wxBitmapFromBits example?

I'm a bit of a wxNewbie, and are currently having fun trying to make random
midpoint displacement fractals. :slight_smile:
Painting out a bitmap from data is pretty slow, so I'd like to use
wxBitmapFromBits instead, but I can't get it to work. Does somebody have a
working example? I have searched the net, but can't find anything...

It typically crashes hard, or it creates a bitmap object that when I try to
select it into a DC so I can blit it, I get an assertion failure telling me
it couldn't select the bitmap. [Helpful error messages are always nice...
:)]

Any help welcome.

Lennart Regebro wrote:

I'm a bit of a wxNewbie, and are currently having fun trying to make random
midpoint displacement fractals. :slight_smile:
Painting out a bitmap from data is pretty slow, so I'd like to use
wxBitmapFromBits instead, but I can't get it to work. Does somebody have a
working example? I have searched the net, but can't find anything...

wxBitmapFromBits has so many platform specific permutations that I've never really taken the time to figure it out. I dont' think it is ever really used (even in C++) anyway.

There are some other options. You can create and manipulate your images in PIL and then convert to a wxImage and then a wxBitmap for display. You shoul dbe able to find some examples of this on the Net. Another option is to create an empty wxImage with wxEmptyImage(width, height) and then call it's GetDataBuffer() method. That will give you a Python buffer object that lets you write to the image's buffer directly.

It typically crashes hard, or it creates a bitmap object that when I try to
select it into a DC so I can blit it, I get an assertion failure telling me
it couldn't select the bitmap. [Helpful error messages are always nice...
:)]

Probably because it wasn't a valid wxBitmap. You can call it's Ok() method to find out.

···

--
Robin Dunn
Software Craftsman
http://wxPython.org Java give you jitters? Relax with wxPython!