python - wxPython {Mask} 中的透明图像

标签 python image wxpython transparency

我厌倦了在网上搜索这个,但无法让它工作。我需要将绿色像素变成透明像素,不需要半透明。想知道如何有效地使用 mask ,但 wx 文档并没有多大帮助......

希望有人能给我提示,问候。

相关代码

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 docs and demo .
在演示 mask 中,他们展示了一种使用透明 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)

关于python - wxPython {Mask} 中的透明图像,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/12029960/

相关文章:

html - 使用 HTML 将图像彼此相邻添加时删除垂直空间

python - wxPython - 如何从事件中获取菜单项?

python - 多窗口 Pygame

python - 在 Pandas Dataframe pd.concat 之后我得到了 NaN

python - 如何使用 pandas 计算列中的失败发生次数?

python - 检查字符串中的空格(python)

python - 如何使用python中的正则表达式模块将文本字符串拆分为单词?

jquery - 循环作为背景图像不起作用

html - 如何指定图像出现在您网站的 facebook 链接中?

python - 为什么 wx.SingleChoiceDialog 没有正确地子类化