Fixed palette lookup
This commit is contained in:
@@ -35,10 +35,23 @@ def processPalettizedImage(asset):
|
||||
imagePalette = extractPaletteFromImage(image)
|
||||
|
||||
# Find palette that contains every color
|
||||
for palette in palettes:
|
||||
if all(color in palette['pixels'] for color in imagePalette):
|
||||
palette = None
|
||||
for p in palettes:
|
||||
hasAllColors = True
|
||||
for color in imagePalette:
|
||||
for palColor in p['pixels']:
|
||||
if color[0] == palColor[0] and color[1] == palColor[1] and color[2] == palColor[2] and color[3] == palColor[3]:
|
||||
break
|
||||
elif color[3] == 0 and palColor[3] == 0:
|
||||
break
|
||||
else:
|
||||
hasAllColors = False
|
||||
break
|
||||
if hasAllColors:
|
||||
palette = p
|
||||
break
|
||||
else:
|
||||
|
||||
if palette is None:
|
||||
palette = palettes[0] # Just to avoid reference error
|
||||
print(f"No matching palette found for {assetPath}!")
|
||||
# Find which pixel is missing
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
import json
|
||||
import os
|
||||
from PIL import Image
|
||||
import datetime
|
||||
@@ -78,6 +79,7 @@ def processPalette(asset):
|
||||
|
||||
def processPaletteList():
|
||||
data = f"// Auto-generated palette list\n"
|
||||
print(f"Generating palette list with {len(palettes)} palettes.")
|
||||
for palette in palettes:
|
||||
data += f"#include \"{palette['headerFile']}\"\n"
|
||||
data += f"\n"
|
||||
|
||||
Reference in New Issue
Block a user