Created
June 22, 2011 20:57
-
-
Save biomood/1041172 to your computer and use it in GitHub Desktop.
Python script to create a gameduino sprite header from an image
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import sys | |
from PIL import Image | |
from gameduino import prep | |
image_path = "" | |
h_name = "" | |
# retrieve the command line arguments | |
if (len(sys.argv) > 2): | |
image_path = sys.argv[1] | |
sprite_name = sys.argv[2] | |
else: | |
print "Not all commands entered" | |
sys.exit(0) | |
# create the header file | |
hdr = open(sprite_name+".h", "w") | |
ir = prep.ImageRAM(hdr) | |
im = Image.open(image_path) | |
# show the image to be changed | |
im.show() | |
sprite = prep.palettize(im, 4) | |
# dump to a h file | |
prep.dump(hdr, sprite_name+"_palette", sprite) | |
ir.addsprites(sprite_name, (16,16), sprite, prep.PALETTE4A) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment