wxPython中的透明图像{Mask} [英] Transparent images in wxPython {Mask}
本文介绍了wxPython中的透明图像{Mask}的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我已经厌倦了在网络上搜索此文件,但我无法使其正常工作.我需要将绿色像素变成透明像素,而不需要一半的透明度.想知道如何才能有效地使用遮罩,但是wx文档并没有真正的帮助...
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.
相关代码
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()))
推荐答案
您可以查看 wxpython文档和演示.
在演示蒙版中,他们展示了一种使用透明蒙版的方法:
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)
这篇关于wxPython中的透明图像{Mask}的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文