X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/db0ff83efbd6105c04d5ab84c85094e887e97b9a..a4353f07c6b37712634d4b2d86527b647a08044f:/wxPython/src/msw/image.cpp diff --git a/wxPython/src/msw/image.cpp b/wxPython/src/msw/image.cpp index 4bffe16f97..9e9d25c2bc 100644 --- a/wxPython/src/msw/image.cpp +++ b/wxPython/src/msw/image.cpp @@ -304,7 +304,7 @@ static PyObject *_wrap_wxImageFromStream(PyObject *self, PyObject *args, PyObjec _arg0 = temp->m_wxis; created = FALSE; } else { - _arg0 = wxPyCBInputStream::create(_obj0, FALSE); + _arg0 = wxPyCBInputStream_create(_obj0, FALSE); if (_arg0 == NULL) { PyErr_SetString(PyExc_TypeError,"Expected _wxInputStream_p or Python file-like object."); return NULL; @@ -353,7 +353,7 @@ static PyObject *_wrap_wxImageFromStreamMime(PyObject *self, PyObject *args, PyO _arg0 = temp->m_wxis; created = FALSE; } else { - _arg0 = wxPyCBInputStream::create(_obj0, FALSE); + _arg0 = wxPyCBInputStream_create(_obj0, FALSE); if (_arg0 == NULL) { PyErr_SetString(PyExc_TypeError,"Expected _wxInputStream_p or Python file-like object."); return NULL; @@ -1943,7 +1943,7 @@ static PyObject *_wrap_wxImage_CanReadStream(PyObject *self, PyObject *args, PyO _arg0 = temp->m_wxis; created = FALSE; } else { - _arg0 = wxPyCBInputStream::create(_obj0, FALSE); + _arg0 = wxPyCBInputStream_create(_obj0, FALSE); if (_arg0 == NULL) { PyErr_SetString(PyExc_TypeError,"Expected _wxInputStream_p or Python file-like object."); return NULL; @@ -1994,7 +1994,7 @@ static PyObject *_wrap_wxImage_LoadStream(PyObject *self, PyObject *args, PyObje _arg1 = temp->m_wxis; created = FALSE; } else { - _arg1 = wxPyCBInputStream::create(_obj1, FALSE); + _arg1 = wxPyCBInputStream_create(_obj1, FALSE); if (_arg1 == NULL) { PyErr_SetString(PyExc_TypeError,"Expected _wxInputStream_p or Python file-like object."); return NULL; @@ -2046,7 +2046,7 @@ static PyObject *_wrap_wxImage_LoadMimeStream(PyObject *self, PyObject *args, Py _arg1 = temp->m_wxis; created = FALSE; } else { - _arg1 = wxPyCBInputStream::create(_obj1, FALSE); + _arg1 = wxPyCBInputStream_create(_obj1, FALSE); if (_arg1 == NULL) { PyErr_SetString(PyExc_TypeError,"Expected _wxInputStream_p or Python file-like object."); return NULL; @@ -2268,6 +2268,40 @@ static PyObject *_wrap_wxImage_Paste(PyObject *self, PyObject *args, PyObject *k return _resultobj; } +static PyObject * wxImage_GetDataBuffer(wxImage *self) { + unsigned char* data = self->GetData(); + int len = self->GetWidth() * self->GetHeight() * 3; + return PyBuffer_FromReadWriteMemory(data, len); + } +static PyObject *_wrap_wxImage_GetDataBuffer(PyObject *self, PyObject *args, PyObject *kwargs) { + PyObject * _resultobj; + PyObject * _result; + wxImage * _arg0; + PyObject * _argo0 = 0; + char *_kwnames[] = { "self", NULL }; + + self = self; + if(!PyArg_ParseTupleAndKeywords(args,kwargs,"O:wxImage_GetDataBuffer",_kwnames,&_argo0)) + return NULL; + if (_argo0) { + if (_argo0 == Py_None) { _arg0 = NULL; } + else if (SWIG_GetPtrObj(_argo0,(void **) &_arg0,"_wxImage_p")) { + PyErr_SetString(PyExc_TypeError,"Type error in argument 1 of wxImage_GetDataBuffer. Expected _wxImage_p."); + return NULL; + } + } +{ + PyThreadState* __tstate = wxPyBeginAllowThreads(); + _result = (PyObject *)wxImage_GetDataBuffer(_arg0); + + wxPyEndAllowThreads(__tstate); + if (PyErr_Occurred()) return NULL; +}{ + _resultobj = _result; +} + return _resultobj; +} + static PyObject * wxImage_GetData(wxImage *self) { unsigned char* data = self->GetData(); int len = self->GetWidth() * self->GetHeight() * 3; @@ -2314,6 +2348,7 @@ static void wxImage_SetData(wxImage *self,PyObject * data) { dataPtr = (unsigned char*) malloc(len); memcpy(dataPtr, PyString_AsString(data), len); self->SetData(dataPtr); + // wxImage takes ownership of dataPtr... } static PyObject *_wrap_wxImage_SetData(PyObject *self, PyObject *args, PyObject *kwargs) { PyObject * _resultobj; @@ -3128,6 +3163,7 @@ static PyMethodDef imagecMethods[] = { { "wxImage_SetMaskColour", (PyCFunction) _wrap_wxImage_SetMaskColour, METH_VARARGS | METH_KEYWORDS }, { "wxImage_SetData", (PyCFunction) _wrap_wxImage_SetData, METH_VARARGS | METH_KEYWORDS }, { "wxImage_GetData", (PyCFunction) _wrap_wxImage_GetData, METH_VARARGS | METH_KEYWORDS }, + { "wxImage_GetDataBuffer", (PyCFunction) _wrap_wxImage_GetDataBuffer, METH_VARARGS | METH_KEYWORDS }, { "wxImage_Paste", (PyCFunction) _wrap_wxImage_Paste, METH_VARARGS | METH_KEYWORDS }, { "wxImage_Copy", (PyCFunction) _wrap_wxImage_Copy, METH_VARARGS | METH_KEYWORDS }, { "wxImage_GetSubImage", (PyCFunction) _wrap_wxImage_GetSubImage, METH_VARARGS | METH_KEYWORDS },