From 6017481d736fd3ae7aa8b1055913e873c0d514c6 Mon Sep 17 00:00:00 2001 From: Loek Le Blansch Date: Fri, 4 Oct 2024 23:53:16 +0200 Subject: implement png2pc --- experiments/conv/pc2png | 26 +++----------------------- 1 file changed, 3 insertions(+), 23 deletions(-) (limited to 'experiments/conv/pc2png') diff --git a/experiments/conv/pc2png b/experiments/conv/pc2png index 4fa7a1a..c7f131a 100755 --- a/experiments/conv/pc2png +++ b/experiments/conv/pc2png @@ -1,18 +1,10 @@ #!/bin/python3 - -import sys -import re import math import io - from PIL import Image -from consts import PICTOCHAT_PALETTE - -DS_TILE_SIZE = 8 -TILE_BYTES = 32 # tiles are stored in 32 bytes chunks - -TILES_HORIZONTAL = 32 +from consts import * +from shared import main # convert a single DS tile (8x8) from packed palette index format to RGB colors def convert_chunk(img, chunk, offset): @@ -53,18 +45,6 @@ def pc2png(data): img.save(output, format='PNG') return output.getvalue() -def convert_file(input_filename, output_filename): - with open(input_filename, 'rb') as input_file: - content = input_file.read() - output = pc2png(content) - with open(output_filename, 'wb+') as output_file: - output_file.write(output) - if __name__ == "__main__": - del sys.argv[0] - for input_filename in sys.argv: - output_filename = re.sub('.bin$', '.png', input_filename) - if not output_filename.endswith('.png'): - output_filename += '.png' - convert_file(input_filename, output_filename) + main("bin", "png", pc2png) -- cgit v1.2.3