]> git.saurik.com Git - wxWidgets.git/blobdiff - wxPython/src/image.i
Removed deprecation warnings in OGL and Gizmos
[wxWidgets.git] / wxPython / src / image.i
index f3d7dc9294792a1f198af050b003e50f464ea545..7f125f11bcd519bf86f7487a714b0249c68885f0 100644 (file)
@@ -136,11 +136,11 @@ public:
     bool SetMaskFromImage(const wxImage & mask,
                           byte mr, byte mg, byte mb);
 
-    void DoFloodFill (wxCoord x, wxCoord y,
-        const wxBrush & fillBrush,
-        const wxColour& testColour,
-        int style = wxFLOOD_SURFACE,
-        int LogicalFunction = wxCOPY /* currently unused */ ) ;
+//      void DoFloodFill (wxCoord x, wxCoord y,
+//          const wxBrush & fillBrush,
+//          const wxColour& testColour,
+//          int style = wxFLOOD_SURFACE,
+//          int LogicalFunction = wxCOPY /* currently unused */ ) ;
 
     static bool CanRead( const wxString& name );
     static int GetImageCount( const wxString& name, long type = wxBITMAP_TYPE_ANY );
@@ -167,12 +167,33 @@ public:
     //void SetData( unsigned char *data );
 
     %addmethods {
+        PyObject* GetDataBuffer() {
+            unsigned char* data = self->GetData();
+            int len = self->GetWidth() * self->GetHeight() * 3;
+            return PyBuffer_FromReadWriteMemory(data, len);
+        }
+
         PyObject* GetData() {
             unsigned char* data = self->GetData();
             int len = self->GetWidth() * self->GetHeight() * 3;
             return PyString_FromStringAndSize((char*)data, len);
         }
 
+        void SetDataBuffer(PyObject* data) {
+            unsigned char* buffer;
+            int size;
+
+            if (!PyArg_Parse(data, "w#", &buffer, &size))
+                return;
+
+            if (size != self->GetWidth() * self->GetHeight() * 3) {
+                PyErr_SetString(PyExc_TypeError, "Incorrect buffer size");
+                return;
+            }
+
+            self->SetData(buffer);
+        }
+
         void SetData(PyObject* data) {
             unsigned char* dataPtr;
 
@@ -185,6 +206,7 @@ public:
             dataPtr = (unsigned char*) malloc(len);
             memcpy(dataPtr, PyString_AsString(data), len);
             self->SetData(dataPtr);
+            // wxImage takes ownership of dataPtr...
         }
     }