cPalette Class Reference

#include <osd.h>

Inheritance diagram for cPalette:

Inheritance graph
[legend]

List of all members.

Public Member Functions

 cPalette (int Bpp=8)
 Initializes the palette with the given color depth.
void SetAntiAliasGranularity (uint FixedColors, uint BlendColors)
int Bpp (void) const
void Reset (void)
 Resets the palette, making it contain no colors.
int Index (tColor Color)
tColor Color (int Index) const
void SetBpp (int Bpp)
void SetColor (int Index, tColor Color)
const tColorColors (int &NumColors) const
void Take (const cPalette &Palette, tIndexes *Indexes=NULL, tColor ColorFg=0, tColor ColorBg=0)
void Replace (const cPalette &Palette)
tColor Blend (tColor ColorFg, tColor ColorBg, uint8_t Level) const
int ClosestColor (tColor Color, int MaxDiff=INT_MAX) const

Protected Types

typedef tIndex tIndexes [MAXNUMCOLORS]

Private Attributes

tColor color [MAXNUMCOLORS]
int bpp
int maxColors
int numColors
bool modified
double antiAliasGranularity


Detailed Description

Definition at line 53 of file osd.h.


Member Typedef Documentation

typedef tIndex cPalette::tIndexes[MAXNUMCOLORS] [protected]

Definition at line 61 of file osd.h.


Constructor & Destructor Documentation

cPalette::cPalette ( int  Bpp = 8  ) 

Initializes the palette with the given color depth.

Definition at line 21 of file osd.c.

References SetAntiAliasGranularity(), and SetBpp().

Here is the call graph for this function:


Member Function Documentation

void cPalette::SetAntiAliasGranularity ( uint  FixedColors,
uint  BlendColors 
)

Allows the system to optimize utilization of the limited color palette entries when generating blended colors for anti-aliasing. FixedColors is the maximum number of colors used, and BlendColors is the maximum number of foreground/background color combinations used with anti-aliasing. If this function is not called with useful values, the palette may be filled up with many shades of a single color combination, and may not be able to serve all requested colors. By default the palette assumes there will be 10 fixed colors and 10 color combinations.

Definition at line 27 of file osd.c.

References antiAliasGranularity, and MAXNUMCOLORS.

Referenced by cPalette().

int cPalette::Bpp ( void   )  const [inline]

void cPalette::Reset ( void   ) 

Resets the palette, making it contain no colors.

Definition at line 38 of file osd.c.

References modified, and numColors.

Referenced by cBitmap::DrawBitmap(), cBitmap::DrawRectangle(), and SetBpp().

int cPalette::Index ( tColor  Color  ) 

Returns the index of the given Color (the first color has index 0). If Color is not yet contained in this palette, it will be added if there is a free slot. If the color can't be added to this palette, the closest existing color will be returned.

Definition at line 44 of file osd.c.

References ClosestColor(), color, maxColors, modified, and numColors.

Referenced by cBitmap::DrawPixel(), cBitmap::DrawRectangle(), cFreetypeFont::DrawText(), cBitmap::ShrinkBpp(), and Take().

Here is the call graph for this function:

tColor cPalette::Color ( int  Index  )  const [inline]

Returns the color at the given Index. If Index is outside the valid range, 0 will be returned.

Definition at line 83 of file osd.h.

References color, and maxColors.

Referenced by cBitmap::GetColor(), and Take().

void cPalette::SetBpp ( int  Bpp  ) 

Sets the color depth of this palette to the given value. The palette contents will be reset, so that it contains no colors.

Definition at line 65 of file osd.c.

References bpp, maxColors, and Reset().

Referenced by cPalette(), cBitmap::ReduceBpp(), cSubtitleRegion::SetDepth(), cBitmap::SetXpm(), and cBitmap::ShrinkBpp().

Here is the call graph for this function:

void cPalette::SetColor ( int  Index,
tColor  Color 
)

Sets the palette entry at Index to Color. If Index is larger than the number of currently used entries in this palette, the entries in between will have undefined values.

Definition at line 72 of file osd.c.

References color, maxColors, modified, and numColors.

Referenced by cDvbSpuBitmap::getBitmap(), Replace(), cSubtitleClut::SetColor(), cBitmap::SetXpm(), and cBitmap::ShrinkBpp().

const tColor * cPalette::Colors ( int &  NumColors  )  const

Returns a pointer to the complete color table and stores the number of valid entries in NumColors. If no colors have been stored yet, NumColors will be set to 0 and the function will return NULL.

Definition at line 85 of file osd.c.

References color, and numColors.

Referenced by cDvbOsd::Flush(), and cBitmap::ShrinkBpp().

void cPalette::Take ( const cPalette Palette,
tIndexes Indexes = NULL,
tColor  ColorFg = 0,
tColor  ColorBg = 0 
)

Takes the colors from the given Palette and adds them to this palette, using existing entries if possible. If Indexes is given, it will be filled with the index values that each color of Palette has in this palette. If either of ColorFg or ColorBg is not zero, the first color in Palette will be taken as ColorBg, and the second color will become ColorFg.

Definition at line 91 of file osd.c.

References color, Color(), Index(), and numColors.

Referenced by cBitmap::DrawBitmap(), and cOsd::SetPalette().

Here is the call graph for this function:

void cPalette::Replace ( const cPalette Palette  ) 

Replaces the colors of this palette with the colors from the given palette.

Definition at line 107 of file osd.c.

References antiAliasGranularity, color, numColors, and SetColor().

Referenced by cBitmap::DrawBitmap(), cBitmap::ReduceBpp(), and cBitmap::ShrinkBpp().

Here is the call graph for this function:

tColor cPalette::Blend ( tColor  ColorFg,
tColor  ColorBg,
uint8_t  Level 
) const

Determines a color that consists of a linear blend between ColorFg and ColorBg. If Level is 0, the result is ColorBg, if it is 255, the result is ColorFg. If SetAntiAliasGranularity() has been called previously, Level will be mapped to a limited range of levels that allow to make best use of the palette entries.

Definition at line 115 of file osd.c.

References antiAliasGranularity.

Referenced by cFreetypeFont::DrawText().

int cPalette::ClosestColor ( tColor  Color,
int  MaxDiff = INT_MAX 
) const

Returns the index of a color in this palette that is closest to the given Color. MaxDiff can be used to control the maximum allowed color difference. If no color with a maximum difference of MaxDiff can be found, -1 will be returned. With the default value of INT_MAX, there will always be a valid color index returned, but the color may be completely different.

Definition at line 134 of file osd.c.

References color, and numColors.

Referenced by Index().


Member Data Documentation

tColor cPalette::color[MAXNUMCOLORS] [private]

Definition at line 55 of file osd.h.

Referenced by ClosestColor(), Color(), Colors(), Index(), Replace(), SetColor(), cBitmap::SetXpm(), and Take().

int cPalette::bpp [private]

Definition at line 56 of file osd.h.

Referenced by Bpp(), and SetBpp().

int cPalette::maxColors [private]

Definition at line 57 of file osd.h.

Referenced by Color(), Index(), SetBpp(), and SetColor().

int cPalette::numColors [private]

Definition at line 57 of file osd.h.

Referenced by ClosestColor(), Colors(), Index(), Replace(), Reset(), SetColor(), and Take().

bool cPalette::modified [private]

Definition at line 58 of file osd.h.

Referenced by Index(), Reset(), and SetColor().

Definition at line 59 of file osd.h.

Referenced by Blend(), Replace(), and SetAntiAliasGranularity().


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

Generated on Tue Jan 13 14:30:47 2009 for VDR by  doxygen 1.5.6