X-Git-Url: https://git.cweiske.de/enigma2.git/blobdiff_plain/a34ef895210161a8820e96829ac87806566e7858..fc83dfbe60f36712953498b20a1c2f10737e7685:/lib/gdi/picload.h diff --git a/lib/gdi/picload.h b/lib/gdi/picload.h index 7bb9adf1..f64fd2f9 100644 --- a/lib/gdi/picload.h +++ b/lib/gdi/picload.h @@ -1,11 +1,107 @@ #ifndef __picload_h__ #define __picload_h__ -#include "Python.h" #include -#include +#include +#include +#include +#include -SWIG_VOID(int) loadPic(ePtr &SWIG_OUTPUT, std::string filename, int x, int y, int aspect, int resize_mode=0, int rotate=0, int background=0, std::string cachefile="", int thumbnail=0); -PyObject *getExif(const char *filename); +#ifndef SWIG +class Cfilepara +{ +public: + int max_x; + int max_y; + bool callback; + + const char *file; + int id; + int ox; + int oy; + unsigned char *pic_buffer; + std::string picinfo; + int test; + + Cfilepara(const char *mfile, int mid, std::string size) + { + file = strdup(mfile); + id = mid; + pic_buffer = NULL; + callback = true; + picinfo = mfile; + picinfo += + "\n" + size + "\n"; + } + + ~Cfilepara() + { + if(pic_buffer != NULL) delete pic_buffer; + picinfo.clear(); + } + + void addExifInfo(std::string val) { picinfo += val + "\n"; } +}; +#endif + +class ePicLoad: public eMainloop, public eThread, public Object, public iObject +{ + DECLARE_REF(ePicLoad); + + enum{ F_PNG, F_JPEG, F_BMP, F_GIF}; + + void decodePic(); + void decodeThumb(); + void resizePic(); + + Cfilepara *m_filepara; + bool threadrunning; + + struct PConf + { + int max_x; + int max_y; + double aspect_ratio; + unsigned char background[4]; + bool resizetype; + bool usecache; + int thumbnailsize; + int test; + } m_conf; + + struct Message + { + int type; + enum + { + decode_Pic, + decode_Thumb, + decode_finished, + quit + }; + Message(int type=0) + :type(type) {} + }; + eFixedMessagePump msg_thread, msg_main; + + void gotMessage(const Message &message); + void thread(); + int startThread(int what, const char *file, int x, int y, bool async=true); + void thread_finished(); +public: + void waitFinished(); + PSignal1 PictureData; + + ePicLoad(); + ~ePicLoad(); + + RESULT startDecode(const char *filename, int x=0, int y=0, bool async=true); + RESULT getThumbnail(const char *filename, int x=0, int y=0, bool async=true); + RESULT setPara(PyObject *val); + PyObject *getInfo(const char *filename); + SWIG_VOID(int) getData(ePtr &SWIG_OUTPUT); +}; + +//for old plugins +SWIG_VOID(int) loadPic(ePtr &SWIG_OUTPUT, std::string filename, int x, int y, int aspect, int resize_mode=0, int rotate=0, int background=0, std::string cachefile=""); #endif // __picload_h__