From a14e88ff4d0d87841a44254e2bff1784da6e8b48 Mon Sep 17 00:00:00 2001 From: Daniel Weipert Date: Sun, 15 Dec 2024 14:23:25 +0100 Subject: next commit --- extractor/sprite_format.gd | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) (limited to 'extractor/sprite_format.gd') diff --git a/extractor/sprite_format.gd b/extractor/sprite_format.gd index 46b20c1..879a45f 100644 --- a/extractor/sprite_format.gd +++ b/extractor/sprite_format.gd @@ -73,6 +73,8 @@ static func from_bytes(bytes: PackedByteArray) -> SpriteFormat: processed_palette_images += 1 palette_image_offset += data.get_byte_length() + assert(sprite_format.palette_image_data.size() == sprite_format.palette_image_count) + sprite_format.rgba_image_data = [] as Array[RGBAImageData] var rgba_image_offset = palette_image_offset var processed_rgba_images = 0 @@ -94,6 +96,8 @@ static func from_bytes(bytes: PackedByteArray) -> SpriteFormat: processed_rgba_images += 1 rgba_image_offset += data.get_byte_length() + assert(sprite_format.rgba_image_data.size() == sprite_format.rgba_image_count) + sprite_format.palette = [] as Array[PaletteColor] var palette_offset = rgba_image_offset while palette_offset < bytes.size(): @@ -127,6 +131,19 @@ func save_to_file(base_dir: String = ""): var path = "%s/%s.png" % [base_dir, str(idx).pad_zeros(3)] image.save_png(path) + + for idx in rgba_image_data.size(): + var data: RGBAImageData = rgba_image_data[idx] + var image = Image.create_from_data( + data.width, + data.height, + false, + Image.FORMAT_RGBA8, + data.data + ) + + var path = "%s/%s.png" % [base_dir, str(idx).pad_zeros(3)] + image.save_png(path) func files_exist() -> bool: -- cgit v1.2.3