vdr  2.2.0
Public Member Functions | Private Attributes | List of all members
cBitmap Class Reference

#include <osd.h>

Public Member Functions

 cBitmap (int Width, int Height, int Bpp, int X0=0, int Y0=0)
 
 cBitmap (const char *FileName)
 
 cBitmap (const char *const Xpm[])
 
virtual ~cBitmap ()
 
int X0 (void) const
 
int Y0 (void) const
 
int Width (void) const
 
int Height (void) const
 
void SetSize (int Width, int Height)
 
void SetOffset (int X0, int Y0)
 
bool Contains (int x, int y) const
 
bool Covers (int x1, int y1, int x2, int y2) const
 
bool Intersects (int x1, int y1, int x2, int y2) const
 
bool Dirty (int &x1, int &y1, int &x2, int &y2)
 
void Clean (void)
 
bool LoadXpm (const char *FileName)
 
bool SetXpm (const char *const Xpm[], bool IgnoreNone=false)
 
void SetIndex (int x, int y, tIndex Index)
 
void Fill (tIndex Index)
 
void DrawPixel (int x, int y, tColor Color)
 
void DrawBitmap (int x, int y, const cBitmap &Bitmap, tColor ColorFg=0, tColor ColorBg=0, bool ReplacePalette=false, bool Overlay=false)
 
void DrawText (int x, int y, const char *s, tColor ColorFg, tColor ColorBg, const cFont *Font, int Width=0, int Height=0, int Alignment=taDefault)
 
void DrawRectangle (int x1, int y1, int x2, int y2, tColor Color)
 
void DrawEllipse (int x1, int y1, int x2, int y2, tColor Color, int Quadrants=0)
 
void DrawSlope (int x1, int y1, int x2, int y2, tColor Color, int Type)
 
const tIndexData (int x, int y) const
 
tColor GetColor (int x, int y) const
 
void ReduceBpp (const cPalette &Palette)
 
void ShrinkBpp (int NewBpp)
 
cBitmapScaled (double FactorX, double FactorY, bool AntiAlias=false) const
 
- Public Member Functions inherited from cPalette
 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
 

Private Attributes

tIndexbitmap
 
int x0
 
int y0
 
int width
 
int height
 
int dirtyX1
 
int dirtyY1
 
int dirtyX2
 
int dirtyY2
 

Additional Inherited Members

- Protected Types inherited from cPalette
typedef tIndex tIndexes[MAXNUMCOLORS]
 

Detailed Description

Definition at line 169 of file osd.h.

Constructor & Destructor Documentation

cBitmap::cBitmap ( int  Width,
int  Height,
int  Bpp,
int  X0 = 0,
int  Y0 = 0 
)

Creates a bitmap with the given Width, Height and color depth (Bpp).

X0 and Y0 define the offset at which this bitmap will be located on the OSD. All coordinates given in the other functions will be relative to this offset (unless specified otherwise).

Definition at line 261 of file osd.c.

References bitmap, height, SetSize(), width, x0, X0(), y0, and Y0().

Referenced by Scaled().

cBitmap::cBitmap ( const char *  FileName)

Creates a bitmap and loads an XPM image from the given file.

Definition at line 271 of file osd.c.

References bitmap, height, LoadXpm(), width, x0, and y0.

cBitmap::cBitmap ( const char *const  Xpm[])

Creates a bitmap from the given XPM data.

Definition at line 280 of file osd.c.

References bitmap, height, SetXpm(), width, x0, and y0.

cBitmap::~cBitmap ( )
virtual

Definition at line 289 of file osd.c.

References bitmap.

Member Function Documentation

void cBitmap::Clean ( void  )

Marks the dirty area as clean.

Definition at line 354 of file osd.c.

References dirtyX1, dirtyX2, dirtyY1, dirtyY2, height, and width.

Referenced by cDvbSdFfOsd::Flush(), cHdffOsd::Flush(), cHdffOsdRaw::Flush(), cSubtitleObject::Parse(), and cHdffOsd::SetAreas().

bool cBitmap::Contains ( int  x,
int  y 
) const

Returns true if this bitmap contains the point (x, y).

Definition at line 317 of file osd.c.

References height, width, x0, and y0.

