From 5224d67b085e95e9bb6c780e4548582bc81d36b1 Mon Sep 17 00:00:00 2001 From: tangstad Date: Tue, 8 Nov 2005 09:18:09 +0000 Subject: [PATCH] Added beginning of img2bin, though it only converts a 8x8 pixel image at the moment. --- gba/tools/img2bin.py | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) create mode 100644 gba/tools/img2bin.py diff --git a/gba/tools/img2bin.py b/gba/tools/img2bin.py new file mode 100644 index 0000000..a574950 --- /dev/null +++ b/gba/tools/img2bin.py @@ -0,0 +1,18 @@ +#!/usr/bin/python +from PIL import Image +import sys + +"""Convert image to raw binary using Python Imaging Library.""" + +if len(sys.argv) != 3: + print "Usage: %s " + print "WARNING: It only converts 8x8 pixel images at 8bit the moment." + +im = Image.open(sys.argv[1]) +output = open(sys.argv[2], "wb") +for x in range(8): + for y in range(8): + val = im.getpixel((x, y)) + output.write(chr(val)) + +