summaryrefslogtreecommitdiff
path: root/osd.c
diff options
context:
space:
mode:
authorKlaus Schmidinger <kls (at) cadsoft (dot) de>2007-06-10 18:00:00 +0200
committerKlaus Schmidinger <kls (at) cadsoft (dot) de>2007-06-10 18:00:00 +0200
commitb9b9ace9a8d2d1c0beda1dc0a2ebc6be9b47c305 (patch)
treebe6d179a3d48dc4323b55a9efc0acb03e767847b /osd.c
parenta5921252942f73601b159f20b560477ec45b4ece (diff)
downloadvdr-patch-lnbsharing-b9b9ace9a8d2d1c0beda1dc0a2ebc6be9b47c305.tar.gz
vdr-patch-lnbsharing-b9b9ace9a8d2d1c0beda1dc0a2ebc6be9b47c305.tar.bz2
Version 1.5.3vdr-1.5.3
- Fixed some spelling errors in 'newplugin' (thanks to Ville Skyttä). - Fixed a busy loop in fast forward if the next video data file is missing (thanks to Reinhard Nissl). - Fixed handling frequencies in NitFilter::Process() (thanks to Anssi Hannula). - Fixed a race condition with signal handlers at program exit (thanks to Udo Richter). - Non-primary devices in Transfer mode are now also used for recording (thanks to Anssi Hannula). - Fixed handling ChannelUp/Down keys if there is currently a replay running (thanks to Marco Schlüßler). - The new SVDRP command REMO can be used to turn VDR's remote control off and on in case other programs need to be controlled (based on patches from Krzysztof Parma and Helmut Auer). - Increased the maximum number of CA system ids to cope with the AlphaCrypt CAM's version 3.11 firmware. - Fixed getting the code setting from the locale (thanks to Matthias Schwarzott). - Implemented support for Freetype fonts (based on a patch from Alexander Riedel). The font names and sizes can be adjusted in the "Setup/OSD" menu. Note that VDR now requires freetype fonts to be installed in /usr/share/fonts/truetype. - If the OSD device in use has at least 8bpp bitmap depth and this is also used by the current skin, Freetype fonts are displayed "anti-aliased". The new setup parameter "OSD/Anti-alias" can be used to turn this off. - The new function cOsd::SetAntiAliasGranularity() can be used to help the OSD in managing the available color palette entries when doing anti-aliasing. Skins that use 8bpp bitmaps can call this function with the maximum number of colors used, and the maximum number of color combinations. The OSD will then evenly split the available palette entries between the various colors combinations, so that fonts can be "anti-aliased". By default a total of 10 colors and 10 combinations is assumed. - The pixel fonts have been completely removed from the VDR source. - VDR is now "UTF-8 aware". It handles strings according to the character encoding used on the user's system. All internationalization strings and incoming SI data are converted to the system encoding. - Plugins that handle strings need to be aware that on systems with UTF-8 encoding a "character symbol" may consist of more than a single byte in memory. The functions and macros named Utf8...() can be used to handle strings without needing to care about the underlying character encoding (see tools.h for details). - Even though the weekdays of repeating timers are presented to the user as UTF-8 characters in the OSD, the timers.conf file and the SVDRP timer commands still use single byte characters ("MTWTFSS") to make sure this information is handled correctly between systems with different character encodings. - Added a missing i18n string for "CAM" in the Turkish OSD texts. - Improved editing strings that are too long to fit into the editable area. - Changes to the OSD settings in the "Setup/OSD" menu now immediately take effect when the "Ok" key is pressed.
Diffstat (limited to 'osd.c')
-rw-r--r--osd.c95
1 files changed, 71 insertions, 24 deletions
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 <math.h>
+#include <stdarg.h>
#include <stdlib.h>
#include <sys/ioctl.h>
#include <sys/stat.h>
@@ -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;