diff options
-rw-r--r-- | CONTRIBUTORS | 1 | ||||
-rw-r--r-- | HISTORY | 3 | ||||
-rw-r--r-- | osd.c | 36 | ||||
-rw-r--r-- | osd.h | 9 |
4 files changed, 36 insertions, 13 deletions
diff --git a/CONTRIBUTORS b/CONTRIBUTORS index b1edf4d7..cc43b028 100644 --- a/CONTRIBUTORS +++ b/CONTRIBUTORS @@ -1080,6 +1080,7 @@ Andreas Regel <andreas.regel@gmx.de> cSkins::Message() for reporting a problem in handling Transfer Mode for radio channels for reporting a problem with messages when a cOsdObject uses the raw OSD + for implementing palette replace mode in the OSD bitmaps Thomas Bergwinkl <Thomas.Bergwinkl@t-online.de> for fixing the validity check for channel IDs, because some providers use TIDs @@ -3630,3 +3630,6 @@ Video Disk Recorder Revision History //#define TEST_cVideoRepacker in remux.c. +- When drawing a bitmap to the OSD, the existing palette of the target can now be + replaced with the new one instead of adding the new entries (thanks to Andreas + Regel). @@ -4,7 +4,7 @@ * See the main source file 'vdr.c' for copyright information and * how to reach the author. * - * $Id: osd.c 1.61 2005/06/11 14:31:36 kls Exp $ + * $Id: osd.c 1.62 2005/06/19 10:43:04 kls Exp $ */ #include "osd.h" @@ -86,6 +86,13 @@ void cPalette::Take(const cPalette &Palette, tIndexes *Indexes, tColor ColorFg, } } +void cPalette::Replace(const cPalette &Palette) +{ + for (int i = 0; i < Palette.numColors; i++) + SetColor(i, Palette.color[i]); + numColors = Palette.numColors; +} + // --- cBitmap --------------------------------------------------------------- cBitmap::cBitmap(int Width, int Height, int Bpp, int X0, int Y0) @@ -337,19 +344,28 @@ void cBitmap::DrawPixel(int x, int y, tColor Color) SetIndex(x, y, Index(Color)); } -void cBitmap::DrawBitmap(int x, int y, const cBitmap &Bitmap, tColor ColorFg, tColor ColorBg) +void cBitmap::DrawBitmap(int x, int y, const cBitmap &Bitmap, tColor ColorFg, tColor ColorBg, bool ReplacePalette) { if (bitmap && Bitmap.bitmap && Intersects(x, y, x + Bitmap.Width() - 1, y + Bitmap.Height() - 1)) { if (Covers(x, y, x + Bitmap.Width() - 1, y + Bitmap.Height() - 1)) Reset(); x -= x0; y -= y0; - tIndexes Indexes; - Take(Bitmap, &Indexes, ColorFg, ColorBg); - for (int ix = 0; ix < Bitmap.width; ix++) { - for (int iy = 0; iy < Bitmap.height; iy++) - SetIndex(x + ix, y + iy, Indexes[int(Bitmap.bitmap[Bitmap.width * iy + ix])]); - } + if (ReplacePalette && Covers(x + x0, y + y0, x + x0 + Bitmap.Width() - 1, y + y0 + Bitmap.Height() - 1)) { + Replace(Bitmap); + for (int ix = 0; ix < Bitmap.width; ix++) { + for (int iy = 0; iy < Bitmap.height; iy++) + SetIndex(x + ix, y + iy, Bitmap.bitmap[Bitmap.width * iy + ix]); + } + } + else { + tIndexes Indexes; + Take(Bitmap, &Indexes, ColorFg, ColorBg); + for (int ix = 0; ix < Bitmap.width; ix++) { + for (int iy = 0; iy < Bitmap.height; iy++) + SetIndex(x + ix, y + iy, Indexes[int(Bitmap.bitmap[Bitmap.width * iy + ix])]); + } + } } } @@ -665,10 +681,10 @@ void cOsd::DrawPixel(int x, int y, tColor Color) bitmaps[i]->DrawPixel(x, y, Color); } -void cOsd::DrawBitmap(int x, int y, const cBitmap &Bitmap, tColor ColorFg, tColor ColorBg) +void cOsd::DrawBitmap(int x, int y, const cBitmap &Bitmap, tColor ColorFg, tColor ColorBg, bool ReplacePalette) { for (int i = 0; i < numBitmaps; i++) - bitmaps[i]->DrawBitmap(x, y, Bitmap, ColorFg, ColorBg); + bitmaps[i]->DrawBitmap(x, y, Bitmap, ColorFg, ColorBg, ReplacePalette); } void cOsd::DrawText(int x, int y, const char *s, tColor ColorFg, tColor ColorBg, const cFont *Font, int Width, int Height, int Alignment) @@ -4,7 +4,7 @@ * See the main source file 'vdr.c' for copyright information and * how to reach the author. * - * $Id: osd.h 1.48 2005/05/14 11:15:55 kls Exp $ + * $Id: osd.h 1.49 2005/06/19 10:35:25 kls Exp $ */ #ifndef __OSD_H @@ -84,6 +84,9 @@ public: ///< 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. + void Replace(const cPalette &Palette); + ///< Replaces the colors of this palette with the colors from the given + ///< palette. }; enum eTextAlignment { taCenter = 0x00, @@ -153,7 +156,7 @@ public: ///< 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. - void DrawBitmap(int x, int y, const cBitmap &Bitmap, tColor ColorFg = 0, tColor ColorBg = 0); + void DrawBitmap(int x, int y, const cBitmap &Bitmap, tColor ColorFg = 0, tColor ColorBg = 0, bool ReplacePalette = 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 @@ -274,7 +277,7 @@ public: ///< If the OSD area has been divided into separate sub-areas, and the ///< given coordinates don't fall into any of these sub-areas, no pixel will ///< be set. - virtual void DrawBitmap(int x, int y, const cBitmap &Bitmap, tColor ColorFg = 0, tColor ColorBg = 0); + virtual void DrawBitmap(int x, int y, const cBitmap &Bitmap, tColor ColorFg = 0, tColor ColorBg = 0, bool ReplacePalette = false); ///< Sets the pixels in the OSD 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 |