Ray Pasco wrote:
I'm confused about the difference (or sameness) on the documentation:
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, such as a string, array, etc."
So far, so good. Now:
ImageFromDataWithAlpha(width, height, data, alpha)
"Construct an Image from a buffer of RGB bytes with an Alpha channel. Accepts either a string or a buffer object holding the data..."
OK, ImageFromDataWithAlpha() accepts only these mysterious "buffers": "Python object that implements the buffer interface, such as a string, array, etc."
What's the difference ?
The idea of a Buffer object is that C/C++ code can access the data pointer directly, rather than making a copy. The trick with that is that you need to make sure the data isn't deleted yourself.
So I guess that ImageFromBuffer doesn't copy the data, and ImageFromData...() does.
Th point of adding ImageFromBuffer...() is that you can grab data from ANY buffer object (lke a numpy array) without knowing anything else about the object, of doing any uneccesary copying. Before Robin added that, you need to copy a numpy array to a string, then the string to the Image, so two copies, rather than potentially zero copies.
NOTE that I'm not entirely sure ImageFromBuffer doesn't copy at all == I've tested it, but don't remember the results.
If it doesn't, then you can do cool things like create a wxImage from a numpy array, then change the array, and the wxImage will have changed as well.
I know wxBitmapFromBuffer does copy.
What are the RGB organizations ?
RGBRGBRGBRGB
for a 3x2 image (all in a row, though)
What's a Python "buffer" ? I can't find documentation for this.
-Chris
···
--
Christopher Barker, Ph.D.
Oceanographer
Emergency Response Division
NOAA/NOS/OR&R (206) 526-6959 voice
7600 Sand Point Way NE (206) 526-6329 fax
Seattle, WA 98115 (206) 526-6317 main reception
Chris.Barker@noaa.gov