summaryrefslogtreecommitdiff
path: root/osd.c
diff options
context:
space:
mode:
authorKlaus Schmidinger <vdr@tvdr.de>2011-03-12 16:08:08 +0100
committerKlaus Schmidinger <vdr@tvdr.de>2011-03-12 16:08:08 +0100
commit2bd17596a045fd77a5b0cf757d9a954c0f23d1f7 (patch)
treeda6bc587d47a7f5c38d6001c410587fb203001ff /osd.c
parent11cca8015c0c1b66a9a4bb9255ab0b1183cca529 (diff)
downloadvdr-2bd17596a045fd77a5b0cf757d9a954c0f23d1f7.tar.gz
vdr-2bd17596a045fd77a5b0cf757d9a954c0f23d1f7.tar.bz2
The original display size of subtitles is now used to scale them properly when displaying them on an HD OSD1.7.17
Diffstat (limited to 'osd.c')
-rw-r--r--osd.c26
1 files changed, 25 insertions, 1 deletions
diff --git a/osd.c b/osd.c
index 4b4105ab..3a535561 100644
--- a/osd.c
+++ b/osd.c
@@ -4,7 +4,7 @@
* See the main source file 'vdr.c' for copyright information and
* how to reach the author.
*
- * $Id: osd.c 2.16 2011/02/27 11:57:37 kls Exp $
+ * $Id: osd.c 2.17 2011/03/12 15:32:33 kls Exp $
*/
#include "osd.h"
@@ -807,6 +807,30 @@ void cBitmap::ShrinkBpp(int NewBpp)
}
}
+cBitmap *cBitmap::Scale(double FactorX, double FactorY)
+{
+ // Fixed point scaling code based on www.inversereality.org/files/bitmapscaling.pdf
+ // by deltener@mindtremors.com
+ cBitmap *b = new cBitmap(int(round(Width() * FactorX)), int(round(Height() * FactorY)), Bpp(), X0(), Y0());
+ b->Replace(*this); // copy palette
+ int RatioX = (Width() << 16) / b->Width();
+ int RatioY = (Height() << 16) / b->Height();
+ tIndex *DestRow = b->bitmap;
+ int SourceY = 0;
+ for (int y = 0; y < b->Height(); y++) {
+ int SourceX = 0;
+ tIndex *SourceRow = bitmap + (SourceY >> 16) * Width();
+ tIndex *Dest = DestRow;
+ for (int x = 0; x < b->Width(); x++) {
+ *Dest++ = SourceRow[SourceX >> 16];
+ SourceX += RatioX;
+ }
+ SourceY += RatioY;
+ DestRow += b->Width();
+ }
+ return b;
+}
+
// --- cRect -----------------------------------------------------------------
const cRect cRect::Null;