[Image-SIG] How to convert from transparent PIL to transparent wx.Image ?

Laszlo Zsolt Nagy gandalf at designaproduct.biz
Sun Sep 18 11:16:11 CEST 2005


Hello,

This is what I have now:

def piltoimage(pil):
    """Convert PIL Image to wx.Image."""
    image = wx.EmptyImage(pil.size[0], pil.size[1])
    new_image = pil.convert('RGB')
    data = new_image.tostring()
    image.SetData(data)
    return image

But this does not work if I try to use 'RGBA' mode. Do you know a solution?

  Les



More information about the Image-SIG mailing list