Added support for SVG channellogos

This commit is contained in:
Manuel Reimer 2014-11-11 20:50:00 +01:00
parent 7762e99dd0
commit 234c855990
4 changed files with 19 additions and 28 deletions

View File

@ -7,7 +7,6 @@ cDesignerConfig::cDesignerConfig() {
skinPathSet = false;
logoPathSet = false;
//Common
logoExtension = "png";
numLogosPerSizeInitial = 30;
limitLogoCache = 1;
numLogosMax = 200;

View File

@ -43,7 +43,6 @@ public:
void SetOSDFonts(void);
bool OsdFontsChanged(void);
cString GetSkinRessourcePath(void);
cString logoExtension;
cString skinPath;
cString logoPath;
cString epgImagePath;

View File

@ -140,27 +140,18 @@ bool cImageCache::LogoExists(string channelID) {
if (!channel)
return false;
string logoLower = StrToLowerCase(channel->Name());
string logoExt = *config.logoExtension;
bool logoExists = FileExists(logoPath.c_str(), logoLower, logoExt);
if (logoExists) {
return true;
}
logoExists = FileExists(logoPath.c_str(), channelID, logoExt);
if (logoExists) {
return true;
}
return false;
return (FileExists(logoPath.c_str(), logoLower, "svg") ||
FileExists(logoPath.c_str(), logoLower, "png") ||
FileExists(logoPath.c_str(), channelID, "svg") ||
FileExists(logoPath.c_str(), channelID, "png"));
}
bool cImageCache::SeparatorLogoExists(string name) {
string separatorPath = *cString::sprintf("%sseparatorlogos/", logoPath.c_str());
string nameLower = StrToLowerCase(name.c_str());
string logoExt = *config.logoExtension;
bool logoExists = FileExists(separatorPath, nameLower, logoExt);
if (logoExists) {
return true;
}
return false;
return FileExists(separatorPath, nameLower, "png");
}
void cImageCache::CacheIcon(eImageType type, string name, int width, int height) {
@ -329,21 +320,23 @@ bool cImageCache::LoadLogo(const cChannel *channel) {
return false;
string channelID = StrToLowerCase(*(channel->GetChannelID().ToString()));
string logoLower = StrToLowerCase(channel->Name());
bool success = false;
if (FileExists(logoPath.c_str(), channelID.c_str(), *config.logoExtension))
return LoadImage(logoPath.c_str(), channelID.c_str(), *config.logoExtension);
if (FileExists(logoPath.c_str(), logoLower.c_str(), *config.logoExtension))
return LoadImage(logoPath.c_str(), logoLower.c_str(), *config.logoExtension);
if (FileExists(logoPath.c_str(), channelID.c_str(), "svg"))
return LoadImage(logoPath.c_str(), channelID.c_str(), "svg");
if (FileExists(logoPath.c_str(), channelID.c_str(), "png"))
return LoadImage(logoPath.c_str(), channelID.c_str(), "png");
if (FileExists(logoPath.c_str(), logoLower.c_str(), "svg"))
return LoadImage(logoPath.c_str(), logoLower.c_str(), "svg");
if (FileExists(logoPath.c_str(), logoLower.c_str(), "png"))
return LoadImage(logoPath.c_str(), logoLower.c_str(), "png");
return false;
}
bool cImageCache::LoadSeparatorLogo(string name) {
cString separatorPath = cString::sprintf("%sseparatorlogos/", logoPath.c_str());
string separatorPath = *cString::sprintf("%sseparatorlogos/", logoPath.c_str());
string nameLower = StrToLowerCase(name.c_str());
return LoadImage(*separatorPath, nameLower.c_str(), *config.logoExtension);
return LoadImage(separatorPath, nameLower.c_str(), "png");
}
bool cImageCache::LoadSkinpart(string name) {

View File

@ -101,7 +101,6 @@ void cImageLoader::DeterminateChannelLogoSize(int &width, int &height) {
else
logoPath = config.logoPath;
cString logoExt = config.logoExtension;
DIR *folder = NULL;
struct dirent *file;
folder = opendir(logoPath);
@ -109,7 +108,8 @@ void cImageLoader::DeterminateChannelLogoSize(int &width, int &height) {
return;
while ( (file = readdir(folder)) ) {
if (endswith(file->d_name, *logoExt)) {
if (endswith(file->d_name, ".png") ||
endswith(file->d_name, ".svg")) {
std::stringstream filePath;
filePath << *logoPath << file->d_name;
if (LoadImage(filePath.str().c_str())) {