deleted old main. Fixed non-batch download
This commit is contained in:
parent
079a46d54c
commit
70b3956d20
|
@ -22,7 +22,7 @@ arguments = docopt(__doc__)
|
|||
colors = [(0xff, 0xff, 0xff), (0xaa, 0xaa, 0xaa), (0x55,0x55,0x55), (0x00,0x00,0x00)]
|
||||
port = serial.Serial(arguments["<port>"], 115200)
|
||||
|
||||
runs = 0
|
||||
runs = 1
|
||||
|
||||
if arguments['-b'] != None:
|
||||
runs = arguments['-b']
|
||||
|
|
49
main.py
49
main.py
|
@ -1,49 +0,0 @@
|
|||
'''
|
||||
Converter of gameboy camera images to PNGs. Probably awful.
|
||||
Gameboy camera images are saved in the format of the mofosyne printer emulator.
|
||||
'''
|
||||
#!/usr/bin/env/python
|
||||
import json
|
||||
import twobpp
|
||||
from PIL import Image
|
||||
|
||||
def chunks(l, n):
|
||||
"""Yield successive n-sized chunks from l."""
|
||||
for i in range(0, len(l), n):
|
||||
yield l[i:i + n]
|
||||
|
||||
TILES_PER_LINE = 20
|
||||
HEIGHT = 144
|
||||
WIDTH = 160
|
||||
|
||||
|
||||
colors = [(0xff, 0xff, 0xff), (0xaa, 0xaa, 0xaa), (0x55,0x55,0x55), (0x00,0x00,0x00)]
|
||||
|
||||
l = f.readlines()
|
||||
|
||||
d = []
|
||||
for line in l:
|
||||
if line.startswith("#"):
|
||||
pass
|
||||
elif line.startswith("!"):
|
||||
pass
|
||||
else:
|
||||
d.append(line)
|
||||
|
||||
b = [bytes.fromhex(h.strip()) for h in d]
|
||||
tiles = [twobpp.decode_tile(l) for l in b]
|
||||
|
||||
tile_image = []
|
||||
for t in chunks(tiles, TILES_PER_LINE):
|
||||
chunk = []
|
||||
for l in range(8):
|
||||
line = []
|
||||
for tile in range(TILES_PER_LINE):
|
||||
line += t[tile][l]
|
||||
chunk += line
|
||||
tile_image += chunk
|
||||
|
||||
image_data = [colors[x] for x in tile_image]
|
||||
|
||||
image = Image.new(mode='RGB',size=(WIDTH,HEIGHT))
|
||||
image.putdata(image_data)
|
Loading…
Reference in New Issue