+ if(m_conf.resizetype)
+ m_filepara->pic_buffer = color_resize(m_filepara->pic_buffer, m_filepara->ox, m_filepara->oy, imx, imy);
+ else
+ m_filepara->pic_buffer = simple_resize(m_filepara->pic_buffer, m_filepara->ox, m_filepara->oy, imx, imy);
+
+ m_filepara->ox = imx;
+ m_filepara->oy = imy;
+}
+
+void ePicLoad::gotMessage(const Message &msg)
+{
+ switch (msg.type)
+ {
+ case Message::decode_Pic:
+ decodePic();
+ msg_main.send(Message(Message::decode_finished));
+ break;
+ case Message::decode_Thumb:
+ decodeThumb();
+ msg_main.send(Message(Message::decode_finished));
+ break;
+ case Message::quit: // called from decode thread
+ eDebug("[Picload] decode thread ... got quit msg");
+ quit(0);
+ break;
+ case Message::decode_finished: // called from main thread
+ //eDebug("[Picload] decode finished... %s", m_filepara->file);
+ threadrunning=false;
+ if(m_filepara->callback)
+ {
+ PictureData(m_filepara->picinfo.c_str());
+ }
+ else
+ {
+ if(m_filepara != NULL)
+ {
+ delete m_filepara;
+ m_filepara = NULL;
+ }
+ }
+ break;
+ default:
+ eDebug("unhandled thread message");
+ }
+}
+
+int ePicLoad::startThread(int what, const char *file, int x, int y)
+{
+ if(threadrunning && m_filepara != NULL)
+ {
+ eDebug("[Picload] thread running");
+ m_filepara->callback = false;
+ return 1;
+ }
+
+ if(m_filepara != NULL)
+ {
+ delete m_filepara;
+ m_filepara = NULL;
+ }
+
+ int file_id = -1;
+ unsigned char id[10];
+ int fd = ::open(file, O_RDONLY);
+ if (fd == -1) return 1;
+ ::read(fd, id, 10);
+ ::close(fd);
+
+ if(id[1] == 'P' && id[2] == 'N' && id[3] == 'G') file_id = F_PNG;
+ else if(id[6] == 'J' && id[7] == 'F' && id[8] == 'I' && id[9] == 'F') file_id = F_JPEG;
+ else if(id[0] == 0xff && id[1] == 0xd8 && id[2] == 0xff) file_id = F_JPEG;
+ else if(id[0] == 'B' && id[1] == 'M' ) file_id = F_BMP;
+ else if(id[0] == 'G' && id[1] == 'I' && id[2] == 'F') file_id = F_GIF;
+
+ if(file_id < 0)
+ {
+ eDebug("[Picload] <format not supportet>");
+ return 1;
+ }
+
+ m_filepara = new Cfilepara(file, file_id, getSize(file));
+ x > 0 ? m_filepara->max_x = x : m_filepara->max_x = m_conf.max_x;
+ y > 0 ? m_filepara->max_y = y : m_filepara->max_y = m_conf.max_y;
+
+ if(m_filepara->max_x <= 0 || m_filepara->max_y <= 0)
+ {
+ delete m_filepara;
+ m_filepara = NULL;
+ eDebug("[Picload] <error in Para>");
+ return 1;
+ }
+
+ threadrunning=true;
+ if(what==1)
+ msg_thread.send(Message(Message::decode_Pic));
+ else
+ msg_thread.send(Message(Message::decode_Thumb));
+ run();
+ return 0;
+}
+
+RESULT ePicLoad::startDecode(const char *file, int x, int y)
+{
+ return startThread(1, file, x, y);
+}
+
+RESULT ePicLoad::getThumbnail(const char *file, int x, int y)
+{
+ return startThread(0, file, x, y);
+}
+
+RESULT ePicLoad::setPara(PyObject *val)
+{
+ if (!PyList_Check(val))
+ return 0;
+ if (PyList_Size(val) < 6)
+ return 0;
+
+ m_conf.max_x = PyInt_AsLong( PyList_GET_ITEM(val, 0));
+ m_conf.max_y = PyInt_AsLong( PyList_GET_ITEM(val, 1));
+ m_conf.aspect_ratio = PyFloat_AsDouble( PyList_GET_ITEM(val, 2));
+ m_conf.usecache = PyInt_AsLong( PyList_GET_ITEM(val, 3));
+ m_conf.resizetype = PyInt_AsLong( PyList_GET_ITEM(val, 4));
+ const char *bg_str = PyString_AsString( PyList_GET_ITEM(val, 5));
+
+ if(bg_str[0] == '#' && strlen(bg_str)==9)
+ {
+ int bg = strtoul(bg_str+1, NULL, 16);
+ m_conf.background[0] = bg&0xFF; //BB
+ m_conf.background[1] = (bg>>8)&0xFF; //GG
+ m_conf.background[2] = (bg>>16)&0xFF; //RR
+ m_conf.background[3] = bg>>24; //AA
+ }
+
+ eDebug("[Picload] setPara max-X=%d max-Y=%d aspect_ratio=%lf cache=%d resize=%d bg=#%02X%02X%02X%02X", m_conf.max_x, m_conf.max_y, m_conf.aspect_ratio, (int)m_conf.usecache, (int)m_conf.resizetype, m_conf.background[3], m_conf.background[2], m_conf.background[1], m_conf.background[0]);
+ return 1;
+}
+
+PyObject *ePicLoad::getInfo(const char *filename)
+{
+ ePyObject list;
+
+ Cexif *exif = new Cexif;
+ if(exif->DecodeExif(filename))
+ {
+ if(exif->m_exifinfo->IsExif)