summaryrefslogtreecommitdiff
path: root/imageloader.c
diff options
context:
space:
mode:
authorlouis <louis.braun@gmx.de>2012-12-18 19:35:07 +0100
committerlouis <louis.braun@gmx.de>2012-12-18 19:35:07 +0100
commit7010739a062c660bbd88b612e1635068325acf3f (patch)
tree8ce9bb1ebabf80a307433d6896e90b6eedb6a108 /imageloader.c
parentec274fcb4852434290a1a9fdc13c8fb747762099 (diff)
downloadskin-nopacity-7010739a062c660bbd88b612e1635068325acf3f.tar.gz
skin-nopacity-7010739a062c660bbd88b612e1635068325acf3f.tar.bz2
Displaying epg image for recordings using first found jpg in recordings folder
Diffstat (limited to 'imageloader.c')
-rw-r--r--imageloader.c36
1 files changed, 36 insertions, 0 deletions
diff --git a/imageloader.c b/imageloader.c
index 3a9a0be..8b937fa 100644
--- a/imageloader.c
+++ b/imageloader.c
@@ -1,6 +1,8 @@
#include "imageloader.h"
#include <math.h>
#include <string>
+#include <dirent.h>
+#include <iostream>
using namespace Magick;
@@ -87,6 +89,22 @@ bool cImageLoader::LoadEPGImage(int eventID) {
return true;
}
+bool cImageLoader::LoadRecordingImage(cString Path) {
+ int width = config.epgImageWidth;
+ int height = config.epgImageHeight;
+ if ((width == 0)||(height==0))
+ return false;
+ cString recImage("");
+ if (FirstImageInFolder(Path, "jpg", &recImage)) {
+ recImage = cString::sprintf("/%s", *recImage);
+ if (!LoadImage(*recImage, Path, "jpg"))
+ return false;
+ buffer.sample( Geometry(width, height));
+ return true;
+ }
+ return false;
+}
+
void cImageLoader::DrawBackground(tColor back, tColor blend, int width, int height) {
Color Back = Argb2Color(back);
Color Blend = Argb2Color(blend);
@@ -155,3 +173,21 @@ bool cImageLoader::LoadImage(cString FileName, cString Path, cString Extension)
}
return true;
}
+
+bool cImageLoader::FirstImageInFolder(cString Path, cString Extension, cString *recImage) {
+ DIR *folder;
+ struct dirent *file;
+ folder = opendir(Path);
+ while (file = readdir(folder)) {
+ if (endswith(file->d_name, *Extension)) {
+ std::string fileName = file->d_name;
+ if (fileName.length() > 4)
+ fileName = fileName.substr(0, fileName.length() - 4);
+ else
+ return false;
+ *recImage = fileName.c_str();
+ return true;
+ }
+ }
+ return false;
+} \ No newline at end of file