SASC-NG
DVBSoftCAM

cPalette Class Reference

#include <osd.h>

Inheritance diagram for cPalette:

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)
void Reset (void)
 Resets the palette, making it contain no colors.
int Index (tColor Color)
tColor Color (int Index)
void SetBpp (int Bpp)
void SetColor (int Index, tColor Color)
const tColor * Colors (int &NumColors)
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)
int ClosestColor (tColor Color, int MaxDiff=INT_MAX)

Protected Types

typedef tIndex tIndexes [MAXNUMCOLORS]

Detailed Description

Definition at line 49 of file osd.h.


Member Typedef Documentation

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

Definition at line 57 of file osd.h.


Constructor & Destructor Documentation

cPalette::cPalette ( int  Bpp = 8)

Initializes the palette with the given color depth.


Member Function Documentation

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

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  ) [inline]

Definition at line 71 of file osd.h.

{ return bpp; }
int cPalette::ClosestColor ( tColor  Color,
int  MaxDiff = INT_MAX 
)

Returns the index of a color in this paltte 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.

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

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

Definition at line 79 of file osd.h.

References Index().

Referenced by cBitmap::GetColor().

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

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.

Referenced by Color().

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.

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::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.


The documentation for this class was generated from the following file:
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines