diff options
author | louis <louis.braun@gmx.de> | 2014-09-27 09:25:14 +0200 |
---|---|---|
committer | louis <louis.braun@gmx.de> | 2014-09-27 09:25:14 +0200 |
commit | b0509b5182b6e0d04f05e6b3d5676b0d21f51966 (patch) | |
tree | 22b302342f22843e0815eb5f516c85f1478cbf0b /libcore/imageloader.c | |
download | vdr-plugin-skindesigner-0.0.1.tar.gz vdr-plugin-skindesigner-0.0.1.tar.bz2 |
initial commit version 0.0.10.0.1
Diffstat (limited to 'libcore/imageloader.c')
-rw-r--r-- | libcore/imageloader.c | 56 |
1 files changed, 56 insertions, 0 deletions
diff --git a/libcore/imageloader.c b/libcore/imageloader.c new file mode 100644 index 0000000..1b220a6 --- /dev/null +++ b/libcore/imageloader.c @@ -0,0 +1,56 @@ +#include "../config.h" +#include "helpers.h" +#include "imageloader.h" +#include <math.h> +#include <string> +#include <dirent.h> +#include <iostream> + +using namespace Magick; + +cImageLoader::cImageLoader() : cImageMagickWrapper() { +} + +cImageLoader::~cImageLoader() { +} + +cImage cImageLoader::GetImage() { + return CreateImageCopy(); +} + +bool cImageLoader::LoadImage(const char *path, int width, int height) { + if (cImageMagickWrapper::LoadImage(path)) { + buffer.sample(Geometry(width, height)); + return true; + } + return false; +} + +void cImageLoader::DeterminateChannelLogoSize(int &width, int &height) { + cString logoPath = cString::sprintf("%s%s/logos/", *config.skinPath, Setup.OSDTheme); + cString logoExt = config.logoExtension; + DIR *folder = NULL; + struct dirent *file; + folder = opendir(logoPath); + if (!folder) { + return; + } + while (file = readdir(folder)) { + if (endswith(file->d_name, *logoExt)) { + std::stringstream filePath; + filePath << *logoPath << file->d_name; + Image logo; + try { + logo.read(filePath.str().c_str()); + Geometry g = logo.size(); + int logoWidth = g.width(); + int logoHeight = g.height(); + if (logoWidth > 0 && logoHeight > 0) { + width = logoWidth; + height = logoHeight; + return; + } + } catch( ... ) { } + } + } +} |