X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/849949b13fa19002da52333e760ebfecd00c60d9..1dc2f8658b885eb1d3514bba87c24830f0e9b034:/utils/wxPython/src/msw/image.cpp?ds=sidebyside diff --git a/utils/wxPython/src/msw/image.cpp b/utils/wxPython/src/msw/image.cpp index 83ba636183..1a44b5ee88 100644 --- a/utils/wxPython/src/msw/image.cpp +++ b/utils/wxPython/src/msw/image.cpp @@ -1207,13 +1207,16 @@ static PyObject *_wrap_wxImage_GetHeight(PyObject *self, PyObject *args) { return _resultobj; } -#define wxImage_GetData(_swigobj) (_swigobj->GetData()) +static PyObject * wxImage_GetData(wxImage *self) { + unsigned char* data = self->GetData(); + int len = self->GetWidth() * self->GetHeight() * 3; + return PyString_FromStringAndSize((char*)data, len); + } static PyObject *_wrap_wxImage_GetData(PyObject *self, PyObject *args) { PyObject * _resultobj; - unsigned char * _result; + PyObject * _result; wxImage * _arg0; char * _argc0 = 0; - char _ptemp[128]; self = self; if(!PyArg_ParseTuple(args,"s:wxImage_GetData",&_argc0)) @@ -1226,24 +1229,34 @@ static PyObject *_wrap_wxImage_GetData(PyObject *self, PyObject *args) { } { wxPy_BEGIN_ALLOW_THREADS; - _result = (unsigned char *)wxImage_GetData(_arg0); + _result = (PyObject *)wxImage_GetData(_arg0); wxPy_END_ALLOW_THREADS; -} SWIG_MakePtr(_ptemp, (char *) _result,"_unsigned_char_p"); - _resultobj = Py_BuildValue("s",_ptemp); +}{ + _resultobj = _result; +} return _resultobj; } -#define wxImage_SetData(_swigobj,_swigarg0) (_swigobj->SetData(_swigarg0)) +static void wxImage_SetData(wxImage *self,PyObject * data) { + unsigned char* dataPtr; + + if (! PyString_Check(data)) { + PyErr_SetString(PyExc_TypeError, "Expected string object"); + return /* NULL */ ; + } + dataPtr = (unsigned char*)PyString_AsString(data); + self->SetData(dataPtr); + } static PyObject *_wrap_wxImage_SetData(PyObject *self, PyObject *args) { PyObject * _resultobj; wxImage * _arg0; - unsigned char * _arg1; + PyObject * _arg1; char * _argc0 = 0; - char * _argc1 = 0; + PyObject * _obj1 = 0; self = self; - if(!PyArg_ParseTuple(args,"ss:wxImage_SetData",&_argc0,&_argc1)) + if(!PyArg_ParseTuple(args,"sO:wxImage_SetData",&_argc0,&_obj1)) return NULL; if (_argc0) { if (SWIG_GetPtr(_argc0,(void **) &_arg0,"_wxImage_p")) { @@ -1251,12 +1264,9 @@ static PyObject *_wrap_wxImage_SetData(PyObject *self, PyObject *args) { return NULL; } } - if (_argc1) { - if (SWIG_GetPtr(_argc1,(void **) &_arg1,"_unsigned_char_p")) { - PyErr_SetString(PyExc_TypeError,"Type error in argument 2 of wxImage_SetData. Expected _unsigned_char_p."); - return NULL; - } - } +{ + _arg1 = _obj1; +} { wxPy_BEGIN_ALLOW_THREADS; wxImage_SetData(_arg0,_arg1);