Location:
gdi.h
Link against: gdi.lib
CPalette
Support
Supported from 6.1
Description
Provides user-definable palette support to the GDI.
A palette is a user-defined set of colours, which is a subset of the full range of 24-bit colours. This allows users the advantages of having a low bpp colour mode whilst being able to specify the colours available in that mode. To give an example, the EColor16 mode provides a palette of 16 colours as it provides a mapping between an integer index and a TRgb colour (see the table EGA Low-colour constants). Only a palette of 16 colour enables you to change the palette. Palettes are also used to allow 24-bit bitmaps to be stored in a more compressed form by finding the actual number of different colours used in the bitmap, creating a palette to allow the mapping of these colours to a smaller index space, and encoding the bitmap’s pixels using indexes to this new index space.
A palette has a size which is set at its creation and cannot be altered — the number of entries in the palette. Each entry in a palette is a mapping between that entry’s index and a TRgb value. Palette entries can be got and set at any time between the palette’s creation and destruction. The GDI’s palette support also provides functions to find the nearest palette colour to a requested TRgb colour.
Derivation
CBase | Base class for all classes to be instantiated on the heap |
CPalette | Provides user-definable palette support to the GDI |
|
Defined in CPalette
:
Clear()
, Entries()
, GetDataPtr()
, GetEntry()
, NearestEntry()
, NearestIndex()
, NewDefaultL()
, NewL()
, SetEntry()
, ~CPalette()
Inherited from CBase
:
operator new()
static CPalette* NewL(TInt aNumberOfEntries);
Description
Creates a new palette of the specified number of entries.
Parameters
TInt aNumberOfEntries |
The number of entries in the palette being created. |
|
Return value
CPalette* |
The newly created palette.
|
|
static CPalette* NewDefaultL(TDisplayMode aDispMode);
Description
Creates a new default palette for the specified display mode. The default palette for a particular display mode has one entry for each possible colour in that display mode (4 entries for EGray2, 256 entries for EColor16 etc.); the colour of each index p in the default palette is set to its default value according to its display mode (e.g. if the mode is EColor16 then palette[p]=Color16(p); if the mode is EGray4 then palette[p]=Gray4(p)).
Parameters
TDisplayMode aDispMode |
The display mode for which the palette is to be created.
|
|
Return value
CPalette* |
The newly created palette
|
|
void Clear();
Description
Clears all the entries in the palette to TRgb(0).
void GetDataPtr(TInt aFirstColor,TInt aNumColors,TPtr8& aPtr);
Description
Returns a descriptor over the palette entries for the specifed colors. It is designed so that the descriptor can be passed to another thread and that thread copy the relevant entries.
Parameters
TInt aFirstColor |
The first colour. |
TInt aNumColors |
Number of colours. |
TPtr8& aPtr |
Descriptor. |
|
TInt Entries() const;
Description
Gets the number of entries in the palette
Return value
TInt |
The number of entries in the palette.
|
|
TRgb GetEntry(TInt aPaletteIndex) const;
Description
Gets the rgb value of the palette entry aPaletteIndex.
Parameters
TInt aPaletteIndex |
The index of the palette entry to get.
|
|
Return value
TRgb |
The rgb value of the palette entry
|
|
void SetEntry(TInt aPaletteIndex,const TRgb& aPaletteEntry);
Description
Sets the palette entry aPaletteIndex to the rgb value aPaletteEntry.
Parameters
TInt aPaletteIndex |
The index of the palette entry to be set. |
const TRgb& aPaletteEntry |
The rgb value to set that entry to. |
|
TRgb NearestEntry(const TRgb& aColor) const;
Description
Gets the colour in the palette which is closest to the specified colour.
Parameters
const TRgb& aColor |
The colour to find. |
|
Return value
TRgb |
The colour in the palette which is closest to the specified colour. |
|
TInt NearestIndex(const TRgb& aColor) const;
Description
Gets the index of the colour in the palette which is closest to the specified colour.
Parameters
const TRgb& aColor |
The colour to find. |
|
Return value
TInt |
The index of the colour in the palette which is closest to the specified colour. |
|