mirror of
https://git.planet-casio.com/Lephenixnoir/fxsdk.git
synced 2024-12-29 13:03:37 +01:00
fxconv: better support for indexed images
Indexed images don't have an alpha channel, so the detection of transparent pixels in fxconv failed. This change forces a conversion of indexed images to RGBA to properly handle this.
This commit is contained in:
parent
84f77c3136
commit
66d88bef7a
1 changed files with 5 additions and 0 deletions
|
@ -737,6 +737,11 @@ def quantize(img, dither=False):
|
||||||
palette.putpixel((i, 0), c)
|
palette.putpixel((i, 0), c)
|
||||||
palette = palette.convert("P")
|
palette = palette.convert("P")
|
||||||
|
|
||||||
|
# Make the image RGBA in case it was indexed so that transparent pixels are
|
||||||
|
# represented in an alpha channel
|
||||||
|
if img.mode == "P":
|
||||||
|
img = img.convert("RGBA")
|
||||||
|
|
||||||
# Save the alpha channel, and make it either full transparent or opaque
|
# Save the alpha channel, and make it either full transparent or opaque
|
||||||
try:
|
try:
|
||||||
alpha_channel = img.getchannel("A").convert("1", dither=Image.NONE)
|
alpha_channel = img.getchannel("A").convert("1", dither=Image.NONE)
|
||||||
|
|
Loading…
Reference in a new issue