Map saving first pass

This commit is contained in:
2025-09-18 17:01:10 -05:00
parent a45a2a5bd7
commit 2f40724258
22 changed files with 355 additions and 24 deletions

View File

@@ -4,24 +4,32 @@ from PIL import Image
from processpalette import extractPaletteFromImage, palettes
from args import args
from assethelpers import getAssetRelativePath
from assetcache import assetGetCache, assetCache
images = []
def processImage(asset):
cache = assetGetCache(asset['path'])
if cache is not None:
return cache
type = None
if 'type' in asset['options']:
type = asset['options'].get('type', 'PALETTIZED').upper()
if type == 'PALETTIZED' or type is None:
return processPalettizedImage(asset)
return assetCache(asset['path'], processPalettizedImage(asset))
elif type == 'ALPHA':
return processAlphaImage(asset)
return assetCache(asset['path'], processAlphaImage(asset))
else:
print(f"Error: Unknown image type {type} for asset {asset['path']}")
sys.exit(1)
def processPalettizedImage(asset):
assetPath = asset['path']
cache = assetGetCache(assetPath)
if cache is not None:
return cache
image = Image.open(assetPath)
imagePalette = extractPaletteFromImage(image)
@@ -72,10 +80,14 @@ def processPalettizedImage(asset):
'width': image.width,
'height': image.height,
}
return outImage
return assetCache(assetPath, outImage)
def processAlphaImage(asset):
assetPath = asset['path']
cache = assetGetCache(assetPath)
if cache is not None:
return cache
print(f"Processing alpha image: {assetPath}")
data = bytearray()
@@ -101,4 +113,4 @@ def processAlphaImage(asset):
'width': image.width,
'height': image.height,
}
return outImage
return assetCache(assetPath, outImage)