From b9b9ace9a8d2d1c0beda1dc0a2ebc6be9b47c305 Mon Sep 17 00:00:00 2001 From: Klaus Schmidinger Date: Sun, 10 Jun 2007 18:00:00 +0200 Subject: =?UTF-8?q?Version=201.5.3=20-=20Fixed=20some=20spelling=20errors?= =?UTF-8?q?=20in=20'newplugin'=20(thanks=20to=20Ville=20Skytt=C3=A4).=20-?= =?UTF-8?q?=20Fixed=20a=20busy=20loop=20in=20fast=20forward=20if=20the=20n?= =?UTF-8?q?ext=20video=20data=20file=20is=20missing=20=20=20(thanks=20to?= =?UTF-8?q?=20Reinhard=20Nissl).=20-=20Fixed=20handling=20frequencies=20in?= =?UTF-8?q?=20NitFilter::Process()=20(thanks=20to=20Anssi=20Hannula).=20-?= =?UTF-8?q?=20Fixed=20a=20race=20condition=20with=20signal=20handlers=20at?= =?UTF-8?q?=20program=20exit=20(thanks=20to=20Udo=20=20=20Richter).=20-=20?= =?UTF-8?q?Non-primary=20devices=20in=20Transfer=20mode=20are=20now=20also?= =?UTF-8?q?=20used=20for=20recording=20(thanks=20=20=20to=20Anssi=20Hannul?= =?UTF-8?q?a).=20-=20Fixed=20handling=20ChannelUp/Down=20keys=20if=20there?= =?UTF-8?q?=20is=20currently=20a=20replay=20running=20=20=20(thanks=20to?= =?UTF-8?q?=20Marco=20Schl=C3=BC=C3=9Fler).=20-=20The=20new=20SVDRP=20comm?= =?UTF-8?q?and=20REMO=20can=20be=20used=20to=20turn=20VDR's=20remote=20con?= =?UTF-8?q?trol=20off=20and=20=20=20on=20in=20case=20other=20programs=20ne?= =?UTF-8?q?ed=20to=20be=20controlled=20(based=20on=20patches=20from=20Krzy?= =?UTF-8?q?sztof=20=20=20Parma=20and=20Helmut=20Auer).=20-=20Increased=20t?= =?UTF-8?q?he=20maximum=20number=20of=20CA=20system=20ids=20to=20cope=20wi?= =?UTF-8?q?th=20the=20AlphaCrypt=20=20=20CAM's=20version=203.11=20firmware?= =?UTF-8?q?.=20-=20Fixed=20getting=20the=20code=20setting=20from=20the=20l?= =?UTF-8?q?ocale=20(thanks=20to=20Matthias=20Schwarzott).=20-=20Implemente?= =?UTF-8?q?d=20support=20for=20Freetype=20fonts=20(based=20on=20a=20patch?= =?UTF-8?q?=20from=20Alexander=20Riedel).=20=20=20The=20font=20names=20and?= =?UTF-8?q?=20sizes=20can=20be=20adjusted=20in=20the=20"Setup/OSD"=20menu.?= =?UTF-8?q?=20=20=20Note=20that=20VDR=20now=20requires=20freetype=20fonts?= =?UTF-8?q?=20to=20be=20installed=20in=20=20=20/usr/share/fonts/truetype.?= =?UTF-8?q?=20-=20If=20the=20OSD=20device=20in=20use=20has=20at=20least=20?= =?UTF-8?q?8bpp=20bitmap=20depth=20and=20this=20is=20also=20=20=20used=20b?= =?UTF-8?q?y=20the=20current=20skin,=20Freetype=20fonts=20are=20displayed?= =?UTF-8?q?=20"anti-aliased".=20=20=20The=20new=20setup=20parameter=20"OSD?= =?UTF-8?q?/Anti-alias"=20can=20be=20used=20to=20turn=20this=20off.=20-=20?= =?UTF-8?q?The=20new=20function=20cOsd::SetAntiAliasGranularity()=20can=20?= =?UTF-8?q?be=20used=20to=20help=20the=20OSD=20=20=20in=20managing=20the?= =?UTF-8?q?=20available=20color=20palette=20entries=20when=20doing=20anti-?= =?UTF-8?q?aliasing.=20=20=20Skins=20that=20use=208bpp=20bitmaps=20can=20c?= =?UTF-8?q?all=20this=20function=20with=20the=20maximum=20number=20=20=20o?= =?UTF-8?q?f=20colors=20used,=20and=20the=20maximum=20number=20of=20color?= =?UTF-8?q?=20combinations.=20The=20OSD=20will=20=20=20then=20evenly=20spl?= =?UTF-8?q?it=20the=20available=20palette=20entries=20between=20the=20vari?= =?UTF-8?q?ous=20colors=20=20=20combinations,=20so=20that=20fonts=20can=20?= =?UTF-8?q?be=20"anti-aliased".=20By=20default=20a=20total=20of=20=20=2010?= =?UTF-8?q?=20colors=20and=2010=20combinations=20is=20assumed.=20-=20The?= =?UTF-8?q?=20pixel=20fonts=20have=20been=20completely=20removed=20from=20?= =?UTF-8?q?the=20VDR=20source.=20-=20VDR=20is=20now=20"UTF-8=20aware".=20I?= =?UTF-8?q?t=20handles=20strings=20according=20to=20the=20character=20=20?= =?UTF-8?q?=20encoding=20used=20on=20the=20user's=20system.=20All=20intern?= =?UTF-8?q?ationalization=20strings=20and=20=20=20incoming=20SI=20data=20a?= =?UTF-8?q?re=20converted=20to=20the=20system=20encoding.=20-=20Plugins=20?= =?UTF-8?q?that=20handle=20strings=20need=20to=20be=20aware=20that=20on=20?= =?UTF-8?q?systems=20with=20UTF-8=20=20=20encoding=20a=20"character=20symb?= =?UTF-8?q?ol"=20may=20consist=20of=20more=20than=20a=20single=20byte=20in?= =?UTF-8?q?=20=20=20memory.=20The=20functions=20and=20macros=20named=20Utf?= =?UTF-8?q?8...()=20can=20be=20used=20to=20handle=20=20=20strings=20withou?= =?UTF-8?q?t=20needing=20to=20care=20about=20the=20underlying=20character?= =?UTF-8?q?=20encoding=20=20=20(see=20tools.h=20for=20details).=20-=20Even?= =?UTF-8?q?=20though=20the=20weekdays=20of=20repeating=20timers=20are=20pr?= =?UTF-8?q?esented=20to=20the=20user=20as=20UTF-8=20=20=20characters=20in?= =?UTF-8?q?=20the=20OSD,=20the=20timers.conf=20file=20and=20the=20SVDRP=20?= =?UTF-8?q?timer=20commands=20still=20=20=20use=20single=20byte=20characte?= =?UTF-8?q?rs=20("MTWTFSS")=20to=20make=20sure=20this=20information=20is?= =?UTF-8?q?=20handled=20=20=20correctly=20between=20systems=20with=20diffe?= =?UTF-8?q?rent=20character=20encodings.=20-=20Added=20a=20missing=20i18n?= =?UTF-8?q?=20string=20for=20"CAM"=20in=20the=20Turkish=20OSD=20texts.=20-?= =?UTF-8?q?=20Improved=20editing=20strings=20that=20are=20too=20long=20to?= =?UTF-8?q?=20fit=20into=20the=20editable=20area.=20-=20Changes=20to=20the?= =?UTF-8?q?=20OSD=20settings=20in=20the=20"Setup/OSD"=20menu=20now=20immed?= =?UTF-8?q?iately=20take=20effect=20=20=20when=20the=20"Ok"=20key=20is=20p?= =?UTF-8?q?ressed.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- osd.c | 95 ++++++++++++++++++++++++++++++++++++++++++++++++++----------------- 1 file changed, 71 insertions(+), 24 deletions(-) (limited to 'osd.c') diff --git a/osd.c b/osd.c index 64f475d..0031eae 100644 --- a/osd.c +++ b/osd.c @@ -4,11 +4,12 @@ * See the main source file 'vdr.c' for copyright information and * how to reach the author. * - * $Id: osd.c 1.68 2007/02/17 16:05:52 kls Exp $ + * $Id: osd.c 1.69 2007/06/10 12:16:36 kls Exp $ */ #include "osd.h" #include +#include #include #include #include @@ -20,6 +21,18 @@ cPalette::cPalette(int Bpp) { SetBpp(Bpp); + SetAntiAliasGranularity(10, 10); +} + +void cPalette::SetAntiAliasGranularity(uint FixedColors, uint BlendColors) +{ + if (FixedColors >= MAXNUMCOLORS || BlendColors == 0) + antiAliasGranularity = MAXNUMCOLORS - 1; + else { + int ColorsForBlending = MAXNUMCOLORS - FixedColors; + int ColorsPerBlend = ColorsForBlending / BlendColors + 2; // +2 = the full foreground and background colors, which are amoung the fixed colors + antiAliasGranularity = double(MAXNUMCOLORS - 1) / (ColorsPerBlend - 1); + } } void cPalette::Reset(void) @@ -30,18 +43,23 @@ void cPalette::Reset(void) int cPalette::Index(tColor Color) { + // Check if color is already defined: for (int i = 0; i < numColors; i++) { if (color[i] == Color) return i; } + // No exact color, try a close one: + int i = ClosestColor(Color, 4); + if (i >= 0) + return i; + // No close one, try to define a new one: if (numColors < maxColors) { color[numColors++] = Color; modified = true; return numColors - 1; } - dsyslog("too many different colors used in palette"); - //TODO: return the index of the "closest" color? - return 0; + // Out of colors, so any close color must do: + return ClosestColor(Color); } void cPalette::SetBpp(int Bpp) @@ -91,6 +109,48 @@ void cPalette::Replace(const cPalette &Palette) for (int i = 0; i < Palette.numColors; i++) SetColor(i, Palette.color[i]); numColors = Palette.numColors; + antiAliasGranularity = Palette.antiAliasGranularity; +} + +tColor cPalette::Blend(tColor ColorFg, tColor ColorBg, uint8_t Level) +{ + if (antiAliasGranularity > 0) + Level = uint8_t(int(Level / antiAliasGranularity + 0.5) * antiAliasGranularity); + int Af = (ColorFg & 0xFF000000) >> 24; + int Rf = (ColorFg & 0x00FF0000) >> 16; + int Gf = (ColorFg & 0x0000FF00) >> 8; + int Bf = (ColorFg & 0x000000FF); + int Ab = (ColorBg & 0xFF000000) >> 24; + int Rb = (ColorBg & 0x00FF0000) >> 16; + int Gb = (ColorBg & 0x0000FF00) >> 8; + int Bb = (ColorBg & 0x000000FF); + int A = (Ab + (Af - Ab) * Level / 0xFF) & 0xFF; + int R = (Rb + (Rf - Rb) * Level / 0xFF) & 0xFF; + int G = (Gb + (Gf - Gb) * Level / 0xFF) & 0xFF; + int B = (Bb + (Bf - Bb) * Level / 0xFF) & 0xFF; + return (A << 24) | (R << 16) | (G << 8) | B; +} + +int cPalette::ClosestColor(tColor Color, int MaxDiff) +{ + int n = 0; + int d = INT_MAX; + int A1 = (Color & 0xFF000000) >> 24; + int R1 = (Color & 0x00FF0000) >> 16; + int G1 = (Color & 0x0000FF00) >> 8; + int B1 = (Color & 0x000000FF); + for (int i = 0; i < numColors; i++) { + int A2 = (color[i] & 0xFF000000) >> 24; + int R2 = (color[i] & 0x00FF0000) >> 16; + int G2 = (color[i] & 0x0000FF00) >> 8; + int B2 = (color[i] & 0x000000FF); + int diff = (abs(A1 - A2) << 1) + (abs(R1 - R2) << 1) + (abs(G1 - G2) << 1) + (abs(B1 - B2) << 1); + if (diff < d) { + d = diff; + n = i; + } + } + return d <= MaxDiff ? n : -1; } // --- cBitmap --------------------------------------------------------------- @@ -424,26 +484,7 @@ void cBitmap::DrawText(int x, int y, const char *s, tColor ColorFg, tColor Color return; x -= x0; y -= y0; - tIndex fg = Index(ColorFg); - tIndex bg = (ColorBg != clrTransparent) ? Index(ColorBg) : 0; - while (s && *s) { - const cFont::tCharData *CharData = Font->CharData(*s++); - if (limit && int(x + CharData->width) > limit) - break; // we don't draw partial characters - if (int(x + CharData->width) > 0) { - for (int row = 0; row < h; row++) { - cFont::tPixelData PixelData = CharData->lines[row]; - for (int col = CharData->width; col-- > 0; ) { - if (ColorBg != clrTransparent || (PixelData & 1)) - SetIndex(x + col, y + row, (PixelData & 1) ? fg : bg); - PixelData >>= 1; - } - } - } - x += CharData->width; - if (x > width - 1) - break; - } + Font->DrawText(this, x, y, s, ColorFg, ColorBg, limit); } } @@ -623,6 +664,12 @@ cOsd::~cOsd() isOpen--; } +void cOsd::SetAntiAliasGranularity(uint FixedColors, uint BlendColors) +{ + for (int i = 0; i < numBitmaps; i++) + bitmaps[i]->SetAntiAliasGranularity(FixedColors, BlendColors); +} + cBitmap *cOsd::GetBitmap(int Area) { return Area < numBitmaps ? bitmaps[Area] : NULL; -- cgit v1.2.3