bool cBitmap::Covers ( int  x1,
int  y1,
int  x2,
int  y2 
) const

Returns true if the rectangle defined by the given coordinates completely covers this bitmap.

Definition at line 324 of file osd.c.

References height, width, x0, and y0.

Referenced by DrawBitmap(), and DrawRectangle().

const tIndex * cBitmap::Data ( int  x,
int  y 
) const

Returns the address of the index byte at the given coordinates.

Definition at line 760 of file osd.c.

References bitmap, and width.

Referenced by cHdffOsd::DrawBitmap(), cPixmapMemory::DrawBitmap(), cDvbSdFfOsd::Flush(), and cHdffOsdRaw::Flush().

bool cBitmap::Dirty ( int &  x1,
int &  y1,
int &  x2,
int &  y2 
)

Tells whether there is a dirty area and returns the bounding rectangle of that area (relative to the bitmaps origin).

Definition at line 342 of file osd.c.

References dirtyX1, dirtyX2, dirtyY1, and dirtyY2.

Referenced by cDvbSdFfOsd::Flush(), cHdffOsd::Flush(), cHdffOsdRaw::Flush(), and cSubtitleObject::Parse().

void cBitmap::DrawBitmap ( int  x,
int  y,
const cBitmap Bitmap,
tColor  ColorFg = 0,
tColor  ColorBg = 0,
bool  ReplacePalette = false,
bool  Overlay = false 
)

Sets the pixels in this bitmap with the data from the given Bitmap, putting the upper left corner of the Bitmap at (x, y).

If ColorFg or ColorBg is given, the first palette entry of the Bitmap will be mapped to ColorBg and the second palette entry will be mapped to ColorFg (palette indexes are defined so that 0 is the background and 1 is the foreground color). ReplacePalette controls whether the target area shall have its palette replaced with the one from Bitmap. If Overlay is true, any pixel in Bitmap that has color index 0 will not overwrite the corresponding pixel in the target area.

Definition at line 533 of file osd.c.

References bitmap, Covers(), height, Height(), Intersects(), cPalette::Replace(), cPalette::Reset(), SetIndex(), cPalette::Take(), width, Width(), x0, and y0.

Referenced by cDvbSubtitleBitmaps::DbgDump(), and cSubtitleObject::Render().

void cBitmap::DrawEllipse ( int  x1,
int  y1,
int  x2,
int  y2,
tColor  Color,
int  Quadrants = 0 
)

Draws a filled ellipse defined by the upper left (x1, y1) and lower right (x2, y2) corners with the given Color.

Quadrants controls which parts of the ellipse are actually drawn: 0 draws the entire ellipse 1..4 draws only the first, second, third or fourth quadrant, respectively 5..8 draws the right, top, left or bottom half, respectively -1..-4 draws the inverted part of the given quadrant If Quadrants is not 0, the coordinates are those of the actual area, not the full circle!

Definition at line 632 of file osd.c.

References DrawRectangle(), Intersects(), and max().

void cBitmap::DrawPixel ( int  x,
int  y,
tColor  Color 
)

Sets the pixel at the given coordinates to the given Color, which is a full 32 bit ARGB value.

If the coordinates are outside the bitmap area, no pixel will be set.

Definition at line 526 of file osd.c.

References cPalette::Index(), SetIndex(), x0, and y0.

Referenced by Scaled().

void cBitmap::DrawRectangle ( int  x1,
int  y1,
int  x2,
int  y2,
tColor  Color 
)

Draws a filled rectangle defined by the upper left (x1, y1) and lower right (x2, y2) corners with the given Color.

If the rectangle covers the entire bitmap area, the color palette will be reset, so that new colors can be used for drawing.

Definition at line 611 of file osd.c.

References bitmap, Covers(), height, cPalette::Index(), Intersects(), max(), min(), cPalette::Reset(), SetIndex(), width, x0, and y0.

Referenced by cSkinDisplayReplay::cProgressBar::cProgressBar(), cDvbSubtitleBitmaps::DbgDump(), DrawEllipse(), DrawSlope(), DrawText(), and cSkinDisplayReplay::cProgressBar::Mark().

