[wxPython-users] Does wx support DIB bitmap?

甜瓜 littlesweetmelon at gmail.com
Mon Jun 4 18:21:09 PDT 2007


Thank you Chirs and Robin. I think numpy is a good way.

2007/6/5, Robin Dunn <robin at alldunn.com>:
> 甜瓜 wrote:
> > I encounter a big problem in drawing bitmap to a wx.Window. The bitmap
> > data is not in the form of RGB-8byte. The pixel is 64K color which
> > Rmax, Gmax, Bmax == (31, 63, 31). For this pixel format, I can easily
> > create a DIB by using pure Win32 API and then Bitblt to a window area.
> > However, it seems that wx does not support DIB and it does not give
> > user a opportunity to setup pixel format (eg: Red bitshift, etc.).
> > Maybe DIB is only used by MS Window, while other platforms use
> > different methods to deal with bitmap rendering. So, what is the best
> > way to draw a bitmap from buffer platform-independently?
> > The required rendering speed is about 15-20 fps for the area
> > (1024x768). The additional buffer-copying is the most I concerned. Is
> > this problem the bottle-neck of my rendering program in python? How to
> > suppress this operation? Eg: the bitmap data is not at the beginning
> > of the buffer, but in the middle:
> >
> > wx.BitmapForBuffer(w, h, buf[start:end] )  # @_@ may be a big copy...
>
> wxBitmap on Windows does use DIB internally but since it is a platform
> specific implementation detail it is not exposed to the wxBitmap API.
> There is another class that can be used, but I didn't see much need to
> expose it to Python since it is Windows only and there are other ways to
> handle it.
>
> A couple options for your situation come to mind:
>
> * Put your data in a numpy buffer and manipulate that into a RGB byte
> format and pass the result to wx.BitmapFromBuffer
>
> * Use the raw bitmap access methods and massage the data into the right
> ranges yourself, building the bitmap as you go.  See RawBitmapAccess.py
> in the demo.   This one may be easier to understand, but will surely be
> lots slower than doing the math in a numpy array.
>
>
> --
> Robin Dunn
> Software Craftsman
> http://wxPython.org  Java give you jitters?  Relax with wxPython!
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: wxPython-users-unsubscribe at lists.wxwidgets.org
> For additional commands, e-mail: wxPython-users-help at lists.wxwidgets.org
>
>


More information about the wxpython-users mailing list