]> git.saurik.com Git - wxWidgets.git/commitdiff
Added wxImage.GetDataBuffer which returns an in-place edit buffer of
authorRobin Dunn <robin@alldunn.com>
Mon, 22 Apr 2002 21:18:52 +0000 (21:18 +0000)
committerRobin Dunn <robin@alldunn.com>
Mon, 22 Apr 2002 21:18:52 +0000 (21:18 +0000)
the image data.  (Patch #546009)

git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@15241 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775

wxPython/CHANGES.txt
wxPython/src/image.i
wxPython/src/msw/image.cpp
wxPython/src/msw/image.py

index c69baec9bf7dcdd96566a358d3519fef117eaeab..60b82af4f945cacfc2bd97fdaed1d87c584bf229 100644 (file)
@@ -88,6 +88,8 @@ Added OOR support for wxGridCellRenderer, wxGridCellEditor,
 wxGridCellAttr, wxGridCellAttrProvider, wxGridTableBase and their
 derived classes.
 
+Added wxImage.GetDataBuffer which returns an in-place edit buffer of
+the image data.  (Patch #546009)
 
 
 
index 837336efe8260a83ec98cef172a2b370a4b989e1..ab9ccc65e9af94edde6f6c514b859fad7366d8fb 100644 (file)
@@ -167,6 +167,12 @@ 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;
index 4bffe16f97da6ff6cdc4defaa8990454cab225ab..dd9ca72cb3be9ca5117599334e796977afe9fa0f 100644 (file)
@@ -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;
@@ -3128,6 +3162,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 },
index 844a22e9549664affb9678b2b0def8d3dd119662..51a559ae51953d624de80697347622a983f1c837 100644 (file)
@@ -265,6 +265,9 @@ class wxImagePtr(wxObjectPtr):
     def Paste(self, *_args, **_kwargs):
         val = apply(imagec.wxImage_Paste,(self,) + _args, _kwargs)
         return val
+    def GetDataBuffer(self, *_args, **_kwargs):
+        val = apply(imagec.wxImage_GetDataBuffer,(self,) + _args, _kwargs)
+        return val
     def GetData(self, *_args, **_kwargs):
         val = apply(imagec.wxImage_GetData,(self,) + _args, _kwargs)
         return val