void cBitmap::DrawSlope ( int  x1,
int  y1,
int  x2,
int  y2,
tColor  Color,
int  Type 
)

Draws a "slope" into the rectangle defined by the upper left (x1, y1) and lower right (x2, y2) corners with the given Color.

Type controls the direction of the slope and which side of it will be drawn: 0: horizontal, rising, lower 1: horizontal, rising, upper 2: horizontal, falling, lower 3: horizontal, falling, upper 4: vertical, rising, lower 5: vertical, rising, upper 6: vertical, falling, lower 7: vertical, falling, upper

Definition at line 727 of file osd.c.

References DrawRectangle(), and Intersects().

void cBitmap::DrawText ( int  x,
int  y,
const char *  s,
tColor  ColorFg,
tColor  ColorBg,
const cFont Font,
int  Width = 0,
int  Height = 0,
int  Alignment = taDefault 
)

Draws the given string at coordinates (x, y) with the given foreground and background color and font.

If Width and Height are given, the text will be drawn into a rectangle with the given size and the given Alignment (default is top-left). If ColorBg is clrTransparent, no background pixels will be drawn, which allows drawing "transparent" text.

Definition at line 562 of file osd.c.

References bitmap, clrTransparent, DrawRectangle(), cFont::DrawText(), cFont::Height(), Intersects(), max(), taBorder, taBottom, taLeft, taRight, taTop, TEXT_ALIGN_BORDER, cFont::Width(), x0, and y0.

void cBitmap::Fill ( tIndex  Index)

Fills the bitmap data with the given Index.

Definition at line 515 of file osd.c.

References bitmap, dirtyX1, dirtyX2, dirtyY1, dirtyY2, height, and width.

Referenced by cSubtitleRegion::Render().

tColor cBitmap::GetColor ( int  x,
int  y 
) const
inline

Returns the color at the given coordinates.

Definition at line 277 of file osd.h.

References cPalette::Color().

Referenced by cFreetypeFont::DrawText(), Scaled(), and cSubtitleDebug::WriteJpeg().

int cBitmap::Height ( void  ) const
inline
bool cBitmap::Intersects ( int  x1,
int  y1,
int  x2,
int  y2 
) const

Returns true if the rectangle defined by the given coordinates intersects with this bitmap.

Definition at line 333 of file osd.c.

References height, width, x0, and y0.

Referenced by DrawBitmap(), DrawEllipse(), DrawRectangle(), DrawSlope(), and DrawText().

bool cBitmap::LoadXpm ( const char *  FileName)

Calls SetXpm() with the data from the file FileName.

Returns true if the operation was successful.

Definition at line 362 of file osd.c.

References esyslog, MALLOC, cReadLine::Read(), SetXpm(), and skipspace().

Referenced by cBitmap().

void cBitmap::ReduceBpp ( const cPalette Palette)

Reduces the color depth of the bitmap to that of the given Palette.

If Palette's color depth is not smaller than the bitmap's current color depth, or if it is not one of 4bpp or 2bpp, nothing happens. After reducing the color depth the current palette is replaced with the given one.

Definition at line 765 of file osd.c.

References bitmap, cPalette::Bpp(), height, cPalette::Replace(), cPalette::SetBpp(), and width.

Referenced by cDvbSubtitleConverter::FinishPage().

cBitmap * cBitmap::Scaled ( double  FactorX,
double  FactorY,
bool  AntiAlias = false 
) const

Creates a copy of this bitmap, scaled by the given factors.

If AntiAlias is true and either of the factors is greater than 1.0, anti-aliasing is applied. This will also set the color depth of the returned bitmap to 8bpp. The caller must delete the returned bitmap once it is no longer used.

Definition at line 838 of file osd.c.

References bitmap, cPalette::Blend(), cPalette::Bpp(), cBitmap(), DrawPixel(), GetColor(), Height(), min(), cRect::Null, cPalette::Replace(), cPalette::SetBpp(), Width(), X0(), and Y0().

Referenced by cDvbSpuDecoder::Draw(), cSkinLCARSDisplayMenu::DrawLiveIndicator(), cOsd::DrawScaledBitmap(), cSubtitleObject::Render(), and cSubtitleDebug::WriteJpeg().

