【问题标题】:Transparent images in wxPython {Mask}wxPython {Mask}中的透明图像
【发布时间】:2012-08-19 20:59:52
【问题描述】:

我厌倦了在网上搜索这个,我无法让它工作。我需要将绿色像素变成透明像素,不需要半透明。想知道如何有效地使用面具,但 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()))

【问题讨论】:

    标签: python image wxpython transparency


    【解决方案1】:

    您可以查看wxpython docs and demo
    在演示 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)
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2021-11-26
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多