Wx.StaticBitmap or wx.DC: Which is Better to Use for Permanently Modifying Images?

I would like to have a python gui that loads different images from files. I have seen many examples of loading an image using some code:

img = wx.Image("1.jpg", wx.BITMAP_TYPE_ANY, -1)
sb = wx.StaticBitmap(rightPanel, -1, wx.BitmapFromImage(img))
sizer.Add(sb)

      

It seems to be suitable for the image that will be present throughout the life of the program. I couldn't find an elegant way to delete / reload images. Will using wx.DC be better for my application?

+2


source to share


3 answers


If you are quickly resizing large images or want some custom effect in the future, it is better to write your own controls and do the painting with paintDC and it is not that hard.



By doing your own drawing, you can scale properly, avoid flickering, and possibly combine one image with another if you like :)

+1


source


You don't need to delete StaticBitmap

, you can just set another bitmap for it using the method SetBitmap

.



If the new image is of different sizes, you will probably have to explicitly call Layout

the parent on it for the anti-aliasing elements to adjust.

0


source


I am reading here: http://docs.wxwidgets.org/trunk/classwx_static_bitmap.html

"Native implementations on some platforms are only intended to display small icons in dialog boxes. In particular, in Windows 9x, bitmap size is limited to 64 * 64 pixels."

This could be a problem. If you are using a DC, you may need a "double buffer", or it may flicker when redrawing, resizing, or updating.

Otherwise, it seems to me that you should use a "normal" bitmap if you update it frequently.

0


source







All Articles