Now that the typemap is handling buffer-compatible objects correctly
we can drop wrapping the parameters in a buffer() git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@40912 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
@@ -416,29 +416,26 @@ the ``type`` parameter.", "");
|
|||||||
def BitmapFromBuffer(width, height, dataBuffer, alphaBuffer=None):
|
def BitmapFromBuffer(width, height, dataBuffer, alphaBuffer=None):
|
||||||
"""
|
"""
|
||||||
Creates a `wx.Bitmap` from the data in dataBuffer. The dataBuffer
|
Creates a `wx.Bitmap` from the data in dataBuffer. The dataBuffer
|
||||||
parameter must be a Python object that implements the buffer interface, or
|
parameter must be a Python object that implements the buffer
|
||||||
is convertable to a buffer object, such as a string, array, etc. The
|
interface, such as a string, array, etc. The dataBuffer object is
|
||||||
dataBuffer object is expected to contain a series of RGB bytes and be
|
expected to contain a series of RGB bytes and be width*height*3
|
||||||
width*height*3 bytes long. A buffer object can optionally be supplied for
|
bytes long. A buffer object can optionally be supplied for the
|
||||||
the image's alpha channel data, and it is expected to be width*height
|
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
|
bytes long. On Windows the RGB values are 'premultiplied' by the
|
||||||
values. (The other platforms appear to already be premultiplying the
|
alpha values. (The other platforms do the multiplication
|
||||||
alpha.)
|
themselves.)
|
||||||
|
|
||||||
Unlike `wx.ImageFromBuffer` the bitmap created with this function does not
|
Unlike `wx.ImageFromBuffer` the bitmap created with this function
|
||||||
share the memory buffer with the buffer object. This is because the
|
does not share the memory buffer with the buffer object. This is
|
||||||
native pixel buffer format varies on different platforms, and so instead
|
because the native pixel buffer format varies on different
|
||||||
an efficient as possible copy of the data is made from the buffer objects
|
platforms, and so instead an efficient as possible copy of the
|
||||||
to the bitmap's native pixel buffer. For direct access to a bitmap's
|
data is made from the buffer objects to the bitmap's native pixel
|
||||||
pixel buffer see `wx.NativePixelData` and `wx.AlphaPixelData`.
|
buffer. For direct access to a bitmap's pixel buffer see
|
||||||
|
`wx.NativePixelData` and `wx.AlphaPixelData`.
|
||||||
|
|
||||||
:see: `wx.Bitmap`, `wx.BitmapFromBufferRGBA`, `wx.NativePixelData`,
|
:see: `wx.Bitmap`, `wx.BitmapFromBufferRGBA`, `wx.NativePixelData`,
|
||||||
`wx.AlphaPixelData`, `wx.ImageFromBuffer`
|
`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:
|
if alphaBuffer is not None:
|
||||||
return _gdi_._BitmapFromBufferAlpha(width, height, dataBuffer, alphaBuffer)
|
return _gdi_._BitmapFromBufferAlpha(width, height, dataBuffer, alphaBuffer)
|
||||||
else:
|
else:
|
||||||
@@ -488,25 +485,24 @@ def BitmapFromBuffer(width, height, dataBuffer, alphaBuffer=None):
|
|||||||
def BitmapFromBufferRGBA(width, height, dataBuffer):
|
def BitmapFromBufferRGBA(width, height, dataBuffer):
|
||||||
"""
|
"""
|
||||||
Creates a `wx.Bitmap` from the data in dataBuffer. The dataBuffer
|
Creates a `wx.Bitmap` from the data in dataBuffer. The dataBuffer
|
||||||
parameter must be a Python object that implements the buffer interface, or
|
parameter must be a Python object that implements the buffer
|
||||||
is convertable to a buffer object, such as a string, array, etc. The
|
interface, such as a string, array, etc. The dataBuffer object is
|
||||||
dataBuffer object is expected to contain a series of RGBA bytes (red,
|
expected to contain a series of RGBA bytes (red, green, blue and
|
||||||
green, blue and alpha) and be width*height*4 bytes long. On Windows the
|
alpha) and be width*height*4 bytes long. On Windows the RGB
|
||||||
RGB values are 'premultiplied' by the alpha values. (The other platforms
|
values are 'premultiplied' by the alpha values. (The other
|
||||||
appear to already be premultiplying the alpha.)
|
platforms do the multiplication themselves.)
|
||||||
|
|
||||||
Unlike `wx.ImageFromBuffer` the bitmap created with this function does not
|
Unlike `wx.ImageFromBuffer` the bitmap created with this function
|
||||||
share the memory buffer with the buffer object. This is because the
|
does not share the memory buffer with the buffer object. This is
|
||||||
native pixel buffer format varies on different platforms, and so instead
|
because the native pixel buffer format varies on different
|
||||||
an efficient as possible copy of the data is made from the buffer object
|
platforms, and so instead an efficient as possible copy of the
|
||||||
to the bitmap's native pixel buffer. For direct access to a bitmap's
|
data is made from the buffer object to the bitmap's native pixel
|
||||||
pixel buffer see `wx.NativePixelData` and `wx.AlphaPixelData`.
|
buffer. For direct access to a bitmap's pixel buffer see
|
||||||
|
`wx.NativePixelData` and `wx.AlphaPixelData`.
|
||||||
|
|
||||||
:see: `wx.Bitmap`, `wx.BitmapFromBuffer`, `wx.NativePixelData`,
|
:see: `wx.Bitmap`, `wx.BitmapFromBuffer`, `wx.NativePixelData`,
|
||||||
`wx.AlphaPixelData`, `wx.ImageFromBuffer`
|
`wx.AlphaPixelData`, `wx.ImageFromBuffer`
|
||||||
"""
|
"""
|
||||||
if not isinstance(dataBuffer, buffer):
|
|
||||||
dataBuffer = buffer(dataBuffer)
|
|
||||||
return _gdi_._BitmapFromBufferRGBA(width, height, dataBuffer)
|
return _gdi_._BitmapFromBufferRGBA(width, height, dataBuffer)
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -637,7 +633,7 @@ public:
|
|||||||
// NOTE: For now I'm not wrapping the Red, Green, Blue and Alpha functions
|
// NOTE: For now I'm not wrapping the Red, Green, Blue and Alpha functions
|
||||||
// because I can't hide the premultiplying needed on wxMSW if only the
|
// because I can't hide the premultiplying needed on wxMSW if only the
|
||||||
// individual components are wrapped. Instead I've added the Set and Get
|
// individual components are wrapped. Instead I've added the Set and Get
|
||||||
// functions and put the puemultiplying in there.
|
// functions and put the premultiplying in there.
|
||||||
|
|
||||||
// %extend {
|
// %extend {
|
||||||
// byte _get_Red() { return self->Red(); }
|
// byte _get_Red() { return self->Red(); }
|
||||||
|
@@ -1017,12 +1017,11 @@ range -1.0..1.0 where -1.0 is -360 degrees and 1.0 is 360 degrees", "");
|
|||||||
def ImageFromBuffer(width, height, dataBuffer, alphaBuffer=None):
|
def ImageFromBuffer(width, height, dataBuffer, alphaBuffer=None):
|
||||||
"""
|
"""
|
||||||
Creates a `wx.Image` from the data in dataBuffer. The dataBuffer
|
Creates a `wx.Image` from the data in dataBuffer. The dataBuffer
|
||||||
parameter must be a Python object that implements the buffer interface, or
|
parameter must be a Python object that implements the buffer interface,
|
||||||
is convertable to a buffer object, such as a string, array, etc. The
|
such as a string, array, etc. The dataBuffer object is expected to
|
||||||
dataBuffer object is expected to contain a series of RGB bytes and be
|
contain a series of RGB bytes and be width*height*3 bytes long. A buffer
|
||||||
width*height*3 bytes long. A buffer object can optionally be supplied for
|
object can optionally be supplied for the image's alpha channel data, and
|
||||||
the image's alpha channel data, and it is expected to be width*height
|
it is expected to be width*height bytes long.
|
||||||
bytes long.
|
|
||||||
|
|
||||||
The wx.Image will be created with its data and alpha pointers initialized
|
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
|
to the memory address pointed to by the buffer objects, thus saving the
|
||||||
@@ -1040,10 +1039,6 @@ def ImageFromBuffer(width, height, dataBuffer, alphaBuffer=None):
|
|||||||
the objects used for the data and alpha buffers in a way that would cause
|
the objects used for the data and alpha buffers in a way that would cause
|
||||||
them to change size.
|
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 = _core_._ImageFromBuffer(width, height, dataBuffer, alphaBuffer)
|
||||||
image._buffer = dataBuffer
|
image._buffer = dataBuffer
|
||||||
image._alpha = alphaBuffer
|
image._alpha = alphaBuffer
|
||||||
|
Reference in New Issue
Block a user