Last active
December 19, 2015 05:09
-
-
Save NalaGinrut/5902263 to your computer and use it in GitHub Desktop.
convert png file to gameduino graphic header. You may need gameduino module of Python
This file contains hidden or 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
#! /usr/bin/env python | |
# Be sure you have installed: | |
# easy_install PIL | |
# easy_install PySerial | |
# easy_install gameduino | |
import Image | |
import gameduino.prep as gdprep | |
from sys import argv | |
def dump_img(pngfile): | |
(dpic,dchr,dpal) = gdprep.encode(Image.open(pngfile)) | |
imgname = pngfile.rstrip('.png') | |
hdr = open(imgname+'.h', "w") | |
gdprep.dump(hdr, imgname+"_pic" ,dpic) | |
gdprep.dump(hdr, imgname+"_chr" ,dchr) | |
gdprep.dump(hdr, imgname+"_pal" ,dpal) | |
hdr.close() | |
if __name__ == "__main__": | |
_,pngfile = argv | |
dump_img(pngfile) | |
print "%s was generated!\n" % (pngfile.rstrip('.png')+'.h') |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment