openATV enigma2
openATV is an open source SetTopBox Graphical user interface.
picload.h
Go to the documentation of this file.
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;
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)),
29  palette(NULL),
30  palette_size(0),
31  bits(24),
32  id(mid),
33  max_x(0),
34  max_y(0),
35  ox(0),
36  oy(0),
37  picinfo(mfile),
38  callback(true)
39  {
40  picinfo += "\n" + size + "\n";
41  }
42 
44  {
45  if (pic_buffer != NULL) delete pic_buffer;
46  if (palette != NULL) delete palette;
47  free(file);
48  }
49 
50  void addExifInfo(std::string val) { picinfo += val + "\n"; }
51 };
52 #endif
53 
54 class ePicLoad: public eMainloop, public eThread, public sigc::trackable, public iObject
55 {
56  DECLARE_REF(ePicLoad);
57 
58  enum{ F_PNG, F_JPEG, F_BMP, F_GIF, F_SVG};
59 
60  void decodePic();
61  void decodeThumb();
62  void resizePic();
63 
64  Cfilepara *m_filepara;
65  bool threadrunning;
66 
67  struct PConf
68  {
69  int max_x;
70  int max_y;
71  double aspect_ratio;
72  unsigned int background;
73  bool resizetype;
74  bool usecache;
75  int thumbnailsize;
76  int test;
77  PConf();
78  } m_conf;
79 
80  struct Message
81  {
82  int type;
83  enum
84  {
85  decode_Pic,
86  decode_Thumb,
87  decode_finished,
88  decode_error,
89  quit
90  };
91  Message(int type=0)
92  :type(type) {}
93  };
94  eFixedMessagePump<Message> msg_thread, msg_main;
95 
96  void gotMessage(const Message &message);
97  void thread();
98  int startThread(int what, const char *file, int x, int y, bool async=true);
99  void thread_finished();
100 public:
101  void waitFinished();
103 
104  ePicLoad();
105  ~ePicLoad();
106 
107  RESULT startDecode(const char *filename, int x=0, int y=0, bool async=true);
108  RESULT getThumbnail(const char *filename, int x=0, int y=0, bool async=true);
109  RESULT setPara(PyObject *val);
110  RESULT setPara(int width, int height, double aspectRatio, int as, bool useCache, int resizeType, const char *bg_str);
111  PyObject *getInfo(const char *filename);
113 };
114 
115 //for old plugins
116 SWIG_VOID(int) loadPic(ePtr<gPixmap> &SWIG_OUTPUT, std::string filename, int x, int y, int aspect, int resize_mode=0, int rotate=0, unsigned int background=0, std::string cachefile="");
117 
118 #endif // __picload_h__
Definition: ebase.h:187
void quit(int ret=0)
Definition: ebase.cpp:389
Definition: picload.h:55
SWIG_VOID(int) getData(ePtr< gPixmap > &SWIG_OUTPUT)
RESULT getThumbnail(const char *filename, int x=0, int y=0, bool async=true)
Definition: picload.cpp:1225
PSignal1< void, const char * > PictureData
Definition: picload.h:102
~ePicLoad()
Definition: picload.cpp:886
RESULT startDecode(const char *filename, int x=0, int y=0, bool async=true)
Definition: picload.cpp:1220
ePicLoad()
Definition: picload.cpp:858
PyObject * getInfo(const char *filename)
Definition: picload.cpp:1230
void waitFinished()
Definition: picload.cpp:880
RESULT setPara(PyObject *val)
Definition: picload.cpp:1457
Definition: thread.h:27
Definition: object.h:15
#define NULL
Definition: eerror.h:101
const char int int int height
Definition: epng.h:39
const char int int width
Definition: epng.h:39
size
Definition: Plugins/SystemPlugins/PositionerSetup/log.py:16
file
Definition: newplugin.py:100
val
Definition: UnitConversions.py:88
int RESULT
Definition: object.h:12
SWIG_VOID(int) loadPic(ePtr< gPixmap > &SWIG_OUTPUT
std::string int int int int int unsigned int background
Definition: picload.h:116
std::string int int int aspect
Definition: picload.h:116
std::string int int int int int rotate
Definition: picload.h:116
std::string int int y
Definition: picload.h:116
std::string int x
Definition: picload.h:116
std::string int int int int int unsigned int std::string cachefile
Definition: picload.h:116
std::string filename
Definition: picload.h:116
std::string int int int int resize_mode
Definition: picload.h:116
Definition: picload.h:12
~Cfilepara()
Definition: picload.h:43
int max_x
Definition: picload.h:19
char * file
Definition: picload.h:13
unsigned char * pic_buffer
Definition: picload.h:14
int id
Definition: picload.h:18
std::string picinfo
Definition: picload.h:23
gRGB * palette
Definition: picload.h:15
bool callback
Definition: picload.h:24
int max_y
Definition: picload.h:20
void addExifInfo(std::string val)
Definition: picload.h:50
int ox
Definition: picload.h:21
int palette_size
Definition: picload.h:16
int bits
Definition: picload.h:17
Cfilepara(const char *mfile, int mid, std::string size)
Definition: picload.h:26
int oy
Definition: picload.h:22
Definition: gpixmap.h:14
#define SWIG_OUTPUT
Definition: swig.h:20