fix conversion from Indexed PNG-image
This commit is contained in:
@@ -112,22 +112,14 @@ class ArgbImage:
|
||||
def _load_png(self, fname: str) -> None:
|
||||
if not PIL_ENABLED:
|
||||
raise ImportError('Install Pillow to support PNG conversion.')
|
||||
img = Image.open(fname, mode='r')
|
||||
img = Image.open(fname, mode='r').convert('RGBA')
|
||||
self.size = img.size
|
||||
self.channels = 4
|
||||
self.a = []
|
||||
self.r = []
|
||||
self.g = []
|
||||
self.b = []
|
||||
w, h = img.size
|
||||
for y in range(h):
|
||||
for x in range(w):
|
||||
px = img.getpixel((x, y))
|
||||
if type(px) == int:
|
||||
px = (px, px, px) # convert mono to rgb
|
||||
if len(px) == 3:
|
||||
px = px + (0xFF,) # convert rgb to rgba
|
||||
r, g, b, a = px
|
||||
for r, g, b, a in img.getdata():
|
||||
self.a.append(a)
|
||||
self.r.append(r)
|
||||
self.g.append(g)
|
||||
|
||||
Reference in New Issue
Block a user