import os import sys import struct from PIL import Image import math # Sprite type: # 0 = VP_PARALLEL_UPRIGHT, # 1 = FACING_UPRIGHT, # 2 = VP_PARALLEL, # 3 = ORIENTED, # 4 = VP_PARALLEL_ORIENTED # Texture format: # 0 = SPR_NORMAL # 1 = SPR_ADDITIVE # 2 = SPR_INDEXALPHA # 3 = SPR_ALPHTEST #TODO: original width / height preservation throughout, use that for offsets and bounding radii def write_spr_header(spr_file, width, height, numframes, sprite_type=2, texture_format=1, synctype=0): bounding_radius = 32 if width > 0 and height > 0: bounding_radius = math.sqrt( ( (width / 2) ** 2 ) + ( ( height / 2) ** 2 ) ) spr_file.write(b'IDSP') # Identifier spr_file.write(struct.pack(' {spr_path}") img_to_spr(img_path, spr_path) width, height, palette, data = read_spr(spr_path) save_as_png(spr_path + "__.png", width, height, palette, data) print(f"Converted {img_path} to {spr_path}") #spr_path = 'content/materialsrc/Sprites/1280/test.spr' #width, height, palette, data = read_spr(spr_path) #save_as_png(spr_path + "__.png", width, height, palette, data)