PixelLightAPI  .
Public Member Functions
PLGraphics::ImagePalette Class Reference

Color palette (also known as "color index") More...

#include <ImagePalette.h>

List of all members.

Public Member Functions

 ImagePalette ()
 Constructor.
PLGRAPHICS_API ImagePalette (const ImagePalette &cSource)
 Copy constructor.
 ~ImagePalette ()
 Destructor.
PLGRAPHICS_API ImagePaletteoperator= (const ImagePalette &cSource)
 Assignment operator.
void Clear ()
 Clear data.
PLGRAPHICS_API void Create (PLCore::uint32 nColors)
 Create palette.
PLCore::uint32 GetNumOfColors () const
 Get number of colors.
Color3 GetColor (PLCore::uint32 nIndex) const
 Get color.
PLGRAPHICS_API int GetColorIndex (const Color3 &cColor) const
 Get index of color.
PLGRAPHICS_API void SetColor (PLCore::uint32 nIndex, const Color3 &cColor)
 Set color.
PLCore::uint32 AddColor (const Color3 &cColor)
 Add color.
void RebuildColorIndex ()
 Rebuild color index.
PLCore::uint8 * GetData () const
 Get color palette data.

Detailed Description

Color palette (also known as "color index")


Constructor & Destructor Documentation

Constructor.

PLGRAPHICS_API PLGraphics::ImagePalette::ImagePalette ( const ImagePalette cSource)

Copy constructor.

Parameters:
[in]cSourceSource to copy from

Destructor.


Member Function Documentation

PLGRAPHICS_API ImagePalette& PLGraphics::ImagePalette::operator= ( const ImagePalette cSource)

Assignment operator.

Parameters:
[in]cSourceSource to copy from
Returns:
Reference to this object

Clear data.

PLGRAPHICS_API void PLGraphics::ImagePalette::Create ( PLCore::uint32  nColors)

Create palette.

Parameters:
[in]nColorsNumber of colors
PLCore::uint32 PLGraphics::ImagePalette::GetNumOfColors ( ) const [inline]

Get number of colors.

Returns:
Number of colors
Color3 PLGraphics::ImagePalette::GetColor ( PLCore::uint32  nIndex) const [inline]

Get color.

Parameters:
[in]nIndexIndex of color
Returns:
Color, if index is invalid, Color3::Null (-1 -1 -1) is returned
PLGRAPHICS_API int PLGraphics::ImagePalette::GetColorIndex ( const Color3 cColor) const

Get index of color.

Parameters:
[in]cColorColor
Returns:
Index of that color, or -1 if color is not found
Remarks:
When this function is called for the first time, a hash-list of color->index is created to speed up any subsequent call to this function
PLGRAPHICS_API void PLGraphics::ImagePalette::SetColor ( PLCore::uint32  nIndex,
const Color3 cColor 
)

Set color.

Parameters:
[in]nIndexIndex of color
[in]cColorColor
Remarks:
If nIndex is greater than the palette size, it is automatically extended
PLCore::uint32 PLGraphics::ImagePalette::AddColor ( const Color3 cColor) [inline]

Add color.

Parameters:
[in]cColorColor
Returns:
Index of new color

Rebuild color index.

Remarks:
Use this function to invalidate the color index hash map (see GetColorIndex). This only needs to be done if you changed the image data by yourself, e.g. by calling GetData() and manipulation the palette directly. If you use SetColor() or AddColor() instead, this will be done for you automatically.
PLCore::uint8 * PLGraphics::ImagePalette::GetData ( ) const [inline]

Get color palette data.

Returns:
Pointer to color palette, a null pointer on error
Remarks:
If you use this function to change the palette data by yourself, be sure to call RebuildColorIndex() to invalidate the index->color hash map!

The documentation for this class was generated from the following files:


PixelLight PixelLight 0.9.11-R1
Copyright (C) 2002-2012 by The PixelLight Team
Last modified Thu Feb 23 2012 14:09:31
The content of this PixelLight document is published under the
Creative Commons Attribution-NonCommercial-ShareAlike 3.0 Unported