mirror of
https://git.planet-casio.com/Lephenixnoir/fxsdk.git
synced 2024-12-29 13:03:37 +01:00
fxconv: "fix" palette remap with non-continous "P" image
Just take the holes and save less space
This commit is contained in:
parent
afc6d51217
commit
6dae13007e
1 changed files with 9 additions and 3 deletions
|
@ -1005,9 +1005,15 @@ def r5g6b5(img, color_count=0, trim_palette=False, palette_base=0, alpha=None):
|
||||||
|
|
||||||
# Format for the first palette is a list of N triplets where N is the
|
# Format for the first palette is a list of N triplets where N is the
|
||||||
# number of used opaque colors; obviously N <= palette_max_size
|
# number of used opaque colors; obviously N <= palette_max_size
|
||||||
palette1 = img.getpalette()[:3*len(img.getcolors())]
|
# Note: sometimes colors are not numbered 0..N-1, so we take the max
|
||||||
|
# value rather than len(img.getcolors()); we don't try to remap indices
|
||||||
|
pixels = img.load()
|
||||||
|
N = 1 + max(pixels[x,y]
|
||||||
|
for y in range(img.height)
|
||||||
|
for x in range(img.width))
|
||||||
|
palette1 = img.getpalette()[:3*N]
|
||||||
palette1 = list(zip(palette1[::3], palette1[1::3], palette1[2::3]))
|
palette1 = list(zip(palette1[::3], palette1[1::3], palette1[2::3]))
|
||||||
|
else:
|
||||||
pixels = img.load()
|
pixels = img.load()
|
||||||
|
|
||||||
#---
|
#---
|
||||||
|
|
Loading…
Reference in a new issue