Added cOsd::DrawScaledBitmap()

This commit is contained in:
Klaus Schmidinger 2015-01-04 15:53:47 +01:00
parent aacdeba5d9
commit fc0094231d
5 changed files with 23 additions and 8 deletions

View File

@ -3262,6 +3262,7 @@ Thomas Reufer <thomas@reufer.ch>
for suggesting to add a note to ePlayMode in device.h that VDR itself always uses
pmAudioVideo when replaying a recording
for fixing a possible crash in the LCARS skin
for implementing cOsd::DrawScaledBitmap()
Eike Sauer <EikeSauer@t-online.de>
for reporting a problem with channels that need more than 5 TS packets for detecting

View File

@ -8331,3 +8331,6 @@ Video Disk Recorder Revision History
"Setup/DVB/Update channels" is set to a value other than "no" or "PIDs only".
- Fixed multiple OBSOLETE marks in channels that are not listed in the SDT in case
"Setup/Miscellaneous/Show channel names with source" is set to "yes".
- The new function cOsd::DrawScaledBitmap() is now used for drawing subtitles.
This function can be reimplemented by high level OSDs which may be able to do
the scaling in hardware or otherwise more efficiently (thanks to Thomas Reufer).

View File

@ -7,7 +7,7 @@
* Original author: Marco Schluessler <marco@lordzodiac.de>
* With some input from the "subtitles plugin" by Pekka Virtanen <pekka.virtanen@sci.fi>
*
* $Id: dvbsubtitle.c 3.5 2014/02/08 12:29:13 kls Exp $
* $Id: dvbsubtitle.c 3.6 2015/01/04 15:46:39 kls Exp $
*/
#include "dvbsubtitle.h"
@ -1077,11 +1077,7 @@ void cDvbSubtitleBitmaps::Draw(cOsd *Osd)
if (State() == 0 || Osd->SetAreas(areas, numAreas) == oeOk) {
for (int i = 0; i < bitmaps.Size(); i++) {
cBitmap *b = bitmaps[i];
if (Scale)
b = b->Scaled(osdFactorX, osdFactorY, AntiAlias);
Osd->DrawBitmap(int(round(b->X0() * osdFactorX)), int(round(b->Y0() * osdFactorY)), *b);
if (b != bitmaps[i])
delete b;
Osd->DrawScaledBitmap(int(round(b->X0() * osdFactorX)), int(round(b->Y0() * osdFactorY)), *b, osdFactorX, osdFactorY, AntiAlias);
}
Osd->Flush();
}

12
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 3.2 2013/09/03 11:59:17 kls Exp $
* $Id: osd.c 3.3 2015/01/04 15:46:39 kls Exp $
*/
#include "osd.h"
@ -1917,6 +1917,16 @@ void cOsd::DrawBitmap(int x, int y, const cBitmap &Bitmap, tColor ColorFg, tColo
}
}
void cOsd::DrawScaledBitmap(int x, int y, const cBitmap &Bitmap, double FactorX, double FactorY, bool AntiAlias)
{
const cBitmap *b = &Bitmap;
if (!DoubleEqual(FactorX, 1.0) || !DoubleEqual(FactorY, 1.0))
b = b->Scaled(FactorX, FactorY, AntiAlias);
DrawBitmap(x, y, *b);
if (b != &Bitmap)
delete b;
}
void cOsd::DrawText(int x, int y, const char *s, tColor ColorFg, tColor ColorBg, const cFont *Font, int Width, int Height, int Alignment)
{
if (isTrueColor)

7
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 3.2 2013/09/06 12:13:47 kls Exp $
* $Id: osd.h 3.3 2015/01/04 15:51:03 kls Exp $
*/
#ifndef __OSD_H
@ -885,6 +885,11 @@ public:
///< If Overlay is true, any pixel in Bitmap that has color index 0 will
///< not overwrite the corresponding pixel in the target area.
///< If this is a true color OSD, ReplacePalette has no meaning.
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 Bitmap at (x, y) and scaled by the given
///< factors. If AntiAlias is true and either of the factors is greater than
///< 1.0, anti-aliasing is applied.
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. If Width and Height are given, the text