1
0
mirror of https://github.com/VDR4Arch/vdr.git synced 2023-10-10 13:36:52 +02:00

Implemented palette replace mode in the OSD bitmaps

This commit is contained in:
Klaus Schmidinger 2005-06-19 10:47:06 +02:00
parent 121678e0ba
commit d68b0a87ae
4 changed files with 36 additions and 13 deletions

View File

@ -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

View File

@ -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).

24
osd.c
View File

@ -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,13 +344,21 @@ 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;
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++) {
@ -351,6 +366,7 @@ void cBitmap::DrawBitmap(int x, int y, const cBitmap &Bitmap, tColor ColorFg, tC
SetIndex(x + ix, y + iy, Indexes[int(Bitmap.bitmap[Bitmap.width * iy + ix])]);
}
}
}
}
void cBitmap::DrawText(int x, int y, const char *s, tColor ColorFg, tColor ColorBg, const cFont *Font, int Width, int Height, int Alignment)
@ -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)

9
osd.h
View File

@ -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