vdr  1.7.27
Public Member Functions | Protected Types | Private Attributes
cPalette Class Reference

#include <osd.h>

List of all members.

Public Member Functions

 cPalette (int Bpp=8)
virtual ~cPalette ()
void SetAntiAliasGranularity (uint FixedColors, uint BlendColors)
int Bpp (void) const
void Reset (void)
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
 cPalette (int Bpp=8)
virtual ~cPalette ()
void SetAntiAliasGranularity (uint FixedColors, uint BlendColors)
int Bpp (void) const
void Reset (void)
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]
typedef tIndex tIndexes [MAXNUMCOLORS]

Private Attributes

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

Detailed Description

Definition at line 79 of file include/vdr/osd.h.


Member Typedef Documentation

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

Definition at line 87 of file include/vdr/osd.h.

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

Definition at line 87 of file osd.h.


Constructor & Destructor Documentation

cPalette::cPalette ( int  Bpp = 8)

Initializes the palette with the given color depth.

Definition at line 107 of file osd.c.

References SetAntiAliasGranularity(), and SetBpp().

cPalette::~cPalette ( ) [virtual]

Definition at line 113 of file osd.c.

cPalette::cPalette ( int  Bpp = 8)

Initializes the palette with the given color depth.

virtual cPalette::~cPalette ( ) [virtual]

Member Function Documentation

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 206 of file osd.c.

References antiAliasGranularity.

Referenced by cFreetypeFont::DrawText(), and cBitmap::Scaled().

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.

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

Definition at line 102 of file osd.h.

References bpp.

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.

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 225 of file osd.c.

References color.

Referenced by Index().

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 110 of file osd.h.

References color, Index(), and maxColors.

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 110 of file include/vdr/osd.h.

References color, Index(), and maxColors.

Referenced by cHdffOsd::DrawBitmap(), cPixmapMemory::DrawBitmap(), cBitmap::GetColor(), Index(), SetColor(), and Take().

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 175 of file osd.c.

References color, and numColors.

Referenced by cHdffOsd::DrawBitmap(), cDvbSdFfOsd::Flush(), cHdffOsdRaw::Flush(), 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.

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.

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 134 of file osd.c.

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

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

void cPalette::Replace ( const cPalette Palette)

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

Definition at line 198 of file osd.c.

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

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

void cPalette::Replace ( const cPalette Palette)

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

void cPalette::Reset ( void  )

Resets the palette, making it contain no colors.

Definition at line 128 of file osd.c.

References modified, and numColors.

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

void cPalette::Reset ( void  )

Resets the palette, making it contain no colors.

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 117 of file osd.c.

References antiAliasGranularity, and MAXNUMCOLORS.

Referenced by cPalette().

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.

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.

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 155 of file osd.c.

References bpp, Bpp(), maxColors, and Reset().

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

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 162 of file osd.c.

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

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

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.

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 181 of file osd.c.

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

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

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.


Member Data Documentation

Definition at line 85 of file include/vdr/osd.h.

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

int cPalette::bpp [private]

Definition at line 82 of file include/vdr/osd.h.

Referenced by Bpp(), and SetBpp().

Definition at line 81 of file include/vdr/osd.h.

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

int cPalette::maxColors [private]

Definition at line 83 of file include/vdr/osd.h.

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

bool cPalette::modified [private]

Definition at line 84 of file include/vdr/osd.h.

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

int cPalette::numColors [private]

Definition at line 83 of file include/vdr/osd.h.

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


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