#!/usr/bin/env python ''' Gameboy camera image converter. Usage: convert.py ''' import twobpp import sys import docopt from PIL import Image TILES_PER_LINE = 20 HEIGHT = 144 WIDTH = 160 arguments = docopt(__doc__) colors = [(0xff, 0xff, 0xff), (0xaa, 0xaa, 0xaa), (0x55,0x55,0x55), (0x00,0x00,0x00)] f = open(arguments[""], "r") 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] image = twobpp.convert_photo(b, colors, TILES_PER_LINE, WIDTH, HEIGHT) image.save(arguments[""])