void cBitmap::SetIndex ( int  x,
int  y,
tIndex  Index 
)

Sets the index at the given coordinates to Index.

Coordinates are relative to the bitmap's origin.

Definition at line 500 of file osd.c.

References bitmap, dirtyX1, dirtyX2, dirtyY1, dirtyY2, height, cPalette::Index(), and width.

Referenced by DrawBitmap(), cSubtitleObject::DrawLine(), DrawPixel(), DrawRectangle(), cFreetypeFont::DrawText(), cDvbSpuBitmap::getBitmap(), and SetXpm().

void cBitmap::SetOffset ( int  X0,
int  Y0 
)
inline

Sets the offset of this bitmap to the given values.

Definition at line 195 of file osd.h.

References cPalette::Color(), DrawEllipse(), DrawSlope(), Font, cPalette::Index(), and taDefault.

Referenced by cDvbSubtitleConverter::FinishPage().

void cBitmap::SetSize ( int  Width,
int  Height 
)

Sets the size of this bitmap to the given values.

Any previous contents of the bitmap will be lost. If Width and Height are the same as the current values, nothing will happen and the bitmap remains unchanged.

Definition at line 294 of file osd.c.

References bitmap, dirtyX1, dirtyX2, dirtyY1, dirtyY2, esyslog, height, Height(), MALLOC, width, and Width().

Referenced by cBitmap(), and SetXpm().

bool cBitmap::SetXpm ( const char *const  Xpm[],
bool  IgnoreNone = false 
)

Sets this bitmap to the given XPM data.

Any previous bitmap or palette data will be overwritten with the new data. If IgnoreNone is true, a "none" color entry will be ignored. Only set IgnoreNone to true if you know that there is a "none" color entry in the XPM data and that this entry is not used! If SetXpm() is called with IgnoreNone set to false and the XPM data contains an unused "none" entry, it will be automatically called again with IgnoreNone set to true. Returns true if the operation was successful.

Definition at line 428 of file osd.c.

References clrTransparent, cPalette::color, esyslog, MAXNUMCOLORS, cPalette::SetBpp(), cPalette::SetColor(), SetIndex(), SetSize(), and skipspace().

Referenced by cBitmap(), and LoadXpm().

void cBitmap::ShrinkBpp ( int  NewBpp)

Shrinks the color depth of the bitmap to NewBpp by keeping only the 2^NewBpp most frequently used colors as defined in the current palette.

If NewBpp is not smaller than the bitmap's current color depth, or if it is not one of 4bpp or 2bpp, nothing happens.

Definition at line 796 of file osd.c.

References bitmap, cPalette::Colors(), height, cPalette::Index(), MAXNUMCOLORS, cPalette::Replace(), cPalette::SetBpp(), cPalette::SetColor(), and width.

Referenced by cDvbSubtitleConverter::FinishPage().

int cBitmap::Width ( void  ) const
inline
int cBitmap::X0 ( void  ) const
inline
int cBitmap::Y0 ( void  ) const
inline

Member Data Documentation

tIndex* cBitmap::bitmap
private
int cBitmap::dirtyX1
private

Definition at line 174 of file osd.h.

Referenced by Clean(), Dirty(), Fill(), SetIndex(), and SetSize().

int cBitmap::dirtyX2
private

Definition at line 174 of file osd.h.

Referenced by Clean(), Dirty(), Fill(), SetIndex(), and SetSize().

int cBitmap::dirtyY1
private

Definition at line 174 of file osd.h.

Referenced by Clean(), Dirty(), Fill(), SetIndex(), and SetSize().

int cBitmap::dirtyY2
private

Definition at line 174 of file osd.h.

Referenced by Clean(), Dirty(), Fill(), SetIndex(), and SetSize().

int cBitmap::height
private
int cBitmap::width
private
int cBitmap::x0
private

Definition at line 172 of file osd.h.

Referenced by cBitmap(), Contains(), Covers(), DrawBitmap(), DrawPixel(), DrawRectangle(), DrawText(), and Intersects().

int cBitmap::y0
private

Definition at line 172 of file osd.h.

Referenced by cBitmap(), Contains(), Covers(), DrawBitmap(), DrawPixel(), DrawRectangle(), DrawText(), and Intersects().


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