Reputation: 282
I'm tired of searching this on the net and i cant get it to work. I need to turn green pixels into transparent ones, no half transparency needed. Wondering how can effectively use a mask, but the wx docs doesn't help much really...
Hope someone can give me a tip, regards.
Related code
png = wx.Image('sun2.png', wx.BITMAP_TYPE_PNG).ConvertToBitmap()
#print png.HasMask() fail
png.SetMaskColour((0,255,0))
#mask=wx.Mask(png,wx.Colour(0,255,0))
#png.SetMask(mask)
imge=wx.StaticBitmap(self, -1, png, (10, 5), (png.GetWidth(), png.GetHeight()))
Upvotes: 1
Views: 2581
Reputation: 85615
You can check the wxpython docs and demo.
In the demo Mask they show a method to use a transparent mask:
# Now we'll create a mask in a bit of an easier way, by picking a
# colour in the image that is to be the transparent colour.
self.bmp_withcolourmask = images.TestStar2.GetBitmap()
mask = wx.Mask(self.bmp_withcolourmask, wx.WHITE)
self.bmp_withcolourmask.SetMask(mask)
Upvotes: 4