[browser] fixed menu skin to set the size automatically.
[vuplus_dvbapp] / 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 bypp;
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                 bypp = 3;
33                 picinfo = mfile;
34                 picinfo += + "\n" + size + "\n";
35         }
36         
37         ~Cfilepara()
38         {
39                 if(pic_buffer != NULL)  delete pic_buffer;
40                 picinfo.clear();
41         }
42         
43         void addExifInfo(std::string val) { picinfo += val + "\n"; }
44 };
45 #endif
46
47 class ePicLoad: public eMainloop, public eThread, public Object, public iObject
48 {
49         DECLARE_REF(ePicLoad);
50
51         enum{ F_PNG, F_JPEG, F_BMP, F_GIF};
52         
53         void decodePic();
54         void decodeThumb();
55         void resizePic();
56
57         Cfilepara *m_filepara;
58         bool threadrunning;
59         
60         struct PConf
61         {
62                 int max_x;
63                 int max_y;
64                 double aspect_ratio;
65                 unsigned char background[4];
66                 bool resizetype;
67                 bool usecache;
68                 int thumbnailsize;
69                 int test;
70         } m_conf;
71         
72         struct Message
73         {
74                 int type;
75                 enum
76                 {
77                         decode_Pic,
78                         decode_Thumb,
79                         decode_finished,
80                         quit
81                 };
82                 Message(int type=0)
83                         :type(type) {}
84         };
85         eFixedMessagePump<Message> msg_thread, msg_main;
86
87         void gotMessage(const Message &message);
88         void thread();
89         int startThread(int what, const char *file, int x, int y, bool async=true);
90         void thread_finished();
91 public:
92         void waitFinished();
93         PSignal1<void, const char*> PictureData;
94
95         ePicLoad();
96         ~ePicLoad();
97         
98         RESULT startDecode(const char *filename, int x=0, int y=0, bool async=true);
99         RESULT getThumbnail(const char *filename, int x=0, int y=0, bool async=true);
100         RESULT setPara(PyObject *val);
101         PyObject *getInfo(const char *filename);
102         SWIG_VOID(int) getData(ePtr<gPixmap> &SWIG_OUTPUT);
103 };
104
105 //for old plugins
106 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="");
107
108 #endif // __picload_h__