summaryrefslogtreecommitdiff
path: root/osd.c
diff options
context:
space:
mode:
authorKlaus Schmidinger <vdr@tvdr.de>2004-06-05 13:20:19 +0200
committerKlaus Schmidinger <vdr@tvdr.de>2004-06-05 13:20:19 +0200
commit32e9db211d15676861ed005a07fc96ede6cef275 (patch)
treee872faeac588c888417ad4dd198c376fd559e90e /osd.c
parent00645daa93f8b26de7b6a71ea425ef406bdf55d6 (diff)
downloadvdr-32e9db211d15676861ed005a07fc96ede6cef275.tar.gz
vdr-32e9db211d15676861ed005a07fc96ede6cef275.tar.bz2
Ignoring unused "none" color entries in XPM files written by some broken graphics tools
Diffstat (limited to 'osd.c')
-rw-r--r--osd.c21
1 files changed, 15 insertions, 6 deletions
diff --git a/osd.c b/osd.c
index b61bfbd9..7159a83c 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 1.50 2004/06/05 11:37:42 kls Exp $
+ * $Id: osd.c 1.51 2004/06/05 13:20:19 kls Exp $
*/
#include "osd.h"
@@ -244,7 +244,7 @@ bool cBitmap::LoadXpm(const char *FileName)
return Result;
}
-bool cBitmap::SetXpm(char *Xpm[])
+bool cBitmap::SetXpm(char *Xpm[], bool IgnoreNone)
{
char **p = Xpm;
int w, h, n, c;
@@ -257,10 +257,11 @@ bool cBitmap::SetXpm(char *Xpm[])
return false;
}
int b = 0;
- while (1 << (1 << b) < n)
+ while (1 << (1 << b) < (IgnoreNone ? n - 1 : n))
b++;
SetBpp(1 << b);
SetSize(w, h);
+ int NoneColorIndex = MAXNUMCOLORS;
for (int i = 0; i < n; i++) {
const char *s = *++p;
if (int(strlen(s)) < c) {
@@ -273,14 +274,18 @@ bool cBitmap::SetXpm(char *Xpm[])
return false;
}
s = skipspace(s + 1);
- if (strcasecmp(s, "none") == 0)
+ if (strcasecmp(s, "none") == 0) {
s = "#00000000";
+ NoneColorIndex = i;
+ if (IgnoreNone)
+ continue;
+ }
if (*s != '#') {
esyslog("ERROR: unknown color code in XPM: '%c'", *s);
return false;
}
tColor color = strtoul(++s, NULL, 16) | 0xFF000000;
- SetColor(i, color);
+ SetColor((IgnoreNone && i > NoneColorIndex) ? i - 1 : i, color);
}
for (int y = 0; y < h; y++) {
const char *s = *++p;
@@ -295,13 +300,17 @@ bool cBitmap::SetXpm(char *Xpm[])
return false;
}
if (strncmp(Xpm[i + 1], s, c) == 0) {
- SetIndex(x, y, i);
+ if (i == NoneColorIndex)
+ NoneColorIndex = MAXNUMCOLORS;
+ SetIndex(x, y, (IgnoreNone && i > NoneColorIndex) ? i - 1 : i);
break;
}
}
s += c;
}
}
+ if (NoneColorIndex < MAXNUMCOLORS && !IgnoreNone)
+ return SetXpm(Xpm, true);
return true;
}