[wxPython-users] Shaped window question
Ken Seehart
ken at seehart.com
Thu May 3 23:56:12 PDT 2007
Robin Dunn wrote:
> Ken Seehart wrote:
>> Andrea Gavana wrote:
>
>> I'm on all platforms :-)
>>> myBitmap = wx.Bitmap("PNGWithAlpha.png", wx.BITMAP_TYPE_PNG)
>>> myRegion = wx.RegionFromBitmap(myBitmap)
>>> self.SetShape(myRegion)
>>>
>>> Where "self" is your frame.
>>>
>> Thanks. It doesn't get the transparency though. The image has
>> variable alpha, but I am pretty certain most of the background is 0
>> alpha. The fully transparent area is unfortunately opaque.
>
> wx.RegionFromBitmap uses the bitmap's mask, however when a PNG image
> is loaded it only gets a mask if all of the alpha channel bytes are
> either 0 or 255. If there are any pixels with partial transparency it
> doesn't get a mask, but an alpha channel instead. You can convert an
> alpha channel to a mask using wx.Image.ConvertAlphaToMask, or you can
> create another image that is only used to specify the mask to be used
> to set the shape, but still draw the other bitmap with its alpha.
>
>
Ah, that explains it. Thank you.
- Ken
More information about the wxpython-users
mailing list