Hello,
I having trouble getting strides to work in the following snippet:
a = wx.EmptyBitmap(dst.width,dst.height,24)
a.CopyFromBuffer(dst.data_as_string(),
format=wx.BitmapBufferFormat_RGB,
stride=dst.widthStep)
dst is an IplImage from opencv, depending on the image size it may
have a different stride (widthStep) than the actual image width. Any
hints on how to get this to work?
Thanks
Andrew
The stride is only used with the wxBitmapBufferFormat_RGB32 and wxBitmapBufferFormat_ARGB32 formats. For reference the C code that gets called to do the copy is located at this link:
As seen there the _RGB and _RGBA formats are expected to be very simple stream of bytes, and the _RGB32 and _ARGB32 formats are there mainly because of Cairo compatibility. If what you need to convert can't be pounded into one of those formats then perhaps we can add other formats...
···
On 6/11/10 12:43 PM, andrew wrote:
Hello,
I having trouble getting strides to work in the following snippet:
a = wx.EmptyBitmap(dst.width,dst.height,24)
a.CopyFromBuffer(dst.data_as_string(),
format=wx.BitmapBufferFormat_RGB,
stride=dst.widthStep)
dst is an IplImage from opencv, depending on the image size it may
have a different stride (widthStep) than the actual image width. Any
hints on how to get this to work?
If what you need to convert can't be pounded into one of those formats then perhaps we can add other formats...
I'd use numpy to convert, it's very flexible about this sort of thing, -- unless copying the data is going to kill you.
-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
Thanks for the reply’s Robin and Chris. I was able to get strides to work with the RGB32 mode. Numpy does work (as does PIL) but they are quite a bit slower than OpenCV and I am trying to get the fasted conversion to a bitmap for display.
Thanks
Andrew