prettify MultiContent TitleList
[enigma2.git] / lib / gdi / picload.h
1 #ifndef __picload_h__
2 #define __picload_h__
3
4 #include <lib/gdi/gpixmap.h>
5 #include <lib/base/thread.h>
6 #include <lib/python/python.h>
7 #include <lib/base/message.h>
8 #include <lib/base/ebase.h>
9
10 #ifndef SWIG
11 class Cfilepara
12 {
13 public:
14         int max_x;
15         int max_y;
16         bool callback;
17         
18         const char *file;
19         int id;
20         int ox;
21         int oy;
22         unsigned char *pic_buffer;
23         std::string picinfo;
24         int test;
25         
26         Cfilepara(const char *mfile, int mid, std::string size)
27         {
28                 file = strdup(mfile);
29                 id = mid;
30                 pic_buffer = NULL;
31                 callback = true;
32                 picinfo = mfile;
33                 picinfo += + "\n" + size + "\n";
34         }
35         
36         ~Cfilepara()
37         {
38                 if(pic_buffer != NULL)  delete pic_buffer;
39                 picinfo.clear();
40         }
41         
42         void addExifInfo(std::string val) { picinfo += val + "\n"; }
43 };
44 #endif
45
46 class ePicLoad: public eMainloop, public eThread, public Object, public iObject
47 {
48         DECLARE_REF(ePicLoad);
49
50         enum{ F_PNG, F_JPEG, F_BMP, F_GIF};
51         
52         void decodePic();
53         void decodeThumb();
54         void resizePic();
55
56         Cfilepara *m_filepara;
57         bool threadrunning;
58         
59         struct PConf
60         {
61                 int max_x;
62                 int max_y;
63                 double aspect_ratio;
64                 unsigned char background[4];
65                 bool resizetype;
66                 bool usecache;
67                 int thumbnailsize;
68                 int test;
69         } m_conf;
70         
71         struct Message
72         {
73                 int type;
74                 enum
75                 {
76                         decode_Pic,
77                         decode_Thumb,
78                         decode_finished,
79                         quit
80                 };
81                 Message(int type=0)
82                         :type(type) {}
83         };
84         eFixedMessagePump<Message> msg_thread, msg_main;
85
86         void gotMessage(const Message &message);
87         void thread();
88         int startThread(int what, const char *file, int x, int y, bool async=true);
89         void thread_finished();
90 public:
91         void waitFinished();
92         PSignal1<void, const char*> PictureData;
93
94         ePicLoad();
95         ~ePicLoad();
96         
97         RESULT startDecode(const char *filename, int x=0, int y=0, bool async=true);
98         RESULT getThumbnail(const char *filename, int x=0, int y=0, bool async=true);
99         RESULT setPara(PyObject *val);
100         PyObject *getInfo(const char *filename);
101         SWIG_VOID(int) getData(ePtr<gPixmap> &SWIG_OUTPUT);
102 };
103
104 //for old plugins
105 SWIG_VOID(int) loadPic(ePtr<gPixmap> &SWIG_OUTPUT, std::string filename, int x, int y, int aspect, int resize_mode=0, int rotate=0, int background=0, std::string cachefile="");
106
107 #endif // __picload_h__