Exemplo n.º 1
0
bool cSoppalusikkaLogoCache::Load(const char *fileNameP)
{
  char *fileName = strdup(fileNameP);
  if (!fileName)
     return false;
  // replace '/' characters with '~'
  strreplace(fileName, '/', '~');
  debug1("%s (%s)", __PRETTY_FUNCTION__, fileName);
  // does the logo exist already in map
  std::map<std::string, cBitmap*>::iterator i = cacheMapM.find(fileName);
  if (i != cacheMapM.end()) {
     // yes - cache hit!
     debug2("%s Cache hit", __PRETTY_FUNCTION__);
     // check if logo really exist
     if (i->second == NULL) {
        debug2("%s Empty", __PRETTY_FUNCTION__);
        // empty logo in cache
        free(fileName);
        return false;
        }
     bitmapM = i->second;
     }
  else {
     // no - cache miss!
     debug2("%s Cache miss", __PRETTY_FUNCTION__);
     // try to load xpm logo
     LoadXpm(fileName);
     // check if cache is active
     if (cacheSizeM) {
        // update map
        if (cacheMapM.size() >= cacheSizeM) {
           // cache full - remove first
           debug2("%s Delete", __PRETTY_FUNCTION__);
           if (cacheMapM.begin()->second != NULL) {
              // logo exists - delete it
              cBitmap *bmp = cacheMapM.begin()->second;
              DELETENULL(bmp);
              }
           // erase item
           cacheMapM.erase(cacheMapM.begin());
           }
        // insert logo into map
        debug2("%s Insert %s", fileName, __PRETTY_FUNCTION__);
        cacheMapM.insert(std::make_pair(fileName, bitmapM));
        }
     // check if logo really exist
     if (bitmapM == NULL) {
        debug2("%s Empty", __PRETTY_FUNCTION__);
        // empty logo in cache
        free(fileName);
        return false;
        }
     }
  free(fileName);
  return true;
}
Exemplo n.º 2
0
bool cReelLogoCache::Load(const char *fileNameP, int w, int h, bool fLogNotFound)
{
  if (fileNameP == NULL)
    return false;

  std::string strFilename;
  strFilename = ReelConfig.GetLogoPath(fileNameP, ".xpm");

  debug("cPluginSkinReel::Load(%s)", strFilename.c_str());
  // does the logo exist already in map
  std::map < std::string, cBitmap * >::iterator i = cacheMapM.find(strFilename.c_str());
  if (i != cacheMapM.end()) { /** yes - cache hit! */
    debug("cPluginSkinReel::Load() CACHE HIT!");
    if (i->second == NULL) { /** check if logo really exist */
      debug("cPluginSkinReel::Load() EMPTY");
      // empty logo in cache
      return false;
    }
    bitmapM = i->second;
  } else { /** no - cache miss! */
    debug("cPluginSkinReel::Load() CACHE MISS!");
    // try to load xpm logo
    if (!LoadXpm(strFilename.c_str(), w, h, fLogNotFound))
      return false;
    if (cacheSizeM) { /** check if cache is active */
      // update map
      if (cacheMapM.size() >= cacheSizeM) {
        // cache full - remove first
        debug("cPluginSkinReel::Load() DELETE");
        if (cacheMapM.begin()->second != NULL) {
          // logo exists - delete it
          cBitmap *bmp = cacheMapM.begin()->second;
          DELETENULL(bmp);
        }
        cacheMapM.erase(cacheMapM.begin()); /** erase item */
      }
      // insert logo into map
      debug("cPluginSkinReel::Load() INSERT(%s)", strFilename.c_str());
      cacheMapM.insert(std::make_pair(strFilename.c_str(), bitmapM));
    }
    // check if logo really exist
    if (bitmapM == NULL) {
      debug("cPluginSkinReel::Load() EMPTY");
      // empty logo in cache
      return false;
    }
  }
  return true;
}
Exemplo n.º 3
0
bool cReelLogoCache::DrawImage(const char *fileNameP, int x, int y, int w, int h, int c, cBitmap *bmp)
{
  if (fileNameP== NULL || bmp == NULL)
    return false;

  struct stat stbuf;
  if (lstat(fileNameP, &stbuf) != 0) {
    error("cPluginSkinReel::LoadImage(%s) FILE NOT FOUND", fileNameP);
    bitmapM = NULL;
    return false;
  }

#ifdef HAVE_IMAGEMAGICK
  bitmapM = NULL;
  return image.DrawImage(fileNameP, x, y, w, h, c, bmp);
#else
  int rc = LoadXpm(fileNameP, w, h);
  if (rc)
    bmp->DrawBitmap(x, y, *bitmapM); //TODO?
  return rc;
#endif
}