summaryrefslogtreecommitdiff
path: root/libcore/imageloader.h
diff options
context:
space:
mode:
authorManuel Reimer <manuel.reimer@gmx.de>2014-11-02 13:41:21 +0100
committerManuel Reimer <manuel.reimer@gmx.de>2014-11-02 13:41:21 +0100
commite07e56a3faced2f2ef7459cc13c2bda6f65f68ba (patch)
tree96cf997be6080a53aa65ca0d5c551dab9d10c702 /libcore/imageloader.h
parent052bc504085a4be9fed4dfc54ab8af8a011e6984 (diff)
downloadvdr-plugin-skindesigner-e07e56a3faced2f2ef7459cc13c2bda6f65f68ba.tar.gz
vdr-plugin-skindesigner-e07e56a3faced2f2ef7459cc13c2bda6f65f68ba.tar.bz2
Added JPEG support
Diffstat (limited to 'libcore/imageloader.h')
-rw-r--r--libcore/imageloader.h51
1 files changed, 49 insertions, 2 deletions
diff --git a/libcore/imageloader.h b/libcore/imageloader.h
index 6caf19f..e90f459 100644
--- a/libcore/imageloader.h
+++ b/libcore/imageloader.h
@@ -1,10 +1,10 @@
#ifndef __NOPACITY_IMAGELOADER_H
#define __NOPACITY_IMAGELOADER_H
-#define X_DISPLAY_MISSING
-
#include <cairo.h>
#include <librsvg/rsvg.h>
+#include <jpeglib.h>
+#include <setjmp.h>
#include <vdr/osd.h>
#include <vdr/tools.h>
@@ -44,6 +44,53 @@ private:
RsvgHandle *handle;
};
+// Image importer for JPG
+
+#if BITS_IN_JSAMPLE != 8
+ #error libjpeg-turbo has to be compiled with 8-bit samples!
+#endif
+#ifndef JCS_EXTENSIONS
+ #error libjpeg-turbo with JCS_EXTENSIONS required!
+#endif
+
+struct my_error_mgr {
+ struct jpeg_error_mgr pub; // "public" fields
+ jmp_buf setjmp_buffer; // for return to caller
+};
+
+METHODDEF(void)
+my_error_exit(j_common_ptr cinfo) {
+ // cinfo->err really points to a my_error_mgr struct, so coerce pointer
+ my_error_mgr *myerr = (my_error_mgr*) cinfo->err;
+
+ // Always display the message.
+ // We could postpone this until after returning, if we chose.
+ (*cinfo->err->output_message) (cinfo);
+
+ // Return control to the setjmp point
+ longjmp(myerr->setjmp_buffer, 1);
+}
+
+METHODDEF(void)
+my_output_message(j_common_ptr cinfo) {
+ char buf[JMSG_LENGTH_MAX];
+ cinfo->err->format_message(cinfo, buf);
+ dsyslog("skindesigner: libjpeg error: %s", buf);
+}
+
+class cImageImporterJPG : public cImageImporter {
+public:
+ cImageImporterJPG();
+ ~cImageImporterJPG();
+ bool LoadImage(const char *path);
+ void DrawToCairo(cairo_t *cr);
+ void GetImageSize(int &width, int &height);
+private:
+ j_decompress_ptr cinfo;
+ FILE *infile;
+};
+
+
class cImageLoader {
private: