+
+RESULT ePicLoad::setPara(PyObject *val)
+{
+ if (!PySequence_Check(val))
+ return 0;
+ if (PySequence_Size(val) < 7)
+ return 0;
+ else {
+ ePyObject fast = PySequence_Fast(val, "");
+ m_conf.max_x = PyInt_AsLong( PySequence_Fast_GET_ITEM(fast, 0));
+ m_conf.max_y = PyInt_AsLong( PySequence_Fast_GET_ITEM(fast, 1));
+ m_conf.aspect_ratio = (double)PyInt_AsLong( PySequence_Fast_GET_ITEM(fast, 2)) / PyInt_AsLong(PySequence_Fast_GET_ITEM(fast, 3));
+ m_conf.usecache = PyInt_AsLong( PySequence_Fast_GET_ITEM(fast, 4));
+ m_conf.resizetype = PyInt_AsLong( PySequence_Fast_GET_ITEM(fast, 5));
+ const char *bg_str = PyString_AsString( PySequence_Fast_GET_ITEM(fast, 6));
+
+ 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;
+}
+
+//------------------------------------------------------------------------------------
+
+//for old plugins
+SWIG_VOID(int) loadPic(ePtr<gPixmap> &result, std::string filename, int x, int y, int aspect, int resize_mode, int rotate, int background, std::string cachefile)
+{
+ long asp1, asp2;
+ result = 0;
+ eDebug("deprecated loadPic function used!!! please use the non blocking version! you can see demo code in Pictureplayer plugin... this function is removed in the near future!");
+ ePicLoad mPL;
+
+ switch(aspect)
+ {
+ case 1: asp1 = 16*576, asp2 = 9*720; break; //16:9
+ case 2: asp1 = 16*576, asp2 = 10*720; break; //16:10
+ case 3: asp1 = 5*576, asp2 = 4*720; break; //5:4
+ default: asp1 = 4*576, asp2 = 3*720; break; //4:3
+ }
+
+ ePyObject tuple = PyTuple_New(7);
+ PyTuple_SET_ITEM(tuple, 0, PyLong_FromLong(x));
+ PyTuple_SET_ITEM(tuple, 1, PyLong_FromLong(y));
+ PyTuple_SET_ITEM(tuple, 2, PyLong_FromLong(asp1));
+ PyTuple_SET_ITEM(tuple, 3, PyLong_FromLong(asp2));
+ PyTuple_SET_ITEM(tuple, 4, PyLong_FromLong(0));
+ PyTuple_SET_ITEM(tuple, 5, PyLong_FromLong(resize_mode));
+ if(background)
+ PyTuple_SET_ITEM(tuple, 6, PyString_FromString("#ff000000"));
+ else
+ PyTuple_SET_ITEM(tuple, 6, PyString_FromString("#00000000"));
+
+ mPL.setPara(tuple);
+
+ if(!mPL.startDecode(filename.c_str(), 0, 0, false))
+ mPL.getData(result);
+
+ return 0;
+}