X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/8bf5d46efb26ab22575ca9bc0d0ca5d32d6b77a3..21422dd796b2895e12fb2df4f3353d6cc9004d15:/utils/wxPython/src/image.i diff --git a/utils/wxPython/src/image.i b/utils/wxPython/src/image.i index c87d3ddb4a..ae84b468bb 100644 --- a/utils/wxPython/src/image.i +++ b/utils/wxPython/src/image.i @@ -102,8 +102,27 @@ public: int GetWidth(); int GetHeight(); - unsigned char *GetData(); - void SetData( unsigned char *data ); + //unsigned char *GetData(); + //void SetData( unsigned char *data ); + + %addmethods { + PyObject* GetData() { + unsigned char* data = self->GetData(); + int len = self->GetWidth() * self->GetHeight() * 3; + return PyString_FromStringAndSize((char*)data, len); + } + + void SetData(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); + } + } void SetMaskColour( unsigned char r, unsigned char g, unsigned char b ); unsigned char GetMaskRed();