X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/8bf5d46efb26ab22575ca9bc0d0ca5d32d6b77a3..85bc0351f76f6d3f00460a167fc108b900e0725c:/utils/wxPython/src/image.i diff --git a/utils/wxPython/src/image.i b/utils/wxPython/src/image.i index c87d3ddb4a..d6095c7a52 100644 --- a/utils/wxPython/src/image.i +++ b/utils/wxPython/src/image.i @@ -32,7 +32,7 @@ class wxImageHandler { public: - wxImageHandler(); + // wxImageHandler(); Abstract Base Class wxString GetName(); wxString GetExtension(); long GetType(); @@ -72,6 +72,20 @@ public: wxGIFHandler(); }; +class wxPNMHandler : public wxImageHandler { +public: + wxPNMHandler(); +}; + +class wxPCXHandler : public wxImageHandler { +public: + wxPCXHandler(); +}; + +class wxTIFFHandler : public wxImageHandler { +public: + wxTIFFHandler(); +}; //--------------------------------------------------------------------------- @@ -102,8 +116,32 @@ public: int GetWidth(); int GetHeight(); - unsigned char *GetData(); - void SetData( unsigned char *data ); + wxImage GetSubImage(const wxRect& rect); + + //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 */ ; + } + + size_t len = self->GetWidth() * self->GetHeight() * 3; + dataPtr = new unsigned char[len]; + memcpy(dataPtr, PyString_AsString(data), len); + self->SetData(dataPtr); + } + } void SetMaskColour( unsigned char r, unsigned char g, unsigned char b ); unsigned char GetMaskRed(); @@ -145,9 +183,7 @@ void wxImage_AddHandler(wxImageHandler *handler); } %} +void wxInitAllImageHandlers(); + //--------------------------------------------------------------------------- //--------------------------------------------------------------------------- - - - -