Extrenal srt problem gst-1 solved.
[openblackhole/openblackhole-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 struct Cfilepara
12 {
13         char *file;
14         unsigned char *pic_buffer;
15         gRGB *palette;
16         int palette_size;
17         int bits;
18         int id;
19         int max_x;
20         int max_y;
21         int ox;
22         int oy;
23         std::string picinfo;
24         bool callback;
25
26         Cfilepara(const char *mfile, int mid, std::string size):
27                 file(strdup(mfile)),
28                 pic_buffer(NULL),
29                 palette(NULL),
30                 palette_size(0),
31                 bits(24),
32                 id(mid),
33                 picinfo(mfile),
34                 callback(true)
35         {
36                 picinfo += "\n" + size + "\n";
37         }
38
39         ~Cfilepara()
40         {
41                 if (pic_buffer != NULL) delete pic_buffer;
42                 if (palette != NULL) delete palette;
43                 free(file);
44         }
45
46         void addExifInfo(std::string val) { picinfo += val + "\n"; }
47 };
48 #endif
49
50 class ePicLoad: public eMainloop, public eThread, public Object, public iObject
51 {
52         DECLARE_REF(ePicLoad);
53
54         enum{ F_PNG, F_JPEG, F_BMP, F_GIF};
55
56         void decodePic();
57         void decodeThumb();
58         void resizePic();
59
60         Cfilepara *m_filepara;
61         bool threadrunning;
62
63         struct PConf
64         {
65                 int max_x;
66                 int max_y;
67                 double aspect_ratio;
68                 int background;
69                 bool resizetype;
70                 bool usecache;
71                 int thumbnailsize;
72                 int test;
73                 PConf();
74         } m_conf;
75
76         struct Message
77         {
78                 int type;
79                 enum
80                 {
81                         decode_Pic,
82                         decode_Thumb,
83                         decode_finished,
84                         quit
85                 };
86                 Message(int type=0)
87                         :type(type) {}
88         };
89         eFixedMessagePump<Message> msg_thread, msg_main;
90
91         void gotMessage(const Message &message);
92         void thread();
93         int startThread(int what, const char *file, int x, int y, bool async=true);
94         void thread_finished();
95 public:
96         void waitFinished();
97         PSignal1<void, const char*> PictureData;
98
99         ePicLoad();
100         ~ePicLoad();
101
102         RESULT startDecode(const char *filename, int x=0, int y=0, bool async=true);
103         RESULT getThumbnail(const char *filename, int x=0, int y=0, bool async=true);
104         RESULT setPara(PyObject *val);
105         RESULT setPara(int width, int height, double aspectRatio, int as, bool useCache, int resizeType, const char *bg_str);
106         PyObject *getInfo(const char *filename);
107         SWIG_VOID(int) getData(ePtr<gPixmap> &SWIG_OUTPUT);
108 };
109
110 //for old plugins
111 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="");
112
113 #endif // __picload_h__