Hi, I've been searching for 3-4 days, on whether wx.Bitmap can share a
pixel buffer with wx.Image, to no avail. I came across
wx.NativePixelData but am not sure whether it can somehow be used with
wx.Image.SetData to associate the wx.Bitmap buffer.
···
--
I am a novice at python(scipy/numpy/wxpython) but am familiar with
wxwidgets in C++. The app i'm building is for Computational Neuro.-
Vision. Specs:
windows vista-32;
python version 2.5.2;
wxpython - 2.8-msw;
wxwidgets(C++) - 2.8.7;
--
MyApp: For the same buffer data, I require the functionality of
wxDC(via wxMemoryDC) and the SetPixel from wxImage. The reason for the
latter
is that I copy & zoom from a loaded image file into the buffer and it
seems way faster to use SetPixel(x,y,colour) than to use the
combination SetPen/DrawPoint
--
MyCode: currently uses ImageFromBitmap, BitmapFromImage
and have used ConvertTo{Image,Bitmap}, to convert back and forth. For
example:
- I store a bitmap
- convert to image to use setPixel
- copy back to bitmap
- use memoryDC
OR
- I store a image
- use setPixel
- convert to bitmap to use DC
- copy back to image
--
Note: I achieve the effects I desire, but i'm not sure if there are
memory leaks, resource hogging, or unnecessary allocation calls, by
either method converting back and forth using ##From## or
ConvertTo##.
I'm not even sure if i need to call "del" when the buffer is resized
from loading a different image or when the zoom size of single pixel
is different.
I understand the consequence of sharing buffers, in that the class
creating the data must exist longer in memory than the one that just
accesses the buffer.
Any help would be much appreciated, thank you for reading
Jack