Go to the documentation of this file.
21 #define OSD_LEVEL_DEFAULT 0
22 #define OSD_LEVEL_SUBTITLES 10
24 #define MAXNUMCOLORS 256
25 #define ALPHA_TRANSPARENT 0x00
26 #define ALPHA_OPAQUE 0xFF
27 #define IS_OPAQUE(c) ((c >> 24) == ALPHA_OPAQUE)
28 #define TEXT_ALIGN_BORDER 10 // fraction of the font height used for sizing border
70 return RgbToColor(uint8_t(0xFF * R), uint8_t(0xFF * G), uint8_t(0xFF * B));
183 cBitmap(
const char *
const Xpm[]);
186 int X0(
void)
const {
return x0; }
187 int Y0(
void)
const {
return y0; }
199 bool Covers(
int x1,
int y1,
int x2,
int y2)
const;
202 bool Intersects(
int x1,
int y1,
int x2,
int y2)
const;
205 bool Dirty(
int &x1,
int &y1,
int &x2,
int &y2);
210 bool LoadXpm(
const char *FileName);
213 bool SetXpm(
const char *
const Xpm[],
bool IgnoreNone =
false);
232 void DrawBitmap(
int x,
int y,
const cBitmap &Bitmap,
tColor ColorFg = 0,
tColor ColorBg = 0,
bool ReplacePalette =
false,
bool Overlay =
false);
290 cBitmap *
Scaled(
double FactorX,
double FactorY,
bool AntiAlias =
false)
const;
318 int X(
void)
const {
return x; }
319 int Y(
void)
const {
return y; }
324 void Shift(
int Dx,
int Dy) {
x += Dx;
y += Dy; }
369 int Left(
void)
const {
return X(); }
370 int Top(
void)
const {
return Y(); }
393 void Grow(
int Dx,
int Dy);
452 #define MAXPIXMAPLAYERS 8
681 #define LOCK_PIXMAPS cPixmapMutexLock PixmapMutexLock
694 const uint8_t *
Data(
void) {
return (uint8_t *)
data; }
695 virtual void Clear(
void);
711 #define MAXOSDAREAS 16
788 #ifndef DEPRECATED_GETBITMAP
789 #define DEPRECATED_GETBITMAP 0
791 #if DEPRECATED_GETBITMAP
881 virtual void SaveRegion(
int x1,
int y1,
int x2,
int y2);
897 virtual void DrawBitmap(
int x,
int y,
const cBitmap &Bitmap,
tColor ColorFg = 0,
tColor ColorBg = 0,
bool ReplacePalette =
false,
bool Overlay =
false);
908 virtual void DrawScaledBitmap(
int x,
int y,
const cBitmap &Bitmap,
double FactorX,
double FactorY,
bool AntiAlias =
false);
922 virtual void DrawEllipse(
int x1,
int y1,
int x2,
int y2,
tColor Color,
int Quadrants = 0);
932 virtual void DrawSlope(
int x1,
int y1,
int x2,
int y2,
tColor Color,
int Type);
944 virtual void Flush(
void);
963 #define MAXOSDIMAGES 64
1059 void Scroll(
bool Up,
bool Page);
const tIndex * Data(int x, int y) const
Returns the address of the index byte at the given coordinates.
cRect Grown(int Dw, int Dh) const
static int OsdWidth(void)
void Shift(const cPoint &Dp)
void Grow(int Dw, int Dh)
static cVector< cOsd * > Osds
void 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,...
cPoint Shifted(int Dx, int Dy) const
virtual void DrawEllipse(const cRect &Rect, tColor Color, int Quadrants=0)
Draws a filled ellipse with the given Color that fits into the given rectangle.
virtual ~cOsd()
Shuts down the OSD.
static cOsd * NewOsd(int Left, int Top, uint Level=OSD_LEVEL_DEFAULT)
Returns a pointer to a newly created cOsd object, which will be located at the given coordinates.
virtual void Clear(void)
Clears the pixmap's draw port by setting all pixels to be fully transparent.
static cImage * images[MAXOSDIMAGES]
cPixmapMemory * savedPixmap
cRect(const cPoint &Point, const cSize &Size)
void SetIndex(int x, int y, tIndex Index)
Sets the index at the given coordinates to Index.
void SetSize(int Width, int Height)
Sets the size of this bitmap to the given values.
static bool SupportsTrueColor(void)
Returns true if the current OSD provider is able to handle a true color OSD.
void Set(const cPoint &Point)
void SetHeight(int Height)
cPoint(const cPoint &Point)
virtual void Clear(void)=0
Clears the pixmap's draw port by setting all pixels to be fully transparent.
bool IsEmpty(void) const
Returns true if this rectangle is empty.
tColor GetColor(int x, int y) const
Returns the color at the given coordinates.
virtual void DrawText(const cPoint &Point, const char *s, tColor ColorFg, tColor ColorBg, const cFont *Font, int Width=0, int Height=0, int Alignment=taDefault)=0
Draws the given string at Point with the given foreground and background color and font.
const cSize & Size(void) const
virtual void Copy(const cPixmap *Pixmap, const cRect &Source, const cPoint &Dest)=0
Copies the part of the given Pixmap covered by Source into this pixmap at location Dest.
void Fill(tIndex Index)
Fills the bitmap data with the given Index.
virtual void SetDrawPortPoint(const cPoint &Point, bool Dirty=true)
Sets the pixmap's draw port to the given Point.
virtual void SetLayer(int Layer)
Sets the layer of this pixmap to the given value.
virtual void 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.
void 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 g...
tColor Color(int Index) const
Returns the color at the given Index.
virtual void Scroll(const cPoint &Dest, const cRect &Source=cRect::Null)
Scrolls the data in the pixmap's draw port to the given Dest point.
The cOsd class is the interface to the "On Screen Display".
virtual void DrawImage(const cPoint &Point, const cImage &Image)=0
Draws the given Image into this pixmap at the given Point.
void SetHeight(int Height)
bool operator==(const cRect &Rect) const
virtual void DrawPixel(const cPoint &Point, tColor Color)=0
Sets the pixel at the given Point to the given Color, which is a full 32 bit ARGB value.
static cSize maxPixmapSize
bool operator!=(const cRect &Rect) const
virtual void SetAlpha(int Alpha)
Sets the alpha value of this pixmap to the given value.
virtual void Pan(const cPoint &Dest, const cRect &Source=cRect::Null)
Does the same as Scroll(), but also shifts the draw port accordingly, so that the view port doesn't g...
virtual cPixmap * CreatePixmap(int Layer, const cRect &ViewPort, const cRect &DrawPort=cRect::Null)
Creates a new true color pixmap on this OSD (see cPixmap for details).
virtual void DrawEllipse(const cRect &Rect, tColor Color, int Quadrants=0)=0
Draws a filled ellipse with the given Color that fits into the given rectangle.
tColor HsvToColor(double H, double S, double V)
Converts the given Hue (0..360), Saturation (0..1) and Value (0..1) to an RGB tColor value.
void SetClean(void)
Resets the "dirty" rectangles of this pixmap.
cBitmap * Scaled(double FactorX, double FactorY, bool AntiAlias=false) const
Creates a copy of this bitmap, scaled by the given factors.
void 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...
cRect Shifted(const cPoint &Dp) const
virtual void SetViewPort(const cRect &Rect)
Sets the pixmap's view port to the given Rect.
tColor ArgbToColor(uint8_t A, uint8_t R, uint8_t G, uint8_t B)
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)
Draws the given string at coordinates (x, y) with the given foreground and background color and font.
static void UpdateOsdSize(bool Force=false)
Inquires the actual size of the video display and adjusts the OSD and font sizes accordingly.
virtual void SaveRegion(int x1, int y1, int x2, int y2)
Saves the region defined by the given coordinates for later restoration through RestoreRegion().
virtual void DestroyPixmap(cPixmap *Pixmap)
Destroys the given Pixmap, which has previously been created by a call to CreatePixmap().
void Reset(void)
Resets the palette, making it contain no colors.
cBitmap * bitmaps[MAXOSDAREAS]
virtual cOsd * CreateOsd(int Left, int Top, uint Level)=0
Returns a pointer to a newly created cOsd object, which will be located at the given coordinates.
tColor GetPixel(const cPoint &Point) const
Returns the pixel value at the given Point.
double antiAliasGranularity
tColor AlphaBlend(tColor ColorFg, tColor ColorBg, uint8_t AlphaLayer=ALPHA_OPAQUE)
static int IsOpen(void)
Returns true if there is currently a level 0 OSD open.
tColor RgbToColor(uint8_t R, uint8_t G, uint8_t B)
void Set(const cSize &Size)
cSize(int Width, int Height)
virtual void DrawImage(const cPoint &Point, const cImage &Image)
Draws the given Image on this OSD at the given Point.
bool LoadXpm(const char *FileName)
Calls SetXpm() with the data from the file FileName.
virtual void Scroll(const cPoint &Dest, const cRect &Source=cRect::Null)=0
Scrolls the data in the pixmap's draw port to the given Dest point.
tColor RgbShade(tColor Color, double Factor)
Returns a brighter (Factor > 0) or darker (Factor < 0) version of the given Color.
bool Intersects(int x1, int y1, int x2, int y2) const
Returns true if the rectangle defined by the given coordinates intersects with this bitmap.
void Combine(const cRect &Rect)
Combines this rectangle with the given Rect.
void SetSize(int Width, int Height)
const cRect & DirtyViewPort(void) const
Returns the "dirty" rectangle this pixmap causes on the OSD.
virtual void 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 g...
virtual void Copy(const cPixmap *Pixmap, const cRect &Source, const cPoint &Dest)
Copies the part of the given Pixmap covered by Source into this pixmap at location Dest.
virtual void DrawImage(const cPoint &Point, int ImageHandle)=0
Draws the image referenced by the given ImageHandle into this pixmap at the given Point.
void SetBpp(int Bpp)
Sets the color depth of this palette to the given value.
const tColor * Colors(int &NumColors) const
Returns a pointer to the complete color table and stores the number of valid entries in NumColors.
static int OsdHeight(void)
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).
void Clean(void)
Marks the dirty area as clean.
virtual void RestoreRegion(void)
Restores the region previously saved by a call to SaveRegion().
void Scroll(bool Up, bool Page)
bool operator==(const cSize &Size) const
const cPoint & Point(void) const
virtual void 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,...
cPalette(int Bpp=8)
Initializes the palette with the given color depth.
static void Shutdown(void)
Shuts down the OSD provider facility by deleting the current OSD provider.
void Set(cOsd *Osd, int Left, int Top, int Width, int Height, const char *Text, const cFont *Font, tColor ColorFg, tColor ColorBg)
bool Contains(const cPoint &Point) const
Returns true if this rectangle contains Point.
virtual void Fill(tColor Color)
Fills the pixmap's draw port with the given Color.
virtual void DrawPixel(const cPoint &Point, tColor Color)
Sets the pixel at the given Point to the given Color, which is a full 32 bit ARGB value.
static int StoreImage(const cImage &Image)
Stores the given Image for later use with DrawImage() on an OSD or pixmap.
bool Contains(int x, int y) const
Returns true if this bitmap contains the point (x, y).
void Clear(void)
Clears the image data by setting all pixels to be fully transparent.
int Lines(void)
Returns the actual number of lines needed to display the full wrapped text.
void SetPoint(int X, int Y)
void Set(int X, int Y, int Width, int Height)
virtual const cSize & MaxPixmapSize(void) const
Returns the maximum possible size of a pixmap this OSD can create.
cBitmap * GetBitmap(int Area)
Returns a pointer to the bitmap for the given Area, or NULL if no such bitmap exists.
virtual void SetActive(bool On)
Sets this OSD to be the active one.
bool operator==(const cPoint &Point) const
cPoint operator-(void) const
void Grow(int Dx, int Dy)
Grows the rectangle by the given number of pixels in either direction.
cPixmap * RenderPixmaps(void)
Renders the dirty part of all pixmaps into a resulting pixmap that shall be displayed on the OSD.
virtual void DrawPixmap(const cPixmap *Pixmap, const cRect &Dirty)
Draws the Dirty part of the given Pixmap into this pixmap.
bool operator<(const cSize &Size) const
virtual void Render(const cPixmap *Pixmap, const cRect &Source, const cPoint &Dest)
Renders the part of the given Pixmap covered by Source into this pixmap at location Dest.
void Set(int Width, int Height)
bool operator!=(const cPoint &Point) const
const tColor * Data(void) const
cRect Intersected(const cRect &Rect) const
Returns the intersection of this rectangle and the given Rect.
cRect Shifted(int Dx, int Dy) const
virtual void DrawText(const cPoint &Point, const char *s, tColor ColorFg, tColor ColorBg, const cFont *Font, int Width=0, int Height=0, int Alignment=taDefault)
Draws the given string at Point with the given foreground and background color and font.
bool operator!=(const cSize &Size) const
virtual void DrawImage(const cPoint &Point, const cImage &Image)
Draws the given Image into this pixmap at the given Point.
void SetBottom(int Bottom)
void SetColor(int Index, tColor Color)
Sets the palette entry at Index to Color.
cOsd(int Left, int Top, uint Level)
Initializes the OSD with the given coordinates.
void 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 poss...
void Shift(int Dx, int Dy)
void 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 ...
cRect(int X, int Y, int Width, int Height)
bool Covers(int x1, int y1, int x2, int y2) const
Returns true if the rectangle defined by the given coordinates completely covers this bitmap.
const uint8_t * Data(void)
void SetAntiAliasGranularity(uint FixedColors, uint BlendColors)
Allows the system to optimize utilization of the limited color palette entries when generating blende...
virtual void 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...
const cSize & Size(void) const
void Fill(tColor Color)
Fills the image data with the given Color.
static bool OsdSizeChanged(int &State)
Checks if the OSD size has changed and a currently displayed OSD needs to be redrawn.
int ClosestColor(tColor Color, int MaxDiff=INT_MAX) const
Returns the index of a color in this palette that is closest to the given Color.
void Set(cPoint Point, cSize Size)
void MarkDrawPortDirty(const cRect &Rect)
Marks the given rectangle of the draw port of this pixmap as dirty.
virtual bool ProvidesTrueColor(void)
Returns true if this OSD provider is able to handle a true color OSD.
bool Intersects(const tArea &Area) const
bool SetXpm(const char *const Xpm[], bool IgnoreNone=false)
Sets this bitmap to the given XPM data.
tColor Blend(tColor ColorFg, tColor ColorBg, uint8_t Level) const
Determines a color that consists of a linear blend between ColorFg and ColorBg.
void SetPixel(const cPoint &Point, tColor Color)
Sets the pixel at the given Point to Color.
virtual eOsdError SetAreas(const tArea *Areas, int NumAreas)
Sets the sub-areas to the given areas.
virtual void DrawRectangle(const cRect &Rect, tColor Color)
Draws a filled rectangle with the given Color.
void SetSize(const cSize &Size)
virtual int StoreImageData(const cImage &Image)
Copies the given Image and returns a handle for later reference.
cRect Combined(const cPoint &Point) const
Returns the surrounding rectangle that contains this rectangle and the given Point.
virtual void DropImageData(int ImageHandle)
Drops the image data referenced by ImageHandle.
const cRect & ViewPort(void) const
Returns the pixmap's view port, which is relative to the OSD's origin.
void ReduceBpp(const cPalette &Palette)
Reduces the color depth of the bitmap to that of the given Palette.
bool 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 ...
void Shift(int Dx, int Dy)
cRect Combined(const cRect &Rect) const
Returns the surrounding rectangle that contains this rectangle and the given Rect.
virtual void DrawSlope(const cRect &Rect, tColor Color, int Type)
Draws a "slope" with the given Color into the given rectangle.
virtual void Fill(tColor Color)=0
Fills the pixmap's draw port with the given Color.
const cRect & DrawPort(void) const
Returns the pixmap's draw port, which is relative to the view port.
static void Lock(void)
All public member functions of cPixmap set locks as necessary to make sure they are thread-safe (unle...
#define OSD_LEVEL_DEFAULT
virtual void DrawScaledBitmap(int x, int y, const cBitmap &Bitmap, double FactorX, double FactorY, bool AntiAlias=false)
Sets the pixels in the OSD with the data from the given Bitmap, putting the upper left corner of the ...
tColor color[MAXNUMCOLORS]
virtual void DrawBitmap(int x, int y, const cBitmap &Bitmap, tColor ColorFg=0, tColor ColorBg=0, bool ReplacePalette=false, bool Overlay=false)
Sets the pixels in the OSD with the data from the given Bitmap, putting the upper left corner of the ...
static void SetOsdPosition(int Left, int Top, int Width, int Height)
Sets the position and size of the OSD to the given values.
virtual void DrawBitmap(const cPoint &Point, const cBitmap &Bitmap, tColor ColorFg=0, tColor ColorBg=0, bool Overlay=false)
Sets the pixels in the OSD with the data from the given Bitmap, putting the upper left corner of the ...
virtual void DrawSlope(const cRect &Rect, tColor Color, int Type)=0
Draws a "slope" with the given Color into the given rectangle.
void SetOffset(int X0, int Y0)
Sets the offset of this bitmap to the given values.
cVector< cPixmap * > pixmaps
virtual void Pan(const cPoint &Dest, const cRect &Source=cRect::Null)=0
Does the same as Scroll(), but also shifts the draw port accordingly, so that the view port doesn't g...
virtual eOsdError CanHandleAreas(const tArea *Areas, int NumAreas)
Checks whether the OSD can display the given set of sub-areas.
virtual 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)
Draws the given string at coordinates (x, y) with the given foreground and background color and font.
virtual eOsdError SetPalette(const cPalette &Palette, int Area)
Sets the Palette for the given Area (the first area is numbered 0).
tIndex tIndexes[MAXNUMCOLORS]
virtual void Render(const cPixmap *Pixmap, const cRect &Source, const cPoint &Dest)=0
Renders the part of the given Pixmap covered by Source into this pixmap at location Dest.
const cRect & DirtyDrawPort(void) const
Returns the "dirty" rectangle in the draw port of this this pixmap.
static cOsdProvider * osdProvider
bool Contains(const cPoint &Point) const
virtual void DrawBitmap(const cPoint &Point, const cBitmap &Bitmap, tColor ColorFg=0, tColor ColorBg=0, bool Overlay=false)=0
Sets the pixels in the OSD with the data from the given Bitmap, putting the upper left corner of the ...
int Index(tColor Color)
Returns the index of the given Color (the first color has index 0).
cPoint operator-(const cPoint &Point) const
bool Intersects(const cRect &Rect) const
Returns true if this rectangle intersects with Rect.
void Replace(const cPalette &Palette)
Replaces the colors of this palette with the colors from the given palette.
virtual void SetTile(bool Tile)
Sets the tile property of this pixmap to the given value.
virtual void Flush(void)
Actually commits all data to the OSD hardware.
cPixmap * AddPixmap(cPixmap *Pixmap)
Adds the given Pixmap to the list of currently active pixmaps in this OSD.
cSize Grown(int Dw, int Dh) const
virtual void DrawRectangle(const cRect &Rect, tColor Color)=0
Draws a filled rectangle with the given Color.
void Shift(const cPoint &Dp)
static const cCursesFont Font
void SetPoint(const cPoint &Point)
cPoint Shifted(const cPoint &Dp) const
void ShrinkBpp(int NewBpp)
Shrinks the color depth of the bitmap to NewBpp by keeping only the 2^NewBpp most frequently used col...
static const cImage * GetImageData(int ImageHandle)
Gets the image data referenced by ImageHandle.
bool IsTrueColor(void) const
Returns 'true' if this is a true color OSD (providing full 32 bit color depth).
void SetAntiAliasGranularity(uint FixedColors, uint BlendColors)
Allows the system to optimize utilization of the limited color palette entries when generating blende...
static void DropImage(int ImageHandle)
Drops the image referenced by the given ImageHandle.
void MarkViewPortDirty(const cRect &Rect)
Marks the given rectangle of the view port of this pixmap as dirty.
void 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.