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

Implemented drawing "transparent" texts

This commit is contained in:
Klaus Schmidinger 2004-06-05 11:42:08 +02:00
parent 2a5a55cee7
commit 00645daa93
4 changed files with 14 additions and 6 deletions

View File

@ -715,6 +715,7 @@ Sascha Volkenandt <sascha@akv-soft.de>
bitmap area is covered bitmap area is covered
for reporting a bug in cBitmap::DrawPixel(), which messed with other bitmaps' for reporting a bug in cBitmap::DrawPixel(), which messed with other bitmaps'
palettes in case the pixel coordinates were outside this bitmap palettes in case the pixel coordinates were outside this bitmap
for suggesting to allow drawing "transparent" texts
Malcolm Caldwell <malcolm.caldwell@ntu.edu.au> Malcolm Caldwell <malcolm.caldwell@ntu.edu.au>
for modifying LOF handling to allow for C-band reception for modifying LOF handling to allow for C-band reception

View File

@ -2876,3 +2876,6 @@ Video Disk Recorder Revision History
- Fixed cBitmap::DrawPixel(), which messed with other bitmaps' palettes in case - Fixed cBitmap::DrawPixel(), which messed with other bitmaps' palettes in case
the pixel coordinates were outside this bitmap (thanks to Sascha Volkenandt for the pixel coordinates were outside this bitmap (thanks to Sascha Volkenandt for
reporting this one). reporting this one).
- The cBitmap::DrawText() function now doesn't set any background pixels if the
given background color is clrTransparent. This allows drawing "transparent"
texts (suggested by Sascha Volkenandt).

4
osd.c
View File

@ -4,7 +4,7 @@
* See the main source file 'vdr.c' for copyright information and * See the main source file 'vdr.c' for copyright information and
* how to reach the author. * how to reach the author.
* *
* $Id: osd.c 1.49 2004/06/05 11:15:43 kls Exp $ * $Id: osd.c 1.50 2004/06/05 11:37:42 kls Exp $
*/ */
#include "osd.h" #include "osd.h"
@ -355,6 +355,7 @@ void cBitmap::DrawText(int x, int y, const char *s, tColor ColorFg, tColor Color
int ch = Height ? Height : h; int ch = Height ? Height : h;
if (!Intersects(x, y, x + cw - 1, y + ch - 1)) if (!Intersects(x, y, x + cw - 1, y + ch - 1))
return; return;
if (ColorBg != clrTransparent)
DrawRectangle(x, y, x + cw - 1, y + ch - 1, ColorBg); DrawRectangle(x, y, x + cw - 1, y + ch - 1, ColorBg);
limit = x + cw - x0; limit = x + cw - x0;
if (Width) { if (Width) {
@ -396,6 +397,7 @@ void cBitmap::DrawText(int x, int y, const char *s, tColor ColorFg, tColor Color
for (int row = 0; row < h; row++) { for (int row = 0; row < h; row++) {
cFont::tPixelData PixelData = CharData->lines[row]; cFont::tPixelData PixelData = CharData->lines[row];
for (int col = CharData->width; col-- > 0; ) { for (int col = CharData->width; col-- > 0; ) {
if (ColorBg != clrTransparent || (PixelData & 1))
SetIndex(x + col, y + row, (PixelData & 1) ? fg : bg); SetIndex(x + col, y + row, (PixelData & 1) ? fg : bg);
PixelData >>= 1; PixelData >>= 1;
} }

8
osd.h
View File

@ -4,7 +4,7 @@
* See the main source file 'vdr.c' for copyright information and * See the main source file 'vdr.c' for copyright information and
* how to reach the author. * how to reach the author.
* *
* $Id: osd.h 1.43 2004/05/31 14:09:00 kls Exp $ * $Id: osd.h 1.44 2004/06/05 11:40:12 kls Exp $
*/ */
#ifndef __OSD_H #ifndef __OSD_H
@ -158,7 +158,8 @@ public:
///< Draws the given string at coordinates (x, y) with the given foreground ///< 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 ///< 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 ///< will be drawn into a rectangle with the given size and the given
///< Alignment (default is top-left). ///< Alignment (default is top-left). If ColorBg is clrTransparent, no
///< background pixels will be drawn, which allows drawing "transparent" text.
void DrawRectangle(int x1, int y1, int x2, int y2, tColor Color); 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 ///< 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 ///< (x2, y2) corners with the given Color. If the rectangle covers the entire
@ -276,7 +277,8 @@ public:
///< Draws the given string at coordinates (x, y) with the given foreground ///< 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 ///< 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 ///< will be drawn into a rectangle with the given size and the given
///< Alignment (default is top-left). ///< Alignment (default is top-left). If ColorBg is clrTransparent, no
///< background pixels will be drawn, which allows drawing "transparent" text.
virtual void DrawRectangle(int x1, int y1, int x2, int y2, tColor Color); 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 ///< Draws a filled rectangle defined by the upper left (x1, y1) and lower right
///< (x2, y2) corners with the given Color. ///< (x2, y2) corners with the given Color.