[wxPython-users] Re: Trouble with drawing, I need some ideas
:)
Robin Dunn
robin at alldunn.com
Mon Oct 15 12:06:27 PDT 2007
Peter Damoc wrote:
> Problem solved via:
>
> def SetAlpha(bmp):
> w, h = bmp.GetSize()
> img = bmp.ConvertToImage()
> img.InitAlpha()
> for i in range(w):
> for j in range(h):
> img.SetAlpha(i,j, 0)
> return img.ConvertToBitmap()
>
> Ugly hack but... until I find something better.... :) will have to do...
I was just chatting with a coworker at OSAF about a similar problem, and
I realized that this is probably equivalent to how you are using the
above. It creates a new bitmap with all pixels set to black and with a
fully transparent alpha:
bytes = array.array('B', [0] * width*height*4)
bmp = wx.BitmapFromBufferRGBA(width, height, bytes)
Then any drawing you do on it with a wx.GCDC or a wx.GraphicsContext
will be working on a fully transparent background, and will reset the
alpha as as specified in the pen or brush objects when drawing other
things on top of it.
--
Robin Dunn
Software Craftsman
http://wxPython.org Java give you jitters? Relax with wxPython!
More information about the wxpython-users
mailing list