def make_fnt_file(pre_str,image_dict):
	# print "make_fnt_file:","\n".join(image_dict)

	fnt_name=output_path_name+"/"+pre_str+".fnt"
	image_name=pre_str+".png"
	fnt_define=dict()
	index=0
	xOffset=0
	max_height=0
	max_width=0
	fnt_define_item=list()
	for key in image_dict.keys():
		print "\t+",key+"\t","Key:",chr(int(image_dict[key]))

		image_size=utility.image_size_at_path(key)
		fnt_define_item_data=dict()
		fnt_define_item_data["id"]=image_dict[key]
		fnt_define_item_data["x"]=str(xOffset)
		fnt_define_item_data["y"]=str(0)
		fnt_define_item_data["width"]=str(image_size[0])
		fnt_define_item_data["height"]=str(image_size[1])
		fnt_define_item_data["xoffset"]=str(0)
		fnt_define_item_data["yoffset"]=str(0)
		fnt_define_item_data["xadvance"]=str(image_size[0])
		fnt_define_item_data["page"]=str(0)
		fnt_define_item_data["chnl"]=str(0)
		fnt_define_item_data["letter"]=chr(int(image_dict[key]))

		fnt_define_item.append(fnt_define_item_data)

		index+=1
		xOffset+=image_size[0]
		max_width=max(max_width,image_size[0])
		max_height=max(max_height,image_size[1])

	fnt_define["data"]=fnt_define_item
	fnt_define["size"]=str(max_width)
	fnt_define["lineHeight"]=str(max_height)
	fnt_define["base"]=str(max_width)
	fnt_define["scaleW"]=str(xOffset)
	fnt_define["scaleH"]=str(max_height)
	fnt_define["file"]=image_name
	fnt_define["count"]=len(image_dict)

	image_name=output_path_name+"/"+image_name

	utility.create_fnt_file(fnt_name, fnt_define)
	print "make:",fnt_name,"done!"
	joint_image(image_name,image_dict)
	print "make:",image_name,"done!"
	print"*************************************************************"
Beispiel #2
0
def make_fnt_file(pre_str, image_dict):
    # print "make_fnt_file:","\n".join(image_dict)

    fnt_name = output_path_name + "/" + pre_str + ".fnt"
    image_name = pre_str + ".png"
    fnt_define = dict()
    index = 0
    xOffset = 0
    max_height = 0
    max_width = 0
    fnt_define_item = list()
    for key in image_dict.keys():
        print "\t+", key + "\t", "Key:", chr(int(image_dict[key]))

        image_size = utility.image_size_at_path(key)
        fnt_define_item_data = dict()
        fnt_define_item_data["id"] = image_dict[key]
        fnt_define_item_data["x"] = str(xOffset)
        fnt_define_item_data["y"] = str(0)
        fnt_define_item_data["width"] = str(image_size[0])
        fnt_define_item_data["height"] = str(image_size[1])
        fnt_define_item_data["xoffset"] = str(0)
        fnt_define_item_data["yoffset"] = str(0)
        fnt_define_item_data["xadvance"] = str(image_size[0])
        fnt_define_item_data["page"] = str(0)
        fnt_define_item_data["chnl"] = str(0)
        fnt_define_item_data["letter"] = chr(int(image_dict[key]))

        fnt_define_item.append(fnt_define_item_data)

        index += 1
        xOffset += image_size[0]
        max_width = max(max_width, image_size[0])
        max_height = max(max_height, image_size[1])

    fnt_define["data"] = fnt_define_item
    fnt_define["size"] = str(max_width)
    fnt_define["lineHeight"] = str(max_height)
    fnt_define["base"] = str(max_width)
    fnt_define["scaleW"] = str(xOffset)
    fnt_define["scaleH"] = str(max_height)
    fnt_define["file"] = image_name
    fnt_define["count"] = len(image_dict)

    image_name = output_path_name + "/" + image_name

    utility.create_fnt_file(fnt_name, fnt_define)
    print "make:", fnt_name, "done!"
    joint_image(image_name, image_dict)
    print "make:", image_name, "done!"
    print "*************************************************************"
Beispiel #3
0
def main():
	file_list=os.listdir(os.getcwd())

	for file_name in file_list:
		if not os.path.isfile(file_name) or file_name.find(".png") == -1:
			continue

		size=utility.image_size_at_path(file_name)

		new_image_cmd="convert -size %dx%d -strip -colors 8 -depth 8 xc:none tmp.png" %(size[0]+left+right,size[1]+top+bottom)
		os.system(new_image_cmd)

		composite_image_cmd="composite -geometry +%d+%d %s tmp.png %s" %(left,right,file_name,file_name)
		os.system(composite_image_cmd)
Beispiel #4
0
def main():
    file_list = os.listdir(os.getcwd())

    for file_name in file_list:
        if not os.path.isfile(file_name) or file_name.find(".png") == -1:
            continue

        size = utility.image_size_at_path(file_name)

        new_image_cmd = "convert -size %dx%d -strip -colors 8 -depth 8 xc:none tmp.png" % (
            size[0] + left + right, size[1] + top + bottom)
        os.system(new_image_cmd)

        composite_image_cmd = "composite -geometry +%d+%d %s tmp.png %s" % (
            left, right, file_name, file_name)
        os.system(composite_image_cmd)
