mirror of
https://mikeslab.dix.asia/gogs/My-Mods/ANI2Cape.git
synced 2025-10-01 23:14:57 +00:00
Fix transparency missing with indexed color
This commit is contained in:
parent
b4e2de09b2
commit
d57a50bedd
3 changed files with 35 additions and 5 deletions
10
ani2cape.py
10
ani2cape.py
|
@ -14,7 +14,15 @@ def scaleImage(img, scale):
|
|||
|
||||
|
||||
def readCUR(f, width=-1.0, height=-1.0):
|
||||
frameImage = Image.open(f, formats=['cur', 'ico']).convert('RGBA')
|
||||
frameImage = Image.open(f, formats=['cur', 'ico'])
|
||||
if (frameImage.mode == 'P'):
|
||||
palette = list(frameImage.palette.getdata()[1])
|
||||
for i in range(4, len(palette), 4):
|
||||
if sum(palette[i:i + 3]) == 0:
|
||||
break
|
||||
palette[i + 3] = 255
|
||||
frameImage.putpalette(palette, 'BGRA')
|
||||
frameImage = frameImage.convert('RGBA')
|
||||
if (width, height) == (-1.0, -1.0):
|
||||
return frameImage, (float(frameImage.width), float(frameImage.height))
|
||||
if -1 in (width, height):
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue