Map saving first pass
This commit is contained in:
@@ -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)
|
Reference in New Issue
Block a user