aboutsummaryrefslogtreecommitdiff
path: root/experiments/conv/pc2png
diff options
context:
space:
mode:
Diffstat (limited to 'experiments/conv/pc2png')
-rwxr-xr-xexperiments/conv/pc2png26
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)