#!/usr/bin/env python import zlib import struct import os from PIL import Image, ImageDraw from common import crc24_func, get_complement, font def is_pcx(data): size,width,height = struct.unpack(">16 g = (crc&0xff00)>>8 b = crc&0xff w,h = im.size im = Image.new("RGB", (w*3,h*3), (r,g,b)) draw = ImageDraw.Draw(im) draw.text((0,0),os.path.basename(filename),get_complement(r,g,b),font=font) im = im.resize((w,h),Image.ANTIALIAS) im.save(filename, "PNG") else: return False else: o = open(filename,"w+") o.write(data) o.close() return True if __name__ == '__main__': import sys if len(sys.argv) != 3: print "usage: %s infile.lod ./outdir"%sys.argv[0] print "" print "usually after installing the normal way:" print " %s .vcmi/Data/H3bitmap.lod .vcmi/Mods/vcmi/Data/" print " rm .vcmi/Data/H3bitmap.lod" print " %s .vcmi/Data/H3sprite.lod .vcmi/Mods/vcmi/Data/" print " rm .vcmi/Data/H3sprite.lod" ret = unpack_lod(sys.argv[1], sys.argv[2]) exit(0 if ret else 1)