]> git.saurik.com Git - wxWidgets.git/blobdiff - utils/wxPython/src/image.i
incremented wxPython version number
[wxWidgets.git] / utils / wxPython / src / image.i
index c87d3ddb4a312f0d25d6cc3dafd31edcafa95a6a..ae84b468bb97764dd6668ca7651bd0a3be9d7de5 100644 (file)
@@ -102,8 +102,27 @@ public:
     int GetWidth();
     int GetHeight();
 
     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();
 
     void SetMaskColour( unsigned char r, unsigned char g, unsigned char b );
     unsigned char GetMaskRed();