[wxpython-users] Re: The new StaticBitmap is dead,
long live the old StaticBitmap!
Peter Damoc
pdamoc at gmail.com
Tue Apr 1 01:52:32 PDT 2008
Hi Alex,
The best way (in my view) to do what you want to do is create an empty
bitmap with alpha channel, load it into a wx.MemoryDC and after that draw on
it what you need in this case a FloodFill with that yellowish color.
here is some code for the EmptyBitmapRGBA
def EmptyBitmapRGBA((width, height)):
bytes =3D array.array('B', [0] * width*height*4)
return wx.BitmapFromBufferRGBA(width, height, bytes)
Maybe if enough people would start using this kind of bitmaps we will get it
in the wx namespace, created in C++ , without depending on the array module
which is painfully slow.
Peter
On Tue, Apr 1, 2008 at 9:51 AM, Alex <alexandru.tabac at gmail.com> wrote:
> Tim van der Leeuw <tnleeuw <at> gmail.com> writes:
>
> > Could you perhaps show us some sample-code? (I had no problem creating a
> > Static Bitmap from an Image created from PIL, the other day, using Vista
> +
> > wxPython 2.8.7.1)Cheers,--Tim
>
> Sure.
>
> -------------------------------------------------------------------------=
---
> #!/usr/bin/env python
> # -*- coding:utf-8 -*-
>
> import wx
>
> import wx.lib.inspection
>
> app =3D wx.App(redirect=3DTrue,filename=3D'debug.log')
>
> frame =3D wx.Frame(None, -1, 'simple.py', size=3D(200,200))
> panel =3D wx.Panel(frame)
> bmp =3D wx.EmptyBitmap(200,200,-1)
> pixels =3D wx.AlphaPixelData(bmp)
> for pixel in pixels:
> pixel.Set(100,100,0,128)
> static =3D wx.StaticBitmap(parent=3Dpanel, bitmap=3Dbmp)
> frame.Show()
> wx.lib.inspection.InspectionTool().Show()
>
> app.MainLoop()
>
> -------------------------------------------------------------------------=
----
>
> Using wx.NativePixelData gives me an error, because apparently,
> wx.NativePixelData chokes on wx.Bitmap-s. I tried wx.NativePixelDatabecau=
se at
> first I thought that winXP somehow disliked the presence of an alpha
> channel,
> but as I remember winXP could deal OK with alphas.
>
> _______________________________________________
> wxpython-users mailing list
> wxpython-users at lists.wxwidgets.org
> http://lists.wxwidgets.org/mailman/listinfo/wxpython-users
>
-- =
There is NO FATE, we are the creators.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.wxwidgets.org/pipermail/wxpython-users/attachments/200804=
01/dc607b8f/attachment.htm
More information about the wxpython-users
mailing list