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));
176 cBitmap(
int Width,
int Height,
int Bpp,
int X0 = 0,
int Y0 = 0);
183 cBitmap(
const char *
const Xpm[]);
186 int X0(
void)
const {
return x0; }
187 int Y0(
void)
const {
return y0; }
188 int Width(
void)
const {
return width; }
189 int Height(
void)
const {
return height; }
190 void SetSize(
int Width,
int Height);
197 bool Contains(
int x,
int y)
const;
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);
242 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);
248 void DrawRectangle(
int x1,
int y1,
int x2,
int y2,
tColor Color);
253 void DrawEllipse(
int x1,
int y1,
int x2,
int y2,
tColor Color,
int Quadrants = 0);
263 void DrawSlope(
int x1,
int y1,
int x2,
int y2,
tColor Color,
int Type);
275 const tIndex *Data(
int x,
int y)
const;
279 void ReduceBpp(
const cPalette &Palette);
285 void ShrinkBpp(
int NewBpp);
290 cBitmap *Scaled(
double FactorX,
double FactorY,
bool AntiAlias =
false)
const;
301 int Width(
void)
const {
return x2 - x1 + 1; }
302 int Height(
void)
const {
return y2 - y1 + 1; }
318 int X(
void)
const {
return x; }
319 int Y(
void)
const {
return y; }
322 void Set(
int X,
int Y) { x = X; y = Y; }
324 void Shift(
int Dx,
int Dy) { x += Dx; y += Dy; }
336 cSize(
int Width,
int Height) { width = Width; height = Height; }
341 int Width(
void)
const {
return width; }
342 int Height(
void)
const {
return height; }
345 void Set(
int Width,
int Height) { width = Width; height = Height; }
347 bool Contains(
const cPoint &Point)
const {
return 0 <= Point.
X() && 0 <= Point.
Y() && Point.
X() < width && Point.
Y() < height; }
348 void Grow(
int Dw,
int Dh) { width += 2 * Dw; height += 2 * Dh; }
358 cRect(
void): point(0, 0), size(0, 0) {}
359 cRect(
int X,
int Y,
int Width,
int Height): point(X, Y), size(Width, Height) {}
362 cRect(
const cRect &Rect): point(Rect.Point()), size(Rect.Size()) {}
365 int X(
void)
const {
return point.
X(); }
366 int Y(
void)
const {
return point.
Y(); }
369 int Left(
void)
const {
return X(); }
370 int Top(
void)
const {
return Y(); }
371 int Right(
void)
const {
return X() + Width() - 1; }
372 int Bottom(
void)
const {
return Y() + Height() - 1; }
375 void Set(
int X,
int Y,
int Width,
int Height) { point.
Set(X, Y); size.
Set(Width, Height); }
379 void SetSize(
int Width,
int Height) { size.
Set(Width, Height); }
385 void SetLeft(
int Left) { SetWidth(Width() + X() - Left); SetX(Left); }
386 void SetTop(
int Top) { SetHeight(Height() + Y() - Top); SetY(Top); }
387 void SetRight(
int Right) { SetWidth(Right - X() + 1); }
388 void SetBottom(
int Bottom) { SetHeight(Bottom - Y() + 1); }
393 void Grow(
int Dx,
int Dy);
397 bool Contains(
const cPoint &Point)
const;
399 bool Contains(
const cRect &Rect)
const;
401 bool Intersects(
const cRect &Rect)
const;
405 void Combine(
const cRect &Rect);
410 void Combine(
const cPoint &Point);
415 bool IsEmpty(
void)
const {
return Width() <= 0 || Height() <= 0; }
452 #define MAXPIXMAPLAYERS 8 468 void MarkViewPortDirty(
const cRect &Rect);
472 void MarkViewPortDirty(
const cPoint &Point);
476 void MarkDrawPortDirty(
const cRect &Rect);
482 void MarkDrawPortDirty(
const cPoint &Point);
490 virtual void DrawPixmap(
const cPixmap *Pixmap,
const cRect &Dirty);
536 int Layer(
void)
const {
return layer; }
537 int Alpha(
void)
const {
return alpha; }
538 bool Tile(
void)
const {
return tile; }
561 virtual void SetLayer(
int Layer);
568 virtual void SetAlpha(
int Alpha);
573 virtual void SetTile(
bool Tile);
579 virtual void SetViewPort(
const cRect &Rect);
583 virtual void SetDrawPortPoint(
const cPoint &Point,
bool Dirty =
true);
592 virtual void Clear(
void) = 0;
598 virtual void DrawImage(
const cPoint &Point,
const cImage &Image) = 0;
600 virtual void DrawImage(
const cPoint &Point,
int ImageHandle) = 0;
605 virtual void DrawPixel(
const cPoint &Point,
tColor Color) = 0;
610 virtual void DrawBitmap(
const cPoint &Point,
const cBitmap &Bitmap,
tColor ColorFg = 0,
tColor ColorBg = 0,
bool Overlay =
false) = 0;
627 virtual void DrawRectangle(
const cRect &Rect,
tColor Color) = 0;
649 virtual void Render(
const cPixmap *Pixmap,
const cRect &Source,
const cPoint &Dest) = 0;
653 virtual void Copy(
const cPixmap *Pixmap,
const cRect &Source,
const cPoint &Dest) = 0;
681 #define LOCK_PIXMAPS cPixmapMutexLock PixmapMutexLock 694 const uint8_t *
Data(
void) {
return (uint8_t *)data; }
695 virtual void Clear(
void);
697 virtual void DrawImage(
const cPoint &Point,
const cImage &Image);
698 virtual void DrawImage(
const cPoint &Point,
int ImageHandle);
699 virtual void DrawPixel(
const cPoint &Point,
tColor Color);
700 virtual void DrawBitmap(
const cPoint &Point,
const cBitmap &Bitmap,
tColor ColorFg = 0,
tColor ColorBg = 0,
bool Overlay =
false);
702 virtual void DrawRectangle(
const cRect &Rect,
tColor Color);
711 #define MAXOSDAREAS 16 741 cOsd(
int Left,
int Top, uint Level);
788 #ifndef DEPRECATED_GETBITMAP 789 #define DEPRECATED_GETBITMAP 0 791 #if DEPRECATED_GETBITMAP 809 static void SetOsdPosition(
int Left,
int Top,
int Width,
int Height);
819 int Left(
void) {
return left; }
820 int Top(
void) {
return top; }
834 virtual const cSize &MaxPixmapSize(
void)
const;
843 virtual void DestroyPixmap(
cPixmap *Pixmap);
848 virtual void DrawImage(
const cPoint &Point,
const cImage &Image);
851 virtual void DrawImage(
const cPoint &Point,
int ImageHandle);
857 virtual eOsdError CanHandleAreas(
const tArea *Areas,
int NumAreas);
877 virtual void SaveRegion(
int x1,
int y1,
int x2,
int y2);
881 virtual void RestoreRegion(
void);
887 virtual void DrawPixel(
int x,
int y,
tColor Color);
893 virtual void DrawBitmap(
int x,
int y,
const cBitmap &Bitmap,
tColor ColorFg = 0,
tColor ColorBg = 0,
bool ReplacePalette =
false,
bool Overlay =
false);
904 virtual void DrawScaledBitmap(
int x,
int y,
const cBitmap &Bitmap,
double FactorX,
double FactorY,
bool AntiAlias =
false);
909 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);
915 virtual void DrawRectangle(
int x1,
int y1,
int x2,
int y2,
tColor Color);
918 virtual void DrawEllipse(
int x1,
int y1,
int x2,
int y2,
tColor Color,
int Quadrants = 0);
928 virtual void DrawSlope(
int x1,
int y1,
int x2,
int y2,
tColor Color,
int Type);
940 virtual void Flush(
void);
959 #define MAXOSDIMAGES 64 976 virtual int StoreImageData(
const cImage &Image);
987 virtual void DropImageData(
int ImageHandle);
989 static const cImage *GetImageData(
int ImageHandle);
1001 static void UpdateOsdSize(
bool Force =
false);
1006 static bool OsdSizeChanged(
int &State);
1012 static bool SupportsTrueColor(
void);
1014 static int StoreImage(
const cImage &Image);
1024 static void DropImage(
int ImageHandle);
1027 static void Shutdown(
void);
1039 void DrawText(
void);
1043 void Set(
cOsd *Osd,
int Left,
int Top,
int Width,
int Height,
const char *Text,
const cFont *
Font,
tColor ColorFg,
tColor ColorBg);
1052 bool CanScroll(
void) {
return CanScrollUp() || CanScrollDown(); }
1055 void Scroll(
bool Up,
bool Page);
cRect(const cPoint &Point, const cSize &Size)
static int OsdHeight(void)
void SetAntiAliasGranularity(uint FixedColors, uint BlendColors)
Allows the system to optimize utilization of the limited color palette entries when generating blende...
static cOsd * CreateOsd(int Left, int Top, int x0, int y0, int x1, int y1)
void Shift(const cPoint &Dp)
void Shift(int Dx, int Dy)
void Reset(void)
Resets the palette, making it contain no colors.
static cOsdProvider * osdProvider
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 SetHeight(int Height)
virtual void SetActive(bool On)
Sets this OSD to be the active one.
cRect Shifted(const cPoint &Dp) const
bool operator<(const cSize &Size) const
void SetOffset(int X0, int Y0)
Sets the offset of this bitmap to the given values.
void Shift(const cPoint &Dp)
const tColor * Colors(int &NumColors) const
Returns a pointer to the complete color table and stores the number of valid entries in NumColors...
bool operator!=(const cPoint &Point) const
const cRect & DrawPort(void) const
Returns the pixmap's draw port, which is relative to the view port.
int Index(tColor Color)
Returns the index of the given Color (the first color has index 0).
void SetSize(int Width, int Height)
cVector< cPixmap * > pixmaps
tIndex tIndexes[MAXNUMCOLORS]
bool IsEmpty(void) const
Returns true if this rectangle is empty.
cPoint operator-(const cPoint &Point) const
int Lines(void)
Returns the actual number of lines needed to display the full wrapped text.
const uint8_t * Data(void)
tColor Blend(tColor ColorFg, tColor ColorBg, uint8_t Level) const
Determines a color that consists of a linear blend between ColorFg and ColorBg.
cSize(int Width, int Height)
void SetHeight(int Height)
bool Intersects(const tArea &Area) const
bool Contains(const cPoint &Point) const
static void Lock(void)
All public member functions of cPixmap set locks as necessary to make sure they are thread-safe (unle...
bool operator!=(const cRect &Rect) const
bool operator==(const cSize &Size) const
const cRect & ViewPort(void) const
Returns the pixmap's view port, which is relative to the OSD's origin.
bool operator!=(const cSize &Size) const
void Combine(const cRect &Rect)
Combines this rectangle with the given Rect.
cRect Shifted(int Dx, int Dy) const
tColor color[MAXNUMCOLORS]
void SetPoint(int X, int Y)
void Replace(const cPalette &Palette)
Replaces the colors of this palette with the colors from the given palette.
void DrawEllipse(cOsd *Osd, int x1, int y1, int x2, int y2, int Quadrants)
const cSize & Size(void) const
void Set(int Width, int Height)
static int OsdWidth(void)
static cSize maxPixmapSize
cPoint operator-(void) const
double antiAliasGranularity
static cVector< cOsd * > Osds
void Set(const cSize &Size)
void Set(cPoint Point, cSize Size)
const tColor * Data(void) const
void SetBottom(int Bottom)
const cRect & DirtyDrawPort(void) const
Returns the "dirty" rectangle in the draw port of this this pixmap.
tColor GetPixel(const cPoint &Point) const
Returns the pixel value at the given Point.
void Set(int X, int Y, int Width, int Height)
cPoint(const cPoint &Point)
const cRect & DirtyViewPort(void) const
Returns the "dirty" rectangle this pixmap causes on the OSD.
static const cCursesFont Font
The cOsd class is the interface to the "On Screen Display".
void Set(const cPoint &Point)
tColor RgbToColor(uint8_t R, uint8_t G, uint8_t B)
static int IsOpen(void)
Returns true if there is currently a level 0 OSD open.
tColor AlphaBlend(tColor ColorFg, tColor ColorBg, uint8_t AlphaLayer=ALPHA_OPAQUE)
const cPoint & Point(void) const
void DrawSlope(cOsd *Osd, int x1, int y1, int x2, int y2, int Type)
cPoint Shifted(const cPoint &Dp) const
void SetColor(int Index, tColor Color)
Sets the palette entry at Index to Color.
void Grow(int Dx, int Dy)
Grows the rectangle by the given number of pixels in either direction.
cRect(int X, int Y, int Width, int Height)
tColor ArgbToColor(uint8_t A, uint8_t R, uint8_t G, uint8_t B)
const cSize & Size(void) const
void Shift(int Dx, int Dy)
#define OSD_LEVEL_DEFAULT
cSize Grown(int Dw, int Dh) const
cRect Combined(const cPoint &Point) const
Returns the surrounding rectangle that contains this rectangle and the given Point.
virtual bool ProvidesTrueColor(void)
Returns true if this OSD provider is able to handle a true color OSD.
cPixmapMemory * savedPixmap
tColor RgbShade(tColor Color, double Factor)
Returns a brighter (Factor > 0) or darker (Factor < 0) version of the given Color.
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.
tColor Color(int Index) const
Returns the color at the given Index.
tColor GetColor(int x, int y) const
Returns the color at 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...
cRect Combined(const cRect &Rect) const
Returns the surrounding rectangle that contains this rectangle and the given Rect.
void SetPixel(const cPoint &Point, tColor Color)
Sets the pixel at the given Point to Color.
void SetSize(const cSize &Size)
void Grow(int Dw, int Dh)
cRect Grown(int Dw, int Dh) const
void SetBpp(int Bpp)
Sets the color depth of this palette to the given value.
bool IsTrueColor(void) const
Returns 'true' if this is a true color OSD (providing full 32 bit color depth).
cPoint Shifted(int Dx, int Dy) const
void SetPoint(const cPoint &Point)
cPalette(int Bpp=8)
Initializes the palette with the given color depth.
bool operator==(const cRect &Rect) const
bool operator==(const cPoint &Point) const