From eec1c382d09671fca4e5e8af83b8b40dea980d53 Mon Sep 17 00:00:00 2001 From: Robin Dunn Date: Tue, 29 Aug 2006 19:26:06 +0000 Subject: [PATCH] reSWIGged git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@40916 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- wxPython/src/gtk/_core.py | 24 ++++++------- wxPython/src/gtk/_core_wrap.cpp | 37 ++++++++----------- wxPython/src/gtk/_gdi.py | 64 ++++++++++++++++----------------- wxPython/src/gtk/_gdi_wrap.cpp | 14 +++----- wxPython/src/mac/_core.py | 24 ++++++------- wxPython/src/mac/_core_wrap.cpp | 37 ++++++++----------- wxPython/src/mac/_gdi.py | 64 ++++++++++++++++----------------- wxPython/src/mac/_gdi_wrap.cpp | 14 +++----- wxPython/src/msw/_core.py | 24 ++++++------- wxPython/src/msw/_core_wrap.cpp | 37 ++++++++----------- wxPython/src/msw/_gdi.py | 64 ++++++++++++++++----------------- wxPython/src/msw/_gdi_wrap.cpp | 14 +++----- 12 files changed, 174 insertions(+), 243 deletions(-) diff --git a/wxPython/src/gtk/_core.py b/wxPython/src/gtk/_core.py index 837170a76b..3cc6d8209e 100644 --- a/wxPython/src/gtk/_core.py +++ b/wxPython/src/gtk/_core.py @@ -275,10 +275,6 @@ ID_ZOOM_OUT = _core_.ID_ZOOM_OUT ID_UNDELETE = _core_.ID_UNDELETE ID_REVERT_TO_SAVED = _core_.ID_REVERT_TO_SAVED ID_HIGHEST = _core_.ID_HIGHEST -ACCEL_ALT = _core_.ACCEL_ALT -ACCEL_CTRL = _core_.ACCEL_CTRL -ACCEL_SHIFT = _core_.ACCEL_SHIFT -ACCEL_NORMAL = _core_.ACCEL_NORMAL PD_AUTO_HIDE = _core_.PD_AUTO_HIDE PD_APP_MODAL = _core_.PD_APP_MODAL PD_CAN_ABORT = _core_.PD_CAN_ABORT @@ -3070,12 +3066,11 @@ def _ImageFromBuffer(*args, **kwargs): def ImageFromBuffer(width, height, dataBuffer, alphaBuffer=None): """ Creates a `wx.Image` from the data in dataBuffer. The dataBuffer - parameter must be a Python object that implements the buffer interface, or - is convertable to a buffer object, such as a string, array, etc. The - dataBuffer object is expected to contain a series of RGB bytes and be - width*height*3 bytes long. A buffer object can optionally be supplied for - the image's alpha channel data, and it is expected to be width*height - bytes long. + parameter must be a Python object that implements the buffer interface, + such as a string, array, etc. The dataBuffer object is expected to + contain a series of RGB bytes and be width*height*3 bytes long. A buffer + object can optionally be supplied for the image's alpha channel data, and + it is expected to be width*height bytes long. The wx.Image will be created with its data and alpha pointers initialized to the memory address pointed to by the buffer objects, thus saving the @@ -3093,10 +3088,6 @@ def ImageFromBuffer(width, height, dataBuffer, alphaBuffer=None): the objects used for the data and alpha buffers in a way that would cause them to change size. """ - if not isinstance(dataBuffer, buffer): - dataBuffer = buffer(dataBuffer) - if alphaBuffer is not None and not isinstance(alphaBuffer, buffer): - alphaBuffer = buffer(alphaBuffer) image = _core_._ImageFromBuffer(width, height, dataBuffer, alphaBuffer) image._buffer = dataBuffer image._alpha = alphaBuffer @@ -7461,6 +7452,11 @@ _core_.EventLoopActivator_swigregister(EventLoopActivator) #--------------------------------------------------------------------------- +ACCEL_ALT = _core_.ACCEL_ALT +ACCEL_CTRL = _core_.ACCEL_CTRL +ACCEL_SHIFT = _core_.ACCEL_SHIFT +ACCEL_NORMAL = _core_.ACCEL_NORMAL +ACCEL_CMD = _core_.ACCEL_CMD class AcceleratorEntry(object): """ A class used to define items in an `wx.AcceleratorTable`. wxPython diff --git a/wxPython/src/gtk/_core_wrap.cpp b/wxPython/src/gtk/_core_wrap.cpp index 12a9404d2c..472b826d03 100644 --- a/wxPython/src/gtk/_core_wrap.cpp +++ b/wxPython/src/gtk/_core_wrap.cpp @@ -13430,9 +13430,7 @@ SWIGINTERN PyObject *_wrap_new_ImageFromData(PyObject *SWIGUNUSEDPARM(self), PyO } arg2 = static_cast< int >(val2); { - if (obj2 != Py_None) { - if (!PyArg_Parse(obj2, "t#", &arg3, &arg4)) SWIG_fail; - } + if (PyObject_AsReadBuffer(obj2, (const void**)(&arg3), &arg4) == -1) SWIG_fail; } { PyThreadState* __tstate = wxPyBeginAllowThreads(); @@ -13480,13 +13478,11 @@ SWIGINTERN PyObject *_wrap_new_ImageFromDataWithAlpha(PyObject *SWIGUNUSEDPARM(s } arg2 = static_cast< int >(val2); { - if (obj2 != Py_None) { - if (!PyArg_Parse(obj2, "t#", &arg3, &arg4)) SWIG_fail; - } + if (PyObject_AsReadBuffer(obj2, (const void**)(&arg3), &arg4) == -1) SWIG_fail; } { if (obj3 != Py_None) { - if (!PyArg_Parse(obj3, "t#", &arg5, &arg6)) SWIG_fail; + if (PyObject_AsReadBuffer(obj3, (const void**)(&arg5), &arg6) == -1) SWIG_fail; } } { @@ -15509,9 +15505,7 @@ SWIGINTERN PyObject *_wrap_Image_SetData(PyObject *SWIGUNUSEDPARM(self), PyObjec } arg1 = reinterpret_cast< wxImage * >(argp1); { - if (obj1 != Py_None) { - if (!PyArg_Parse(obj1, "t#", &arg2, &arg3)) SWIG_fail; - } + if (PyObject_AsReadBuffer(obj1, (const void**)(&arg2), &arg3) == -1) SWIG_fail; } { PyThreadState* __tstate = wxPyBeginAllowThreads(); @@ -15574,9 +15568,7 @@ SWIGINTERN PyObject *_wrap_Image_SetDataBuffer(PyObject *SWIGUNUSEDPARM(self), P } arg1 = reinterpret_cast< wxImage * >(argp1); { - if (obj1 != Py_None) { - if (!PyArg_Parse(obj1, "t#", &arg2, &arg3)) SWIG_fail; - } + if (PyObject_AsReadBuffer(obj1, (const void**)(&arg2), &arg3) == -1) SWIG_fail; } { PyThreadState* __tstate = wxPyBeginAllowThreads(); @@ -15640,7 +15632,7 @@ SWIGINTERN PyObject *_wrap_Image_SetAlphaData(PyObject *SWIGUNUSEDPARM(self), Py arg1 = reinterpret_cast< wxImage * >(argp1); { if (obj1 != Py_None) { - if (!PyArg_Parse(obj1, "t#", &arg2, &arg3)) SWIG_fail; + if (PyObject_AsReadBuffer(obj1, (const void**)(&arg2), &arg3) == -1) SWIG_fail; } } { @@ -15705,7 +15697,7 @@ SWIGINTERN PyObject *_wrap_Image_SetAlphaBuffer(PyObject *SWIGUNUSEDPARM(self), arg1 = reinterpret_cast< wxImage * >(argp1); { if (obj1 != Py_None) { - if (!PyArg_Parse(obj1, "t#", &arg2, &arg3)) SWIG_fail; + if (PyObject_AsReadBuffer(obj1, (const void**)(&arg2), &arg3) == -1) SWIG_fail; } } { @@ -17082,14 +17074,12 @@ SWIGINTERN PyObject *_wrap__ImageFromBuffer(PyObject *SWIGUNUSEDPARM(self), PyOb } arg2 = static_cast< int >(val2); { - if (obj2 != Py_None) { - if (!PyArg_Parse(obj2, "t#", &arg3, &arg4)) SWIG_fail; - } + if (PyObject_AsReadBuffer(obj2, (const void**)(&arg3), &arg4) == -1) SWIG_fail; } if (obj3) { { if (obj3 != Py_None) { - if (!PyArg_Parse(obj3, "t#", &arg5, &arg6)) SWIG_fail; + if (PyObject_AsReadBuffer(obj3, (const void**)(&arg5), &arg6) == -1) SWIG_fail; } } } @@ -56284,10 +56274,6 @@ SWIGEXPORT void SWIG_init(void) { SWIG_Python_SetConstant(d, "ID_UNDELETE",SWIG_From_int(static_cast< int >(wxID_UNDELETE))); SWIG_Python_SetConstant(d, "ID_REVERT_TO_SAVED",SWIG_From_int(static_cast< int >(wxID_REVERT_TO_SAVED))); SWIG_Python_SetConstant(d, "ID_HIGHEST",SWIG_From_int(static_cast< int >(wxID_HIGHEST))); - SWIG_Python_SetConstant(d, "ACCEL_ALT",SWIG_From_int(static_cast< int >(wxACCEL_ALT))); - SWIG_Python_SetConstant(d, "ACCEL_CTRL",SWIG_From_int(static_cast< int >(wxACCEL_CTRL))); - SWIG_Python_SetConstant(d, "ACCEL_SHIFT",SWIG_From_int(static_cast< int >(wxACCEL_SHIFT))); - SWIG_Python_SetConstant(d, "ACCEL_NORMAL",SWIG_From_int(static_cast< int >(wxACCEL_NORMAL))); SWIG_Python_SetConstant(d, "PD_AUTO_HIDE",SWIG_From_int(static_cast< int >(wxPD_AUTO_HIDE))); SWIG_Python_SetConstant(d, "PD_APP_MODAL",SWIG_From_int(static_cast< int >(wxPD_APP_MODAL))); SWIG_Python_SetConstant(d, "PD_CAN_ABORT",SWIG_From_int(static_cast< int >(wxPD_CAN_ABORT))); @@ -56936,6 +56922,11 @@ SWIGEXPORT void SWIG_init(void) { SWIG_Python_SetConstant(d, "PYAPP_ASSERT_LOG",SWIG_From_int(static_cast< int >(wxPYAPP_ASSERT_LOG))); SWIG_Python_SetConstant(d, "PRINT_WINDOWS",SWIG_From_int(static_cast< int >(wxPRINT_WINDOWS))); SWIG_Python_SetConstant(d, "PRINT_POSTSCRIPT",SWIG_From_int(static_cast< int >(wxPRINT_POSTSCRIPT))); + SWIG_Python_SetConstant(d, "ACCEL_ALT",SWIG_From_int(static_cast< int >(wxACCEL_ALT))); + SWIG_Python_SetConstant(d, "ACCEL_CTRL",SWIG_From_int(static_cast< int >(wxACCEL_CTRL))); + SWIG_Python_SetConstant(d, "ACCEL_SHIFT",SWIG_From_int(static_cast< int >(wxACCEL_SHIFT))); + SWIG_Python_SetConstant(d, "ACCEL_NORMAL",SWIG_From_int(static_cast< int >(wxACCEL_NORMAL))); + SWIG_Python_SetConstant(d, "ACCEL_CMD",SWIG_From_int(static_cast< int >(wxACCEL_CMD))); SWIG_addvarlink(SWIG_globals(),(char*)"NullAcceleratorTable",NullAcceleratorTable_get, NullAcceleratorTable_set); SWIG_addvarlink(SWIG_globals(),(char*)"PanelNameStr",PanelNameStr_get, PanelNameStr_set); SWIG_Python_SetConstant(d, "WINDOW_VARIANT_NORMAL",SWIG_From_int(static_cast< int >(wxWINDOW_VARIANT_NORMAL))); diff --git a/wxPython/src/gtk/_gdi.py b/wxPython/src/gtk/_gdi.py index 08dec1ccae..f24c6564f3 100644 --- a/wxPython/src/gtk/_gdi.py +++ b/wxPython/src/gtk/_gdi.py @@ -724,29 +724,26 @@ def _BitmapFromBuffer(*args, **kwargs): def BitmapFromBuffer(width, height, dataBuffer, alphaBuffer=None): """ Creates a `wx.Bitmap` from the data in dataBuffer. The dataBuffer - parameter must be a Python object that implements the buffer interface, or - is convertable to a buffer object, such as a string, array, etc. The - dataBuffer object is expected to contain a series of RGB bytes and be - width*height*3 bytes long. A buffer object can optionally be supplied for - the image's alpha channel data, and it is expected to be width*height - bytes long. On Windows the RGB values are 'premultiplied' by the alpha - values. (The other platforms appear to already be premultiplying the - alpha.) - - Unlike `wx.ImageFromBuffer` the bitmap created with this function does not - share the memory buffer with the buffer object. This is because the - native pixel buffer format varies on different platforms, and so instead - an efficient as possible copy of the data is made from the buffer objects - to the bitmap's native pixel buffer. For direct access to a bitmap's - pixel buffer see `wx.NativePixelData` and `wx.AlphaPixelData`. + parameter must be a Python object that implements the buffer + interface, such as a string, array, etc. The dataBuffer object is + expected to contain a series of RGB bytes and be width*height*3 + bytes long. A buffer object can optionally be supplied for the + image's alpha channel data, and it is expected to be width*height + bytes long. On Windows the RGB values are 'premultiplied' by the + alpha values. (The other platforms do the multiplication + themselves.) + + Unlike `wx.ImageFromBuffer` the bitmap created with this function + does not share the memory buffer with the buffer object. This is + because the native pixel buffer format varies on different + platforms, and so instead an efficient as possible copy of the + data is made from the buffer objects to the bitmap's native pixel + buffer. For direct access to a bitmap's pixel buffer see + `wx.NativePixelData` and `wx.AlphaPixelData`. :see: `wx.Bitmap`, `wx.BitmapFromBufferRGBA`, `wx.NativePixelData`, `wx.AlphaPixelData`, `wx.ImageFromBuffer` """ - if not isinstance(dataBuffer, buffer): - dataBuffer = buffer(dataBuffer) - if alphaBuffer is not None and not isinstance(alphaBuffer, buffer): - alphaBuffer = buffer(alphaBuffer) if alphaBuffer is not None: return _gdi_._BitmapFromBufferAlpha(width, height, dataBuffer, alphaBuffer) else: @@ -759,25 +756,24 @@ def _BitmapFromBufferRGBA(*args, **kwargs): def BitmapFromBufferRGBA(width, height, dataBuffer): """ Creates a `wx.Bitmap` from the data in dataBuffer. The dataBuffer - parameter must be a Python object that implements the buffer interface, or - is convertable to a buffer object, such as a string, array, etc. The - dataBuffer object is expected to contain a series of RGBA bytes (red, - green, blue and alpha) and be width*height*4 bytes long. On Windows the - RGB values are 'premultiplied' by the alpha values. (The other platforms - appear to already be premultiplying the alpha.) - - Unlike `wx.ImageFromBuffer` the bitmap created with this function does not - share the memory buffer with the buffer object. This is because the - native pixel buffer format varies on different platforms, and so instead - an efficient as possible copy of the data is made from the buffer object - to the bitmap's native pixel buffer. For direct access to a bitmap's - pixel buffer see `wx.NativePixelData` and `wx.AlphaPixelData`. + parameter must be a Python object that implements the buffer + interface, such as a string, array, etc. The dataBuffer object is + expected to contain a series of RGBA bytes (red, green, blue and + alpha) and be width*height*4 bytes long. On Windows the RGB + values are 'premultiplied' by the alpha values. (The other + platforms do the multiplication themselves.) + + Unlike `wx.ImageFromBuffer` the bitmap created with this function + does not share the memory buffer with the buffer object. This is + because the native pixel buffer format varies on different + platforms, and so instead an efficient as possible copy of the + data is made from the buffer object to the bitmap's native pixel + buffer. For direct access to a bitmap's pixel buffer see + `wx.NativePixelData` and `wx.AlphaPixelData`. :see: `wx.Bitmap`, `wx.BitmapFromBuffer`, `wx.NativePixelData`, `wx.AlphaPixelData`, `wx.ImageFromBuffer` """ - if not isinstance(dataBuffer, buffer): - dataBuffer = buffer(dataBuffer) return _gdi_._BitmapFromBufferRGBA(width, height, dataBuffer) class PixelDataBase(object): diff --git a/wxPython/src/gtk/_gdi_wrap.cpp b/wxPython/src/gtk/_gdi_wrap.cpp index 04a530c65b..ac6a4fd75c 100644 --- a/wxPython/src/gtk/_gdi_wrap.cpp +++ b/wxPython/src/gtk/_gdi_wrap.cpp @@ -6680,13 +6680,11 @@ SWIGINTERN PyObject *_wrap__BitmapFromBufferAlpha(PyObject *SWIGUNUSEDPARM(self) } arg2 = static_cast< int >(val2); { - if (obj2 != Py_None) { - if (!PyArg_Parse(obj2, "t#", &arg3, &arg4)) SWIG_fail; - } + if (PyObject_AsReadBuffer(obj2, (const void**)(&arg3), &arg4) == -1) SWIG_fail; } { if (obj3 != Py_None) { - if (!PyArg_Parse(obj3, "t#", &arg5, &arg6)) SWIG_fail; + if (PyObject_AsReadBuffer(obj3, (const void**)(&arg5), &arg6) == -1) SWIG_fail; } } { @@ -6730,9 +6728,7 @@ SWIGINTERN PyObject *_wrap__BitmapFromBuffer(PyObject *SWIGUNUSEDPARM(self), PyO } arg2 = static_cast< int >(val2); { - if (obj2 != Py_None) { - if (!PyArg_Parse(obj2, "t#", &arg3, &arg4)) SWIG_fail; - } + if (PyObject_AsReadBuffer(obj2, (const void**)(&arg3), &arg4) == -1) SWIG_fail; } { result = (wxBitmap *)_BitmapFromBuffer(arg1,arg2,arg3,arg4); @@ -6775,9 +6771,7 @@ SWIGINTERN PyObject *_wrap__BitmapFromBufferRGBA(PyObject *SWIGUNUSEDPARM(self), } arg2 = static_cast< int >(val2); { - if (obj2 != Py_None) { - if (!PyArg_Parse(obj2, "t#", &arg3, &arg4)) SWIG_fail; - } + if (PyObject_AsReadBuffer(obj2, (const void**)(&arg3), &arg4) == -1) SWIG_fail; } { result = (wxBitmap *)_BitmapFromBufferRGBA(arg1,arg2,arg3,arg4); diff --git a/wxPython/src/mac/_core.py b/wxPython/src/mac/_core.py index 837170a76b..3cc6d8209e 100644 --- a/wxPython/src/mac/_core.py +++ b/wxPython/src/mac/_core.py @@ -275,10 +275,6 @@ ID_ZOOM_OUT = _core_.ID_ZOOM_OUT ID_UNDELETE = _core_.ID_UNDELETE ID_REVERT_TO_SAVED = _core_.ID_REVERT_TO_SAVED ID_HIGHEST = _core_.ID_HIGHEST -ACCEL_ALT = _core_.ACCEL_ALT -ACCEL_CTRL = _core_.ACCEL_CTRL -ACCEL_SHIFT = _core_.ACCEL_SHIFT -ACCEL_NORMAL = _core_.ACCEL_NORMAL PD_AUTO_HIDE = _core_.PD_AUTO_HIDE PD_APP_MODAL = _core_.PD_APP_MODAL PD_CAN_ABORT = _core_.PD_CAN_ABORT @@ -3070,12 +3066,11 @@ def _ImageFromBuffer(*args, **kwargs): def ImageFromBuffer(width, height, dataBuffer, alphaBuffer=None): """ Creates a `wx.Image` from the data in dataBuffer. The dataBuffer - parameter must be a Python object that implements the buffer interface, or - is convertable to a buffer object, such as a string, array, etc. The - dataBuffer object is expected to contain a series of RGB bytes and be - width*height*3 bytes long. A buffer object can optionally be supplied for - the image's alpha channel data, and it is expected to be width*height - bytes long. + parameter must be a Python object that implements the buffer interface, + such as a string, array, etc. The dataBuffer object is expected to + contain a series of RGB bytes and be width*height*3 bytes long. A buffer + object can optionally be supplied for the image's alpha channel data, and + it is expected to be width*height bytes long. The wx.Image will be created with its data and alpha pointers initialized to the memory address pointed to by the buffer objects, thus saving the @@ -3093,10 +3088,6 @@ def ImageFromBuffer(width, height, dataBuffer, alphaBuffer=None): the objects used for the data and alpha buffers in a way that would cause them to change size. """ - if not isinstance(dataBuffer, buffer): - dataBuffer = buffer(dataBuffer) - if alphaBuffer is not None and not isinstance(alphaBuffer, buffer): - alphaBuffer = buffer(alphaBuffer) image = _core_._ImageFromBuffer(width, height, dataBuffer, alphaBuffer) image._buffer = dataBuffer image._alpha = alphaBuffer @@ -7461,6 +7452,11 @@ _core_.EventLoopActivator_swigregister(EventLoopActivator) #--------------------------------------------------------------------------- +ACCEL_ALT = _core_.ACCEL_ALT +ACCEL_CTRL = _core_.ACCEL_CTRL +ACCEL_SHIFT = _core_.ACCEL_SHIFT +ACCEL_NORMAL = _core_.ACCEL_NORMAL +ACCEL_CMD = _core_.ACCEL_CMD class AcceleratorEntry(object): """ A class used to define items in an `wx.AcceleratorTable`. wxPython diff --git a/wxPython/src/mac/_core_wrap.cpp b/wxPython/src/mac/_core_wrap.cpp index 6d1c4a0914..ccf9003de4 100644 --- a/wxPython/src/mac/_core_wrap.cpp +++ b/wxPython/src/mac/_core_wrap.cpp @@ -13429,9 +13429,7 @@ SWIGINTERN PyObject *_wrap_new_ImageFromData(PyObject *SWIGUNUSEDPARM(self), PyO } arg2 = static_cast< int >(val2); { - if (obj2 != Py_None) { - if (!PyArg_Parse(obj2, "t#", &arg3, &arg4)) SWIG_fail; - } + if (PyObject_AsReadBuffer(obj2, (const void**)(&arg3), &arg4) == -1) SWIG_fail; } { PyThreadState* __tstate = wxPyBeginAllowThreads(); @@ -13479,13 +13477,11 @@ SWIGINTERN PyObject *_wrap_new_ImageFromDataWithAlpha(PyObject *SWIGUNUSEDPARM(s } arg2 = static_cast< int >(val2); { - if (obj2 != Py_None) { - if (!PyArg_Parse(obj2, "t#", &arg3, &arg4)) SWIG_fail; - } + if (PyObject_AsReadBuffer(obj2, (const void**)(&arg3), &arg4) == -1) SWIG_fail; } { if (obj3 != Py_None) { - if (!PyArg_Parse(obj3, "t#", &arg5, &arg6)) SWIG_fail; + if (PyObject_AsReadBuffer(obj3, (const void**)(&arg5), &arg6) == -1) SWIG_fail; } } { @@ -15508,9 +15504,7 @@ SWIGINTERN PyObject *_wrap_Image_SetData(PyObject *SWIGUNUSEDPARM(self), PyObjec } arg1 = reinterpret_cast< wxImage * >(argp1); { - if (obj1 != Py_None) { - if (!PyArg_Parse(obj1, "t#", &arg2, &arg3)) SWIG_fail; - } + if (PyObject_AsReadBuffer(obj1, (const void**)(&arg2), &arg3) == -1) SWIG_fail; } { PyThreadState* __tstate = wxPyBeginAllowThreads(); @@ -15573,9 +15567,7 @@ SWIGINTERN PyObject *_wrap_Image_SetDataBuffer(PyObject *SWIGUNUSEDPARM(self), P } arg1 = reinterpret_cast< wxImage * >(argp1); { - if (obj1 != Py_None) { - if (!PyArg_Parse(obj1, "t#", &arg2, &arg3)) SWIG_fail; - } + if (PyObject_AsReadBuffer(obj1, (const void**)(&arg2), &arg3) == -1) SWIG_fail; } { PyThreadState* __tstate = wxPyBeginAllowThreads(); @@ -15639,7 +15631,7 @@ SWIGINTERN PyObject *_wrap_Image_SetAlphaData(PyObject *SWIGUNUSEDPARM(self), Py arg1 = reinterpret_cast< wxImage * >(argp1); { if (obj1 != Py_None) { - if (!PyArg_Parse(obj1, "t#", &arg2, &arg3)) SWIG_fail; + if (PyObject_AsReadBuffer(obj1, (const void**)(&arg2), &arg3) == -1) SWIG_fail; } } { @@ -15704,7 +15696,7 @@ SWIGINTERN PyObject *_wrap_Image_SetAlphaBuffer(PyObject *SWIGUNUSEDPARM(self), arg1 = reinterpret_cast< wxImage * >(argp1); { if (obj1 != Py_None) { - if (!PyArg_Parse(obj1, "t#", &arg2, &arg3)) SWIG_fail; + if (PyObject_AsReadBuffer(obj1, (const void**)(&arg2), &arg3) == -1) SWIG_fail; } } { @@ -17081,14 +17073,12 @@ SWIGINTERN PyObject *_wrap__ImageFromBuffer(PyObject *SWIGUNUSEDPARM(self), PyOb } arg2 = static_cast< int >(val2); { - if (obj2 != Py_None) { - if (!PyArg_Parse(obj2, "t#", &arg3, &arg4)) SWIG_fail; - } + if (PyObject_AsReadBuffer(obj2, (const void**)(&arg3), &arg4) == -1) SWIG_fail; } if (obj3) { { if (obj3 != Py_None) { - if (!PyArg_Parse(obj3, "t#", &arg5, &arg6)) SWIG_fail; + if (PyObject_AsReadBuffer(obj3, (const void**)(&arg5), &arg6) == -1) SWIG_fail; } } } @@ -56283,10 +56273,6 @@ SWIGEXPORT void SWIG_init(void) { SWIG_Python_SetConstant(d, "ID_UNDELETE",SWIG_From_int(static_cast< int >(wxID_UNDELETE))); SWIG_Python_SetConstant(d, "ID_REVERT_TO_SAVED",SWIG_From_int(static_cast< int >(wxID_REVERT_TO_SAVED))); SWIG_Python_SetConstant(d, "ID_HIGHEST",SWIG_From_int(static_cast< int >(wxID_HIGHEST))); - SWIG_Python_SetConstant(d, "ACCEL_ALT",SWIG_From_int(static_cast< int >(wxACCEL_ALT))); - SWIG_Python_SetConstant(d, "ACCEL_CTRL",SWIG_From_int(static_cast< int >(wxACCEL_CTRL))); - SWIG_Python_SetConstant(d, "ACCEL_SHIFT",SWIG_From_int(static_cast< int >(wxACCEL_SHIFT))); - SWIG_Python_SetConstant(d, "ACCEL_NORMAL",SWIG_From_int(static_cast< int >(wxACCEL_NORMAL))); SWIG_Python_SetConstant(d, "PD_AUTO_HIDE",SWIG_From_int(static_cast< int >(wxPD_AUTO_HIDE))); SWIG_Python_SetConstant(d, "PD_APP_MODAL",SWIG_From_int(static_cast< int >(wxPD_APP_MODAL))); SWIG_Python_SetConstant(d, "PD_CAN_ABORT",SWIG_From_int(static_cast< int >(wxPD_CAN_ABORT))); @@ -56935,6 +56921,11 @@ SWIGEXPORT void SWIG_init(void) { SWIG_Python_SetConstant(d, "PYAPP_ASSERT_LOG",SWIG_From_int(static_cast< int >(wxPYAPP_ASSERT_LOG))); SWIG_Python_SetConstant(d, "PRINT_WINDOWS",SWIG_From_int(static_cast< int >(wxPRINT_WINDOWS))); SWIG_Python_SetConstant(d, "PRINT_POSTSCRIPT",SWIG_From_int(static_cast< int >(wxPRINT_POSTSCRIPT))); + SWIG_Python_SetConstant(d, "ACCEL_ALT",SWIG_From_int(static_cast< int >(wxACCEL_ALT))); + SWIG_Python_SetConstant(d, "ACCEL_CTRL",SWIG_From_int(static_cast< int >(wxACCEL_CTRL))); + SWIG_Python_SetConstant(d, "ACCEL_SHIFT",SWIG_From_int(static_cast< int >(wxACCEL_SHIFT))); + SWIG_Python_SetConstant(d, "ACCEL_NORMAL",SWIG_From_int(static_cast< int >(wxACCEL_NORMAL))); + SWIG_Python_SetConstant(d, "ACCEL_CMD",SWIG_From_int(static_cast< int >(wxACCEL_CMD))); SWIG_addvarlink(SWIG_globals(),(char*)"NullAcceleratorTable",NullAcceleratorTable_get, NullAcceleratorTable_set); SWIG_addvarlink(SWIG_globals(),(char*)"PanelNameStr",PanelNameStr_get, PanelNameStr_set); SWIG_Python_SetConstant(d, "WINDOW_VARIANT_NORMAL",SWIG_From_int(static_cast< int >(wxWINDOW_VARIANT_NORMAL))); diff --git a/wxPython/src/mac/_gdi.py b/wxPython/src/mac/_gdi.py index e8683448ef..d54219b4b1 100644 --- a/wxPython/src/mac/_gdi.py +++ b/wxPython/src/mac/_gdi.py @@ -728,29 +728,26 @@ def _BitmapFromBuffer(*args, **kwargs): def BitmapFromBuffer(width, height, dataBuffer, alphaBuffer=None): """ Creates a `wx.Bitmap` from the data in dataBuffer. The dataBuffer - parameter must be a Python object that implements the buffer interface, or - is convertable to a buffer object, such as a string, array, etc. The - dataBuffer object is expected to contain a series of RGB bytes and be - width*height*3 bytes long. A buffer object can optionally be supplied for - the image's alpha channel data, and it is expected to be width*height - bytes long. On Windows the RGB values are 'premultiplied' by the alpha - values. (The other platforms appear to already be premultiplying the - alpha.) - - Unlike `wx.ImageFromBuffer` the bitmap created with this function does not - share the memory buffer with the buffer object. This is because the - native pixel buffer format varies on different platforms, and so instead - an efficient as possible copy of the data is made from the buffer objects - to the bitmap's native pixel buffer. For direct access to a bitmap's - pixel buffer see `wx.NativePixelData` and `wx.AlphaPixelData`. + parameter must be a Python object that implements the buffer + interface, such as a string, array, etc. The dataBuffer object is + expected to contain a series of RGB bytes and be width*height*3 + bytes long. A buffer object can optionally be supplied for the + image's alpha channel data, and it is expected to be width*height + bytes long. On Windows the RGB values are 'premultiplied' by the + alpha values. (The other platforms do the multiplication + themselves.) + + Unlike `wx.ImageFromBuffer` the bitmap created with this function + does not share the memory buffer with the buffer object. This is + because the native pixel buffer format varies on different + platforms, and so instead an efficient as possible copy of the + data is made from the buffer objects to the bitmap's native pixel + buffer. For direct access to a bitmap's pixel buffer see + `wx.NativePixelData` and `wx.AlphaPixelData`. :see: `wx.Bitmap`, `wx.BitmapFromBufferRGBA`, `wx.NativePixelData`, `wx.AlphaPixelData`, `wx.ImageFromBuffer` """ - if not isinstance(dataBuffer, buffer): - dataBuffer = buffer(dataBuffer) - if alphaBuffer is not None and not isinstance(alphaBuffer, buffer): - alphaBuffer = buffer(alphaBuffer) if alphaBuffer is not None: return _gdi_._BitmapFromBufferAlpha(width, height, dataBuffer, alphaBuffer) else: @@ -763,25 +760,24 @@ def _BitmapFromBufferRGBA(*args, **kwargs): def BitmapFromBufferRGBA(width, height, dataBuffer): """ Creates a `wx.Bitmap` from the data in dataBuffer. The dataBuffer - parameter must be a Python object that implements the buffer interface, or - is convertable to a buffer object, such as a string, array, etc. The - dataBuffer object is expected to contain a series of RGBA bytes (red, - green, blue and alpha) and be width*height*4 bytes long. On Windows the - RGB values are 'premultiplied' by the alpha values. (The other platforms - appear to already be premultiplying the alpha.) - - Unlike `wx.ImageFromBuffer` the bitmap created with this function does not - share the memory buffer with the buffer object. This is because the - native pixel buffer format varies on different platforms, and so instead - an efficient as possible copy of the data is made from the buffer object - to the bitmap's native pixel buffer. For direct access to a bitmap's - pixel buffer see `wx.NativePixelData` and `wx.AlphaPixelData`. + parameter must be a Python object that implements the buffer + interface, such as a string, array, etc. The dataBuffer object is + expected to contain a series of RGBA bytes (red, green, blue and + alpha) and be width*height*4 bytes long. On Windows the RGB + values are 'premultiplied' by the alpha values. (The other + platforms do the multiplication themselves.) + + Unlike `wx.ImageFromBuffer` the bitmap created with this function + does not share the memory buffer with the buffer object. This is + because the native pixel buffer format varies on different + platforms, and so instead an efficient as possible copy of the + data is made from the buffer object to the bitmap's native pixel + buffer. For direct access to a bitmap's pixel buffer see + `wx.NativePixelData` and `wx.AlphaPixelData`. :see: `wx.Bitmap`, `wx.BitmapFromBuffer`, `wx.NativePixelData`, `wx.AlphaPixelData`, `wx.ImageFromBuffer` """ - if not isinstance(dataBuffer, buffer): - dataBuffer = buffer(dataBuffer) return _gdi_._BitmapFromBufferRGBA(width, height, dataBuffer) class PixelDataBase(object): diff --git a/wxPython/src/mac/_gdi_wrap.cpp b/wxPython/src/mac/_gdi_wrap.cpp index e22f3153a4..613156b444 100644 --- a/wxPython/src/mac/_gdi_wrap.cpp +++ b/wxPython/src/mac/_gdi_wrap.cpp @@ -6722,13 +6722,11 @@ SWIGINTERN PyObject *_wrap__BitmapFromBufferAlpha(PyObject *SWIGUNUSEDPARM(self) } arg2 = static_cast< int >(val2); { - if (obj2 != Py_None) { - if (!PyArg_Parse(obj2, "t#", &arg3, &arg4)) SWIG_fail; - } + if (PyObject_AsReadBuffer(obj2, (const void**)(&arg3), &arg4) == -1) SWIG_fail; } { if (obj3 != Py_None) { - if (!PyArg_Parse(obj3, "t#", &arg5, &arg6)) SWIG_fail; + if (PyObject_AsReadBuffer(obj3, (const void**)(&arg5), &arg6) == -1) SWIG_fail; } } { @@ -6772,9 +6770,7 @@ SWIGINTERN PyObject *_wrap__BitmapFromBuffer(PyObject *SWIGUNUSEDPARM(self), PyO } arg2 = static_cast< int >(val2); { - if (obj2 != Py_None) { - if (!PyArg_Parse(obj2, "t#", &arg3, &arg4)) SWIG_fail; - } + if (PyObject_AsReadBuffer(obj2, (const void**)(&arg3), &arg4) == -1) SWIG_fail; } { result = (wxBitmap *)_BitmapFromBuffer(arg1,arg2,arg3,arg4); @@ -6817,9 +6813,7 @@ SWIGINTERN PyObject *_wrap__BitmapFromBufferRGBA(PyObject *SWIGUNUSEDPARM(self), } arg2 = static_cast< int >(val2); { - if (obj2 != Py_None) { - if (!PyArg_Parse(obj2, "t#", &arg3, &arg4)) SWIG_fail; - } + if (PyObject_AsReadBuffer(obj2, (const void**)(&arg3), &arg4) == -1) SWIG_fail; } { result = (wxBitmap *)_BitmapFromBufferRGBA(arg1,arg2,arg3,arg4); diff --git a/wxPython/src/msw/_core.py b/wxPython/src/msw/_core.py index 0eabd054bb..5daca2919f 100644 --- a/wxPython/src/msw/_core.py +++ b/wxPython/src/msw/_core.py @@ -275,10 +275,6 @@ ID_ZOOM_OUT = _core_.ID_ZOOM_OUT ID_UNDELETE = _core_.ID_UNDELETE ID_REVERT_TO_SAVED = _core_.ID_REVERT_TO_SAVED ID_HIGHEST = _core_.ID_HIGHEST -ACCEL_ALT = _core_.ACCEL_ALT -ACCEL_CTRL = _core_.ACCEL_CTRL -ACCEL_SHIFT = _core_.ACCEL_SHIFT -ACCEL_NORMAL = _core_.ACCEL_NORMAL PD_AUTO_HIDE = _core_.PD_AUTO_HIDE PD_APP_MODAL = _core_.PD_APP_MODAL PD_CAN_ABORT = _core_.PD_CAN_ABORT @@ -3070,12 +3066,11 @@ def _ImageFromBuffer(*args, **kwargs): def ImageFromBuffer(width, height, dataBuffer, alphaBuffer=None): """ Creates a `wx.Image` from the data in dataBuffer. The dataBuffer - parameter must be a Python object that implements the buffer interface, or - is convertable to a buffer object, such as a string, array, etc. The - dataBuffer object is expected to contain a series of RGB bytes and be - width*height*3 bytes long. A buffer object can optionally be supplied for - the image's alpha channel data, and it is expected to be width*height - bytes long. + parameter must be a Python object that implements the buffer interface, + such as a string, array, etc. The dataBuffer object is expected to + contain a series of RGB bytes and be width*height*3 bytes long. A buffer + object can optionally be supplied for the image's alpha channel data, and + it is expected to be width*height bytes long. The wx.Image will be created with its data and alpha pointers initialized to the memory address pointed to by the buffer objects, thus saving the @@ -3093,10 +3088,6 @@ def ImageFromBuffer(width, height, dataBuffer, alphaBuffer=None): the objects used for the data and alpha buffers in a way that would cause them to change size. """ - if not isinstance(dataBuffer, buffer): - dataBuffer = buffer(dataBuffer) - if alphaBuffer is not None and not isinstance(alphaBuffer, buffer): - alphaBuffer = buffer(alphaBuffer) image = _core_._ImageFromBuffer(width, height, dataBuffer, alphaBuffer) image._buffer = dataBuffer image._alpha = alphaBuffer @@ -7461,6 +7452,11 @@ _core_.EventLoopActivator_swigregister(EventLoopActivator) #--------------------------------------------------------------------------- +ACCEL_ALT = _core_.ACCEL_ALT +ACCEL_CTRL = _core_.ACCEL_CTRL +ACCEL_SHIFT = _core_.ACCEL_SHIFT +ACCEL_NORMAL = _core_.ACCEL_NORMAL +ACCEL_CMD = _core_.ACCEL_CMD class AcceleratorEntry(object): """ A class used to define items in an `wx.AcceleratorTable`. wxPython diff --git a/wxPython/src/msw/_core_wrap.cpp b/wxPython/src/msw/_core_wrap.cpp index 27e6fda8b9..3b3aa82146 100644 --- a/wxPython/src/msw/_core_wrap.cpp +++ b/wxPython/src/msw/_core_wrap.cpp @@ -13414,9 +13414,7 @@ SWIGINTERN PyObject *_wrap_new_ImageFromData(PyObject *SWIGUNUSEDPARM(self), PyO } arg2 = static_cast< int >(val2); { - if (obj2 != Py_None) { - if (!PyArg_Parse(obj2, "t#", &arg3, &arg4)) SWIG_fail; - } + if (PyObject_AsReadBuffer(obj2, (const void**)(&arg3), &arg4) == -1) SWIG_fail; } { PyThreadState* __tstate = wxPyBeginAllowThreads(); @@ -13464,13 +13462,11 @@ SWIGINTERN PyObject *_wrap_new_ImageFromDataWithAlpha(PyObject *SWIGUNUSEDPARM(s } arg2 = static_cast< int >(val2); { - if (obj2 != Py_None) { - if (!PyArg_Parse(obj2, "t#", &arg3, &arg4)) SWIG_fail; - } + if (PyObject_AsReadBuffer(obj2, (const void**)(&arg3), &arg4) == -1) SWIG_fail; } { if (obj3 != Py_None) { - if (!PyArg_Parse(obj3, "t#", &arg5, &arg6)) SWIG_fail; + if (PyObject_AsReadBuffer(obj3, (const void**)(&arg5), &arg6) == -1) SWIG_fail; } } { @@ -15493,9 +15489,7 @@ SWIGINTERN PyObject *_wrap_Image_SetData(PyObject *SWIGUNUSEDPARM(self), PyObjec } arg1 = reinterpret_cast< wxImage * >(argp1); { - if (obj1 != Py_None) { - if (!PyArg_Parse(obj1, "t#", &arg2, &arg3)) SWIG_fail; - } + if (PyObject_AsReadBuffer(obj1, (const void**)(&arg2), &arg3) == -1) SWIG_fail; } { PyThreadState* __tstate = wxPyBeginAllowThreads(); @@ -15558,9 +15552,7 @@ SWIGINTERN PyObject *_wrap_Image_SetDataBuffer(PyObject *SWIGUNUSEDPARM(self), P } arg1 = reinterpret_cast< wxImage * >(argp1); { - if (obj1 != Py_None) { - if (!PyArg_Parse(obj1, "t#", &arg2, &arg3)) SWIG_fail; - } + if (PyObject_AsReadBuffer(obj1, (const void**)(&arg2), &arg3) == -1) SWIG_fail; } { PyThreadState* __tstate = wxPyBeginAllowThreads(); @@ -15624,7 +15616,7 @@ SWIGINTERN PyObject *_wrap_Image_SetAlphaData(PyObject *SWIGUNUSEDPARM(self), Py arg1 = reinterpret_cast< wxImage * >(argp1); { if (obj1 != Py_None) { - if (!PyArg_Parse(obj1, "t#", &arg2, &arg3)) SWIG_fail; + if (PyObject_AsReadBuffer(obj1, (const void**)(&arg2), &arg3) == -1) SWIG_fail; } } { @@ -15689,7 +15681,7 @@ SWIGINTERN PyObject *_wrap_Image_SetAlphaBuffer(PyObject *SWIGUNUSEDPARM(self), arg1 = reinterpret_cast< wxImage * >(argp1); { if (obj1 != Py_None) { - if (!PyArg_Parse(obj1, "t#", &arg2, &arg3)) SWIG_fail; + if (PyObject_AsReadBuffer(obj1, (const void**)(&arg2), &arg3) == -1) SWIG_fail; } } { @@ -17066,14 +17058,12 @@ SWIGINTERN PyObject *_wrap__ImageFromBuffer(PyObject *SWIGUNUSEDPARM(self), PyOb } arg2 = static_cast< int >(val2); { - if (obj2 != Py_None) { - if (!PyArg_Parse(obj2, "t#", &arg3, &arg4)) SWIG_fail; - } + if (PyObject_AsReadBuffer(obj2, (const void**)(&arg3), &arg4) == -1) SWIG_fail; } if (obj3) { { if (obj3 != Py_None) { - if (!PyArg_Parse(obj3, "t#", &arg5, &arg6)) SWIG_fail; + if (PyObject_AsReadBuffer(obj3, (const void**)(&arg5), &arg6) == -1) SWIG_fail; } } } @@ -56310,10 +56300,6 @@ SWIGEXPORT void SWIG_init(void) { SWIG_Python_SetConstant(d, "ID_UNDELETE",SWIG_From_int(static_cast< int >(wxID_UNDELETE))); SWIG_Python_SetConstant(d, "ID_REVERT_TO_SAVED",SWIG_From_int(static_cast< int >(wxID_REVERT_TO_SAVED))); SWIG_Python_SetConstant(d, "ID_HIGHEST",SWIG_From_int(static_cast< int >(wxID_HIGHEST))); - SWIG_Python_SetConstant(d, "ACCEL_ALT",SWIG_From_int(static_cast< int >(wxACCEL_ALT))); - SWIG_Python_SetConstant(d, "ACCEL_CTRL",SWIG_From_int(static_cast< int >(wxACCEL_CTRL))); - SWIG_Python_SetConstant(d, "ACCEL_SHIFT",SWIG_From_int(static_cast< int >(wxACCEL_SHIFT))); - SWIG_Python_SetConstant(d, "ACCEL_NORMAL",SWIG_From_int(static_cast< int >(wxACCEL_NORMAL))); SWIG_Python_SetConstant(d, "PD_AUTO_HIDE",SWIG_From_int(static_cast< int >(wxPD_AUTO_HIDE))); SWIG_Python_SetConstant(d, "PD_APP_MODAL",SWIG_From_int(static_cast< int >(wxPD_APP_MODAL))); SWIG_Python_SetConstant(d, "PD_CAN_ABORT",SWIG_From_int(static_cast< int >(wxPD_CAN_ABORT))); @@ -56962,6 +56948,11 @@ SWIGEXPORT void SWIG_init(void) { SWIG_Python_SetConstant(d, "PYAPP_ASSERT_LOG",SWIG_From_int(static_cast< int >(wxPYAPP_ASSERT_LOG))); SWIG_Python_SetConstant(d, "PRINT_WINDOWS",SWIG_From_int(static_cast< int >(wxPRINT_WINDOWS))); SWIG_Python_SetConstant(d, "PRINT_POSTSCRIPT",SWIG_From_int(static_cast< int >(wxPRINT_POSTSCRIPT))); + SWIG_Python_SetConstant(d, "ACCEL_ALT",SWIG_From_int(static_cast< int >(wxACCEL_ALT))); + SWIG_Python_SetConstant(d, "ACCEL_CTRL",SWIG_From_int(static_cast< int >(wxACCEL_CTRL))); + SWIG_Python_SetConstant(d, "ACCEL_SHIFT",SWIG_From_int(static_cast< int >(wxACCEL_SHIFT))); + SWIG_Python_SetConstant(d, "ACCEL_NORMAL",SWIG_From_int(static_cast< int >(wxACCEL_NORMAL))); + SWIG_Python_SetConstant(d, "ACCEL_CMD",SWIG_From_int(static_cast< int >(wxACCEL_CMD))); SWIG_addvarlink(SWIG_globals(),(char*)"NullAcceleratorTable",NullAcceleratorTable_get, NullAcceleratorTable_set); SWIG_addvarlink(SWIG_globals(),(char*)"PanelNameStr",PanelNameStr_get, PanelNameStr_set); SWIG_Python_SetConstant(d, "WINDOW_VARIANT_NORMAL",SWIG_From_int(static_cast< int >(wxWINDOW_VARIANT_NORMAL))); diff --git a/wxPython/src/msw/_gdi.py b/wxPython/src/msw/_gdi.py index 9f1e417d97..22bea127eb 100644 --- a/wxPython/src/msw/_gdi.py +++ b/wxPython/src/msw/_gdi.py @@ -748,29 +748,26 @@ def _BitmapFromBuffer(*args, **kwargs): def BitmapFromBuffer(width, height, dataBuffer, alphaBuffer=None): """ Creates a `wx.Bitmap` from the data in dataBuffer. The dataBuffer - parameter must be a Python object that implements the buffer interface, or - is convertable to a buffer object, such as a string, array, etc. The - dataBuffer object is expected to contain a series of RGB bytes and be - width*height*3 bytes long. A buffer object can optionally be supplied for - the image's alpha channel data, and it is expected to be width*height - bytes long. On Windows the RGB values are 'premultiplied' by the alpha - values. (The other platforms appear to already be premultiplying the - alpha.) - - Unlike `wx.ImageFromBuffer` the bitmap created with this function does not - share the memory buffer with the buffer object. This is because the - native pixel buffer format varies on different platforms, and so instead - an efficient as possible copy of the data is made from the buffer objects - to the bitmap's native pixel buffer. For direct access to a bitmap's - pixel buffer see `wx.NativePixelData` and `wx.AlphaPixelData`. + parameter must be a Python object that implements the buffer + interface, such as a string, array, etc. The dataBuffer object is + expected to contain a series of RGB bytes and be width*height*3 + bytes long. A buffer object can optionally be supplied for the + image's alpha channel data, and it is expected to be width*height + bytes long. On Windows the RGB values are 'premultiplied' by the + alpha values. (The other platforms do the multiplication + themselves.) + + Unlike `wx.ImageFromBuffer` the bitmap created with this function + does not share the memory buffer with the buffer object. This is + because the native pixel buffer format varies on different + platforms, and so instead an efficient as possible copy of the + data is made from the buffer objects to the bitmap's native pixel + buffer. For direct access to a bitmap's pixel buffer see + `wx.NativePixelData` and `wx.AlphaPixelData`. :see: `wx.Bitmap`, `wx.BitmapFromBufferRGBA`, `wx.NativePixelData`, `wx.AlphaPixelData`, `wx.ImageFromBuffer` """ - if not isinstance(dataBuffer, buffer): - dataBuffer = buffer(dataBuffer) - if alphaBuffer is not None and not isinstance(alphaBuffer, buffer): - alphaBuffer = buffer(alphaBuffer) if alphaBuffer is not None: return _gdi_._BitmapFromBufferAlpha(width, height, dataBuffer, alphaBuffer) else: @@ -783,25 +780,24 @@ def _BitmapFromBufferRGBA(*args, **kwargs): def BitmapFromBufferRGBA(width, height, dataBuffer): """ Creates a `wx.Bitmap` from the data in dataBuffer. The dataBuffer - parameter must be a Python object that implements the buffer interface, or - is convertable to a buffer object, such as a string, array, etc. The - dataBuffer object is expected to contain a series of RGBA bytes (red, - green, blue and alpha) and be width*height*4 bytes long. On Windows the - RGB values are 'premultiplied' by the alpha values. (The other platforms - appear to already be premultiplying the alpha.) - - Unlike `wx.ImageFromBuffer` the bitmap created with this function does not - share the memory buffer with the buffer object. This is because the - native pixel buffer format varies on different platforms, and so instead - an efficient as possible copy of the data is made from the buffer object - to the bitmap's native pixel buffer. For direct access to a bitmap's - pixel buffer see `wx.NativePixelData` and `wx.AlphaPixelData`. + parameter must be a Python object that implements the buffer + interface, such as a string, array, etc. The dataBuffer object is + expected to contain a series of RGBA bytes (red, green, blue and + alpha) and be width*height*4 bytes long. On Windows the RGB + values are 'premultiplied' by the alpha values. (The other + platforms do the multiplication themselves.) + + Unlike `wx.ImageFromBuffer` the bitmap created with this function + does not share the memory buffer with the buffer object. This is + because the native pixel buffer format varies on different + platforms, and so instead an efficient as possible copy of the + data is made from the buffer object to the bitmap's native pixel + buffer. For direct access to a bitmap's pixel buffer see + `wx.NativePixelData` and `wx.AlphaPixelData`. :see: `wx.Bitmap`, `wx.BitmapFromBuffer`, `wx.NativePixelData`, `wx.AlphaPixelData`, `wx.ImageFromBuffer` """ - if not isinstance(dataBuffer, buffer): - dataBuffer = buffer(dataBuffer) return _gdi_._BitmapFromBufferRGBA(width, height, dataBuffer) class PixelDataBase(object): diff --git a/wxPython/src/msw/_gdi_wrap.cpp b/wxPython/src/msw/_gdi_wrap.cpp index ec1eab7b19..44d9bdcc92 100644 --- a/wxPython/src/msw/_gdi_wrap.cpp +++ b/wxPython/src/msw/_gdi_wrap.cpp @@ -6874,13 +6874,11 @@ SWIGINTERN PyObject *_wrap__BitmapFromBufferAlpha(PyObject *SWIGUNUSEDPARM(self) } arg2 = static_cast< int >(val2); { - if (obj2 != Py_None) { - if (!PyArg_Parse(obj2, "t#", &arg3, &arg4)) SWIG_fail; - } + if (PyObject_AsReadBuffer(obj2, (const void**)(&arg3), &arg4) == -1) SWIG_fail; } { if (obj3 != Py_None) { - if (!PyArg_Parse(obj3, "t#", &arg5, &arg6)) SWIG_fail; + if (PyObject_AsReadBuffer(obj3, (const void**)(&arg5), &arg6) == -1) SWIG_fail; } } { @@ -6924,9 +6922,7 @@ SWIGINTERN PyObject *_wrap__BitmapFromBuffer(PyObject *SWIGUNUSEDPARM(self), PyO } arg2 = static_cast< int >(val2); { - if (obj2 != Py_None) { - if (!PyArg_Parse(obj2, "t#", &arg3, &arg4)) SWIG_fail; - } + if (PyObject_AsReadBuffer(obj2, (const void**)(&arg3), &arg4) == -1) SWIG_fail; } { result = (wxBitmap *)_BitmapFromBuffer(arg1,arg2,arg3,arg4); @@ -6969,9 +6965,7 @@ SWIGINTERN PyObject *_wrap__BitmapFromBufferRGBA(PyObject *SWIGUNUSEDPARM(self), } arg2 = static_cast< int >(val2); { - if (obj2 != Py_None) { - if (!PyArg_Parse(obj2, "t#", &arg3, &arg4)) SWIG_fail; - } + if (PyObject_AsReadBuffer(obj2, (const void**)(&arg3), &arg4) == -1) SWIG_fail; } { result = (wxBitmap *)_BitmapFromBufferRGBA(arg1,arg2,arg3,arg4); -- 2.47.2