diff options
author | Andreas Mair <amair.sob@googlemail.com> | 2007-04-02 11:38:08 +0200 |
---|---|---|
committer | Andreas Mair <amair.sob@googlemail.com> | 2007-04-02 11:38:08 +0200 |
commit | c562d549bc6274265991eec634f99b1e311323df (patch) | |
tree | 2f4f23396e60f381cb2899ef7be87c1b54dc153c /logo.c | |
parent | de39678a54ab87364a3c8c5e3b058d313451db5b (diff) | |
download | vdr-plugin-skinenigmang-0.0.4.tar.gz vdr-plugin-skinenigmang-0.0.4.tar.bz2 |
2007-04-02: Version 0.0.4v0.0.4
- Changed text color in themes for green and yellow buttons.
- Fixed false colors problem after theme changes.
- Updated Finnish translation. (Submitted by Rolf Ahrenberg)
- Updated French translation. (Submitted by pat @vdr-portal.de)
- Do not overwrite status messages in mainmenu with list items.
- New setup option that replaces SKINENIGMA_FULL_CHANNELINFO_TITLE define.
- Disable logos/symbols/flags if 4bpp single area is configured in setup. (Will eventually replace SKINENIGMA_NO_MENULOGO define)
- Added support for mailbox plugin; shows mail symbol in channel info (Based on patch by triple955 @vdr-portal.de).
- Introduced new HAVE_IMAGEMAGICK define to enable non-xpm images in event's and recording's details.
- Fixed "blinking" date in channel info (Reported by several people).
- Changed background for recording symbol in channel info to white (Suggested by gromit @vdr-portal.de).
- Long channel group names are no longer drawn at the right side of the date (Reported by several people).
- New setup option for displaying a recording's size and use size.vdr (Suggested by vejoun @vdr-portal.de).
- Show stop time of running timers in info area in main menu. (Suggested by viking @vdr-portal.de)
- Updated Russian translation. (Submitted by neptunvasja @vdr-portal.de)
- New defines "ListProgressBarGap" & "ListProgressBarBorder" to customize the progressbar in lists:
* "ListProgressBarGap" sets the gap above/below the progressbar (relative to the font's height).
* "ListProgressBarBorder" sets the border's width.
- Added fallback to "classic" skin if any of the OSD menus fails to open.
- Fix possible NULL pointer accesses.
- Fixed compiler error with certain gcc versions.
- Minor bugfixes and graphical changes.
Diffstat (limited to 'logo.c')
-rw-r--r-- | logo.c | 154 |
1 files changed, 129 insertions, 25 deletions
@@ -5,22 +5,30 @@ * */ +#include <strings.h> + +#include "bitmap.h" #include "common.h" #include "config.h" #include "logo.h" #include <vdr/tools.h> #include <vdr/plugin.h> -#undef debug -#define debug(x...) ; - cEnigmaLogoCache EnigmaLogoCache(0); cEnigmaLogoCache::cEnigmaLogoCache(unsigned int cacheSizeP) :cacheSizeM(cacheSizeP), bitmapM(NULL) -{ } +{ +#ifdef HAVE_IMAGEMAGICK + bmpImage = new cBitmap(8, 8, 1); +#endif +} cEnigmaLogoCache::~cEnigmaLogoCache() { +#ifdef HAVE_IMAGEMAGICK + delete bmpImage; +#endif + // let's flush the cache Flush(); } @@ -37,11 +45,97 @@ bool cEnigmaLogoCache::Resize(unsigned int cacheSizeP) return true; } -bool cEnigmaLogoCache::Load(const char *fileNameP) +bool cEnigmaLogoCache::LoadEventImage(const cEvent *Event, int w, int h, int c) +{ + if (Event == NULL) + return false; + + char *strFilename = NULL; + asprintf(&strFilename, "%s/%d.%s", EnigmaConfig.GetImagesDir(), Event->EventID(), EnigmaConfig.GetImageExtension()); + int rc = LoadImage(strFilename, w, h, c); + free (strFilename); + return rc; +} + +bool cEnigmaLogoCache::LoadRecordingImage(const cRecording *Recording, int w, int h, int c) +{ + if (Recording == NULL) + return false; + + char *strFilename = NULL; + asprintf(&strFilename, "%s/%s.%s", Recording->FileName(), RECORDING_COVER, EnigmaConfig.GetImageExtension()); + int rc = LoadImage(strFilename, w, h, c); + free (strFilename); + return rc; +} + +bool cEnigmaLogoCache::LoadImage(const char *fileNameP, int w, int h, int c) { - debug("cPluginSkinEnigma::Load(%s)\n", fileNameP); + struct stat stbuf; + if (lstat(fileNameP, &stbuf) != 0) { + error("cPluginSkinEnigma::LoadImage(%s) FILE NOT FOUND\n", fileNameP); + bitmapM = NULL; + return false; + } + +#ifdef HAVE_IMAGEMAGICK + int rc = image.LoadImage(fileNameP, w, h, c, *bmpImage); + bitmapM = rc ? bmpImage : NULL; + return rc; +#else + return LoadXpm(fileNameP, w, h); +#endif +} + +bool cEnigmaLogoCache::LoadChannelLogo(const cChannel *Channel) +{ + if (Channel == NULL) + return false; + + bool fFoundLogo = false; + char *strChannelID = EnigmaConfig.useChannelId ? strdup(*Channel->GetChannelID().ToString()) : NULL; + const char *logoname = EnigmaConfig.useChannelId ? strChannelID : Channel->Name(); + if (logoname) { + char *filename = (char *)malloc(strlen(logoname) + 20 /* should be enough for folder */); + if (filename == NULL) return false; + strcpy(filename, "hqlogos/"); + strcat(filename, logoname); + if (!(fFoundLogo = Load(filename, ChannelLogoWidth, ChannelLogoHeight))) { + strcpy(filename, "logos/"); + strcat(filename, logoname); + if (!(fFoundLogo = EnigmaLogoCache.Load(filename, ChannelLogoWidth, ChannelLogoHeight))) { + fFoundLogo = Load("hqlogos/no_logo", ChannelLogoWidth, ChannelLogoHeight); //TODO? different default logo for channel/group? + } + } + free(filename); + free(strChannelID); + } + return fFoundLogo; +} + +bool cEnigmaLogoCache::LoadSymbol(const char *fileNameP) +{ + return Load(fileNameP, SymbolWidth, SymbolHeight); +} + +bool cEnigmaLogoCache::LoadIcon(const char *fileNameP) +{ + return Load(fileNameP, IconWidth, IconHeight); +} + +bool cEnigmaLogoCache::Load(const char *fileNameP, int w, int h) +{ + if (fileNameP == NULL) + return false; + + char *strFilename; + asprintf(&strFilename, "%s/%s.xpm", EnigmaConfig.GetLogoDir(), fileNameP); + if (strFilename == NULL) + return false; + + debug("cPluginSkinEnigma::Load(%s)\n", strFilename); // does the logo exist already in map - std::map < std::string, cBitmap * >::iterator i = cacheMapM.find(fileNameP); + std::map < std::string, cBitmap * >::iterator i = cacheMapM.find(strFilename); if (i != cacheMapM.end()) { // yes - cache hit! debug("cPluginSkinEnigma::Load() CACHE HIT!\n"); @@ -49,6 +143,7 @@ bool cEnigmaLogoCache::Load(const char *fileNameP) if (i->second == NULL) { debug("cPluginSkinEnigma::Load() EMPTY\n"); // empty logo in cache + free(strFilename); return false; } bitmapM = i->second; @@ -56,7 +151,8 @@ bool cEnigmaLogoCache::Load(const char *fileNameP) // no - cache miss! debug("cPluginSkinEnigma::Load() CACHE MISS!\n"); // try to load xpm logo - LoadXpm(fileNameP); + if (!LoadXpm(strFilename, w, h)) + return false; // check if cache is active if (cacheSizeM) { // update map @@ -72,16 +168,18 @@ bool cEnigmaLogoCache::Load(const char *fileNameP) cacheMapM.erase(cacheMapM.begin()); } // insert logo into map - debug("cPluginSkinEnigma::Load() INSERT(%s)\n", fileNameP); - cacheMapM.insert(std::make_pair(fileNameP, bitmapM)); + debug("cPluginSkinEnigma::Load() INSERT(%s)\n", strFilename); + cacheMapM.insert(std::make_pair(strFilename, bitmapM)); } // check if logo really exist if (bitmapM == NULL) { debug("cPluginSkinEnigma::Load() EMPTY\n"); // empty logo in cache + free(strFilename); return false; } } + free(strFilename); return true; } @@ -90,30 +188,34 @@ cBitmap & cEnigmaLogoCache::Get(void) return *bitmapM; } -bool cEnigmaLogoCache::LoadXpm(const char *fileNameP) +bool cEnigmaLogoCache::LoadXpm(const char *fileNameP, int w, int h) { + if (fileNameP == NULL) + return false; + struct stat stbuf; - char *filename; cBitmap *bmp = new cBitmap(1, 1, 1); // create absolute filename - asprintf(&filename, "%s/%s.xpm", EnigmaConfig.GetLogoDir(), fileNameP); - debug("cPluginSkinEnigma::LoadXpm(%s)\n", filename); + debug("cPluginSkinEnigma::LoadXpm(%s)\n", fileNameP); // check validity - if ((stat(filename, &stbuf) == 0) && bmp->LoadXpm(filename) - /*TODO? && (bmp->Width() == ChannelLogoWidth) - && (bmp->Height() == ChannelLogoHeight)*/) { - debug("cPluginSkinEnigma::LoadXpm() LOGO FOUND\n"); - // assign bitmap - bitmapM = bmp; - free(filename); - return true; + if ((lstat(fileNameP, &stbuf) == 0) && bmp->LoadXpm(fileNameP)) { + if ((bmp->Width() <= w) && (bmp->Height() <= h)) { + debug("cPluginSkinEnigma::LoadXpm(%s) LOGO FOUND\n", fileNameP); + // assign bitmap + bitmapM = bmp; + return true; + } else { + // wrong size + error("cPluginSkinEnigma::LoadXpm(%s) LOGO HAS WRONG SIZE %d/%d (%d/%d)\n", fileNameP, bmp->Width(), bmp->Height(), w, h); + } + } else { + // no xpm logo found + error("cPluginSkinEnigma::LoadXpm(%s) LOGO NOT FOUND\n", fileNameP); } - // no xpm logo found - delete bitmap - error("cPluginSkinEnigma::LoadXpm(%s) LOGO NOT FOUND\n", filename); + delete bmp; bitmapM = NULL; - free(filename); return false; } @@ -136,3 +238,5 @@ bool cEnigmaLogoCache::Flush(void) } return true; } + +// vim:et:sw=2:ts=2: |