diff options
author | Loek Le Blansch <loek@pipeframe.xyz> | 2024-10-04 23:53:16 +0200 |
---|---|---|
committer | Loek Le Blansch <loek@pipeframe.xyz> | 2024-10-04 23:53:16 +0200 |
commit | 6017481d736fd3ae7aa8b1055913e873c0d514c6 (patch) | |
tree | 0889d960f54630b242052e5ebdfb1894b287058f /experiments/conv/pc2png | |
parent | fd68acc5f88e13cdbed17d6d438323ce95fee634 (diff) |
implement png2pc
Diffstat (limited to 'experiments/conv/pc2png')
-rwxr-xr-x | experiments/conv/pc2png | 26 |
1 files changed, 3 insertions, 23 deletions
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) |