mirror of
https://github.com/VDR4Arch/vdr.git
synced 2023-10-10 13:36:52 +02:00
Added anti-aliasing when upscaling bitmaps
This commit is contained in:
parent
16bd3bd5b9
commit
8768a9c321
4
HISTORY
4
HISTORY
@ -6557,7 +6557,7 @@ Video Disk Recorder Revision History
|
|||||||
- The original display size of subtitles is now used to scale them properly when
|
- The original display size of subtitles is now used to scale them properly when
|
||||||
displaying them on an HD OSD.
|
displaying them on an HD OSD.
|
||||||
|
|
||||||
2011-03-21: Version 1.7.18
|
2011-03-27: Version 1.7.18
|
||||||
|
|
||||||
- Changed -O2 to -O3 in Make.config.template (reported by Matti Lehtimäki).
|
- Changed -O2 to -O3 in Make.config.template (reported by Matti Lehtimäki).
|
||||||
- Added a missing 'default' case in cPixmapMemory::DrawEllipse().
|
- Added a missing 'default' case in cPixmapMemory::DrawEllipse().
|
||||||
@ -6573,3 +6573,5 @@ Video Disk Recorder Revision History
|
|||||||
- Fixed cUnbufferedFile::Seek() in case it is compiled without USE_FADVISE (thanks
|
- Fixed cUnbufferedFile::Seek() in case it is compiled without USE_FADVISE (thanks
|
||||||
to Juergen Lock).
|
to Juergen Lock).
|
||||||
- Fixed the Language header of the Serbian translation file (thanks to Ville Skyttä).
|
- Fixed the Language header of the Serbian translation file (thanks to Ville Skyttä).
|
||||||
|
- Added anti-aliasing when upscaling bitmaps (improves the display of SD subtitles
|
||||||
|
when replayed on an HD OSD).
|
||||||
|
26
osd.c
26
osd.c
@ -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 2.18 2011/03/13 13:52:01 kls Exp $
|
* $Id: osd.c 2.19 2011/03/27 11:48:39 kls Exp $
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include "osd.h"
|
#include "osd.h"
|
||||||
@ -503,7 +503,6 @@ void cBitmap::DrawPixel(int x, int y, tColor Color)
|
|||||||
{
|
{
|
||||||
x -= x0;
|
x -= x0;
|
||||||
y -= y0;
|
y -= y0;
|
||||||
if (0 <= x && x < width && 0 <= y && y < height)
|
|
||||||
SetIndex(x, y, Index(Color));
|
SetIndex(x, y, Index(Color));
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -815,6 +814,8 @@ cBitmap *cBitmap::Scale(double FactorX, double FactorY)
|
|||||||
b->Replace(*this); // copy palette
|
b->Replace(*this); // copy palette
|
||||||
int RatioX = (Width() << 16) / b->Width();
|
int RatioX = (Width() << 16) / b->Width();
|
||||||
int RatioY = (Height() << 16) / b->Height();
|
int RatioY = (Height() << 16) / b->Height();
|
||||||
|
if (FactorX <= 1.0 && FactorY <= 1.0) {
|
||||||
|
// Downscaling - no anti-aliasing:
|
||||||
tIndex *DestRow = b->bitmap;
|
tIndex *DestRow = b->bitmap;
|
||||||
int SourceY = 0;
|
int SourceY = 0;
|
||||||
for (int y = 0; y < b->Height(); y++) {
|
for (int y = 0; y < b->Height(); y++) {
|
||||||
@ -828,6 +829,27 @@ cBitmap *cBitmap::Scale(double FactorX, double FactorY)
|
|||||||
SourceY += RatioY;
|
SourceY += RatioY;
|
||||||
DestRow += b->Width();
|
DestRow += b->Width();
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
// Upscaling - anti-aliasing:
|
||||||
|
b->SetBpp(8);
|
||||||
|
int SourceY = 0;
|
||||||
|
for (int y = 0; y < b->Height() - 1; y++) {
|
||||||
|
int SourceX = 0;
|
||||||
|
int sy = SourceY >> 16;
|
||||||
|
uint8_t BlendY = 0xFF - ((SourceY >> 8) & 0xFF);
|
||||||
|
for (int x = 0; x < b->Width() - 1; x++) {
|
||||||
|
int sx = SourceX >> 16;
|
||||||
|
uint8_t BlendX = 0xFF - ((SourceX >> 8) & 0xFF);
|
||||||
|
tColor c1 = b->Blend(GetColor(sx, sy), GetColor(sx + 1, sy), BlendX);
|
||||||
|
tColor c2 = b->Blend(GetColor(sx, sy + 1), GetColor(sx + 1, sy + 1), BlendX);
|
||||||
|
tColor c3 = b->Blend(c1, c2, BlendY);
|
||||||
|
b->DrawPixel(x + X0(), y + Y0(), c3);
|
||||||
|
SourceX += RatioX;
|
||||||
|
}
|
||||||
|
SourceY += RatioY;
|
||||||
|
}
|
||||||
|
}
|
||||||
return b;
|
return b;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user