vdr
2.2.0
|
#include <osd.h>
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 tColor * | Colors (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 |
|
protected |
cPalette::cPalette | ( | int | Bpp = 8 | ) |
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 216 of file osd.c.
Referenced by Color(), cFreetypeFont::DrawText(), and cBitmap::Scaled().
|
inline |
Definition at line 111 of file osd.h.
References bpp, Color(), Index(), and Reset().
Referenced by Color(), cSubtitleObject::DecodeSubBlock(), cFreetypeFont::DrawText(), cDvbSdFfOsd::Flush(), cSubtitleObject::Parse(), cBitmap::ReduceBpp(), cSubtitleObject::Render(), cSubtitleRegion::Render(), and cBitmap::Scaled().
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 235 of file osd.c.
Referenced by Color().
|
inline |
Returns the color at the given Index.
If Index is outside the valid range, 0 will be returned.
Definition at line 119 of file osd.h.
References Blend(), Bpp(), ClosestColor(), Colors(), Index(), Replace(), SetBpp(), SetColor(), and Take().
Referenced by Bpp(), cPixmapMemory::Data(), cPixmap::DirtyDrawPort(), cPixmapMemory::DrawBitmap(), cBitmap::GetColor(), cOsd::Height(), cSubtitleObject::Render(), cBitmap::SetOffset(), and cImage::SetPixel().
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 185 of file osd.c.
Referenced by Color(), cHdffOsd::DrawBitmap(), cDvbSdFfOsd::Flush(), cHdffOsdRaw::Flush(), and cBitmap::ShrinkBpp().
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 144 of file osd.c.
Referenced by Bpp(), Color(), cBitmap::DrawPixel(), cBitmap::DrawRectangle(), cFreetypeFont::DrawText(), cBitmap::SetIndex(), cBitmap::SetOffset(), and cBitmap::ShrinkBpp().
void cPalette::Replace | ( | const cPalette & | Palette | ) |
Replaces the colors of this palette with the colors from the given palette.
Definition at line 208 of file osd.c.
References antiAliasGranularity, color, and numColors.
Referenced by Color(), cBitmap::DrawBitmap(), cDvbSubtitleConverter::FinishPage(), cSubtitleObject::Parse(), cBitmap::ReduceBpp(), cBitmap::Scaled(), and cBitmap::ShrinkBpp().
void cPalette::Reset | ( | void | ) |
Resets the palette, making it contain no colors.
Definition at line 138 of file osd.c.
Referenced by Bpp(), cBitmap::DrawBitmap(), and cBitmap::DrawRectangle().
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 127 of file osd.c.
References MAXNUMCOLORS.
Referenced by cOsd::Height().
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 165 of file osd.c.
Referenced by Color(), cBitmap::ReduceBpp(), cBitmap::Scaled(), 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 172 of file osd.c.
Referenced by Color(), cSubtitleClut::cSubtitleClut(), cDvbSpuBitmap::getBitmap(), cSubtitleClut::SetColor(), cBitmap::SetXpm(), 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 191 of file osd.c.
References color, and numColors.
Referenced by Color(), and cBitmap::DrawBitmap().
|
private |
|
private |
Definition at line 90 of file osd.h.
Referenced by Replace(), cBitmap::SetXpm(), and Take().
|
private |