Beispiel #5
0
def write_fnt_file(name,info):

	image_size=utility.image_size_at_path(info["textureFilename"])

	# print "\tImage  %s ,width=%d ,height= %d" % (info["textureFilename"],image_size[0],image_size[1])

	nCount=image_size[0]/int(info["itemWidth"])
	nFirstID=int(info["firstChar"])
	nCharWidth=int(info["itemWidth"])
	nCharHeight=int(info["itemHeight"])
	fnt_define=dict()
	fnt_define_item=list()

	for index in range(0,nCount):
		fnt_define_item_data=dict()
		fnt_define_item_data["id"]=str(nFirstID+index)
		fnt_define_item_data["x"]=str(index*nCharWidth)
		fnt_define_item_data["y"]=str(0)
		fnt_define_item_data["width"]=str(nCharWidth)
		fnt_define_item_data["height"]=str(nCharHeight)
		fnt_define_item_data["xoffset"]=str(0)
		fnt_define_item_data["yoffset"]=str(0)
		fnt_define_item_data["xadvance"]=str(nCharWidth)
		fnt_define_item_data["page"]=str(0)
		fnt_define_item_data["chnl"]=str(0)
		fnt_define_item_data["letter"]=chr(index+nFirstID)

		fnt_define_item.append(fnt_define_item_data)
	

	fnt_define["data"]=fnt_define_item
	fnt_define["size"]=str(nCharWidth)
	fnt_define["lineHeight"]=str(nCharHeight)
	fnt_define["base"]=str(nCharWidth)
	fnt_define["scaleW"]=str(image_size[0])
	fnt_define["scaleH"]=str(image_size[1])
	fnt_define["file"]=info["textureFilename"]
	fnt_define["count"]=nCount


	fnt_path_name=output_path_name+"/"+name

	utility.create_fnt_file(fnt_path_name, fnt_define)
Beispiel #6
0
def joint_image(out_image_name,image_dict):
	outW=0
	outH=0
	for key in image_dict.keys():
		size=utility.image_size_at_path(key)
		outW+=size[0]
		outH=max(size[1],outH)

	print "out image size %dx%d" %(outW,outH)

	toImage = Image.new('RGBA', (outW, outH))

	x=0
	for key in image_dict.keys():
		fromImage=Image.open(key)
		toImage.paste(fromImage,( x, 0))
		print "\t %s offset %d" %(key,x)
		x+=fromImage.size[0]

	toImage.save(out_image_name)
Beispiel #7
0
def joint_image(out_image_name, image_dict):
    outW = 0
    outH = 0
    for key in image_dict.keys():
        size = utility.image_size_at_path(key)
        outW += size[0]
        outH = max(size[1], outH)

    print "out image size %dx%d" % (outW, outH)

    toImage = Image.new('RGBA', (outW, outH))

    x = 0
    for key in image_dict.keys():
        fromImage = Image.open(key)
        toImage.paste(fromImage, (x, 0))
        print "\t %s offset %d" % (key, x)
        x += fromImage.size[0]

    toImage.save(out_image_name)
Beispiel #8
0
def write_fnt_file(name, info):

    image_size = utility.image_size_at_path(info["textureFilename"])

    # print "\tImage  %s ,width=%d ,height= %d" % (info["textureFilename"],image_size[0],image_size[1])

    nCount = image_size[0] / int(info["itemWidth"])
    nFirstID = int(info["firstChar"])
    nCharWidth = int(info["itemWidth"])
    nCharHeight = int(info["itemHeight"])
    fnt_define = dict()
    fnt_define_item = list()

    for index in range(0, nCount):
        fnt_define_item_data = dict()
        fnt_define_item_data["id"] = str(nFirstID + index)
        fnt_define_item_data["x"] = str(index * nCharWidth)
        fnt_define_item_data["y"] = str(0)
        fnt_define_item_data["width"] = str(nCharWidth)
        fnt_define_item_data["height"] = str(nCharHeight)
        fnt_define_item_data["xoffset"] = str(0)
        fnt_define_item_data["yoffset"] = str(0)
        fnt_define_item_data["xadvance"] = str(nCharWidth)
        fnt_define_item_data["page"] = str(0)
        fnt_define_item_data["chnl"] = str(0)
        fnt_define_item_data["letter"] = chr(index + nFirstID)

        fnt_define_item.append(fnt_define_item_data)

    fnt_define["data"] = fnt_define_item
    fnt_define["size"] = str(nCharWidth)
    fnt_define["lineHeight"] = str(nCharHeight)
    fnt_define["base"] = str(nCharWidth)
    fnt_define["scaleW"] = str(image_size[0])
    fnt_define["scaleH"] = str(image_size[1])
    fnt_define["file"] = info["textureFilename"]
    fnt_define["count"] = nCount

    fnt_path_name = output_path_name + "/" + name

    utility.create_fnt_file(fnt_path_name, fnt_define)