0942v8653
Dec 14, 2014 - 16:33
When I load a Typicon file, e.g. the house picture, all the partial transparency (antialiasing) is removed:

This is how it looks once I'm done with it:

and this is how it should look:

Here is my code:
from PIL import Image as ImageP
import io
import base64
import clipboard
import ui
appsize = (120, 120)
typsize = (96, 96)
offset = [(appsize[i] - typsize[i])/2 for i in range(2)]
master = ImageP.new('RGBA', (120, 120), (50, 50, 50, 255))
home = ImageP.open("Typicons96_Home")
home.show() # it is broken here, even before converting.
home = home.convert('RGBA')
r, g, b, a = home.split()
home = ImageP.merge("RGB", (r, g, b))
mask = ImageP.merge("L", (a,))
master.paste(home, tuple(offset), mask)
with io.BytesIO() as bIO:
master.save(bIO, 'PNG')
img = ui.Image.from_data(bIO.getvalue())
bytes = img.to_png()
clipboard.set(base64.b64encode(bytes))
Curiously, this seems to happen only with the Typicon files and nothing else.