summaryrefslogtreecommitdiff
path: root/bitmap.c
diff options
context:
space:
mode:
authorlordjaxom <lordjaxom>2004-06-05 18:06:22 +0000
committerlordjaxom <lordjaxom>2004-06-05 18:06:22 +0000
commit6094765d94e4caaf0813039dff826b731f277753 (patch)
treefed79334167f26d5a81a6cae9be3f1341375a36f /bitmap.c
parente0c2ee1d37c0f213f22a04df71710bebe3526f85 (diff)
downloadvdr-plugin-text2skin-6094765d94e4caaf0813039dff826b731f277753.tar.gz
vdr-plugin-text2skin-6094765d94e4caaf0813039dff826b731f277753.tar.bz2
- added scrollable texts and "SymbolScrollUp" and "SymbolScrollDown"v0.0.1
- added "MenuText", "MenuEventTitle", "MenuEventShortText", "MenuEventDescription", "MenuEventTime", "MenuRecording", "SymbolEventRunning", "SymbolEventTimer" and "SymbolEventVPS" - implemented image caching - added english and german README - removed some workarounds, and added a patch to vdr to the tree (will be included in 1.3.10) - fixed two bugs when displaying replay symbols - implemented tabbed texts in menu
Diffstat (limited to 'bitmap.c')
-rw-r--r--bitmap.c53
1 files changed, 29 insertions, 24 deletions
diff --git a/bitmap.c b/bitmap.c
index 185f435..1d9d6f5 100644
--- a/bitmap.c
+++ b/bitmap.c
@@ -1,5 +1,5 @@
/*
- * $Id: bitmap.c,v 1.9 2004/06/02 20:43:05 lordjaxom Exp $
+ * $Id: bitmap.c,v 1.11 2004/06/05 16:52:44 lordjaxom Exp $
*/
#include "bitmap.h"
@@ -12,40 +12,46 @@
#include <Magick++.h>
#endif
-cText2SkinBitmap::cText2SkinBitmap(void): cBitmap(1, 1, 1) {
-#ifdef HAVE_IMLIB2
- imlib_set_cache_size(4096 * 1024);
-#endif
+template<>
+void cImageCache::Delete(string &key, cText2SkinBitmap *&value) {
+ delete value;
}
-cText2SkinBitmap::cText2SkinBitmap(const char *Filename): cBitmap(1, 1, 1) {
-#ifdef HAVE_IMLIB2
- imlib_set_cache_size(4096 * 1024);
-#endif
- Load(Filename);
+cImageCache cText2SkinBitmap::mCache(10);
+
+cText2SkinBitmap::cText2SkinBitmap(void): cBitmap(1, 1, 1) {
}
cText2SkinBitmap::~cText2SkinBitmap() {
}
-bool cText2SkinBitmap::Load(const char *Filename) {
- int len = strlen(Filename);
- if (len > 4) {
- if (strcmp(Filename + len - 4, ".xpm") == 0)
- return LoadXpm(Filename);
+cText2SkinBitmap *cText2SkinBitmap::Load(const char *Filename) {
+ if (mCache.Contains(Filename)) {
+ return mCache[Filename];
+ } else {
+ cText2SkinBitmap *bmp = new cText2SkinBitmap;
+ int len = strlen(Filename);
+ bool result = false;
+ if (len > 4) {
+ if (strcmp(Filename + len - 4, ".xpm") == 0)
+ result = bmp->LoadXpm(Filename);
+ else {
#ifdef HAVE_IMLIB2
- else if (strcmp(Filename + len - 4, ".png") == 0)
- return LoadImlib(Filename);
+ result = bmp->LoadImlib(Filename);
#else
# ifdef HAVE_IMAGEMAGICK
- else if (strcmp(Filename + len - 4, ".png") == 0)
- return LoadMagick(Filename);
+ result = bmp->LoadMagick(Filename);
# endif
#endif
- else
- esyslog("ERROR: text2skin: unknown file format for %s", Filename);
- } else
- esyslog("ERROR: text2skin: filename %s too short to identify format", Filename);
+ }
+ //else
+ //esyslog("ERROR: text2skin: unknown file format for %s", Filename);
+ } else
+ esyslog("ERROR: text2skin: filename %s too short to identify format", Filename);
+
+ if (result)
+ return (mCache[Filename] = bmp);
+ }
return false;
}
@@ -66,7 +72,6 @@ bool cText2SkinBitmap::LoadImlib(const char *Filename) {
for (int x = 0; x < Width(); ++x) {
tColor col = (data[pos + 3] << 24) | (data[pos + 2] << 16) | (data[pos + 1] << 8) | data[pos + 0];
int res = Index(col);
- //printf("color: r=%d,g=%d,b=%d,a=%d\n", data[pos], data[pos+1], data[pos+2], data[pos+3]);
if (pal > 0 && res == 0)
;//esyslog("ERROR: text2skin: Too many colors used in palette");
else