X-Git-Url: http://git.tdb.fi/?a=blobdiff_plain;f=maketex.py;fp=maketex.py;h=17012c8a6e7f6d8925dae9ce41cc51aa683c369f;hb=d1800d7ea80290f4913d0203241cef1409656522;hp=0000000000000000000000000000000000000000;hpb=a80b074c70ec991f27114efd13686038cf42c493;p=libs%2Fgl.git diff --git a/maketex.py b/maketex.py new file mode 100755 index 00000000..17012c8a --- /dev/null +++ b/maketex.py @@ -0,0 +1,36 @@ +#!/usr/bin/python + +# $Id$ + +import Image +import sys +import os + +def escape(str): + result="" + for c in str: + if c=='"': + result+='\\"' + elif c=='\\': + result+='\\\\' + elif ord(c)<0x20: + result+="\\%03o"%ord(c) + else: + result+=c + return result; + +img=Image.open(sys.argv[1]) +out=file(os.path.splitext(sys.argv[1])[0]+".tex", "w") +fmt="".join(img.getbands()) +if fmt=="LA": + fmt="LUMINANCE_ALPHA" +elif fmt=="L": + fmt="LUMINANCE" +out.write("storage %s %d %d 0;\n"%(fmt, img.size[0], img.size[1])) +out.write("min_filter LINEAR;\n") +out.write("raw_data \"") +data=list(img.getdata()) +for y in range(img.size[1]): + i=(img.size[1]-1-y)*img.size[0] + out.write(escape("".join(["".join([chr(v) for v in p]) for p in data[i:i+img.size[0]]]))) +out.write("\";\n")