Shaped window using png with a transparent background

I've been battling with this for days. I'm pretty sure it's just my
ignorance of graphic images, but if anyone can point me in the right
direction I'd be *most* appreciative.

I create a region from a bitmap, then set the window shape from the
bitmap region (similar to the shaped window demo in wx demos).

def SetWindowShape(self, *event)
    region = wx.RegionFromBitmap(self.bitmap)
    self.hasShape = self.SetShape(region)

This bitmap is a simple rounded rectangle, but my window ALWAYS
displays the background of parent frame on the corners, instead of
being transparent (showing the desktop). My png image appears to be
transparent when I view it with different backgrounds or in a browser,
but I can't seem to get my window shaped to the NON-transparent
portion of the bitmap.
I know this can be done, because when I load Vippi.png (the image used
wx demo) the window IS shaped correctly to the bitmap, but if I edit
the same png with gimp and add a colored circle... bang! I see the
parent frame background in a square frame. What am I missing here?
Joelb

wx.RegionFromBitmap uses the bitmap's mask, if it has one, to create
the region. Your bitmap probably has an alpha channel instead. When
PNG images are loaded by wx they are given a mask only if al the
pixels are either fully transparent or fully opaque (1-bit alpha)
otherwise they are given an 8-bit alpha channel and
wx.RegionFromBitmap doesn't know what to do with it.

You can either edit your image to have no partially transparent
pixels, or you can convert the alpha to a mask when you load the image
using wx.Image.ConvertAlphaToMask.

···

On Nov 2, 8:45 pm, joelb <jburt...@gmail.com> wrote:

I've been battling with this for days. I'm pretty sure it's just my
ignorance of graphic images, but if anyone can point me in the right
direction I'd be *most* appreciative.

I create a region from a bitmap, then set the window shape from the
bitmap region (similar to the shaped window demo in wx demos).

def SetWindowShape(self, *event)
region = wx.RegionFromBitmap(self.bitmap)
self.hasShape = self.SetShape(region)

This bitmap is a simple rounded rectangle, but my window ALWAYS
displays the background of parent frame on the corners, instead of
being transparent (showing the desktop). My png image appears to be
transparent when I view it with different backgrounds or in a browser,
but I can't seem to get my window shaped to the NON-transparent
portion of the bitmap.
I know this can be done, because when I load Vippi.png (the image used
wx demo) the window IS shaped correctly to the bitmap, but if I edit
the same png with gimp and add a colored circle... bang! I see the
parent frame background in a square frame. What am I missing here?

--
Robin Dunn
Software Craftsman