def export_nametable(nametable_data, chr_data, png_file, palette=palette): if isinstance(nametable_data, str): nts = nametable.load_nametable(nametable_data) else: nts = nametable_data if isinstance(chr_data, str): sprs = SpriteSet(chr_data) else: sprs = SpriteSet(chr_data) nt = nametable.get_nametable(0, nts) size = (256, 256) img = Image.new('RGB', size) draw = ImageDraw.Draw(img) nt_index = 0 num_nt = nametable.length(nts) if len(sprs) == 512: start = 256 else: start = 0 for y in range(32): for x in range(32): dx = nt_index / 32 dy = nt_index % 32 spr_index = nt[y][x] + start #TODO something strange with X and Y spr = sprs.get(spr_index) draw_sprite(spr, dx, dy, draw, palette) nt_index += 1 img.save(png_file, 'PNG')
def export_nametable(nametable_file, chr_file, png_file, palette=palette): nts = nametable.load_nametable(nametable_file) sprs = sprite.load_sprites(chr_file) nt = nametable.get_nametable(0, nts) size = (256, 256) img = Image.new('RGB', size) draw = ImageDraw.Draw(img) nt_index = 0 num_nt = nametable.length(nts) for y in range(32): for x in range(32): dx = nt_index / 32 dy = nt_index % 32 spr_index = nt[y][x] + 256 spr = sprite.get_sprite(spr_index, sprs) draw_sprite(spr, dx, dy, draw, palette) nt_index += 1 img.save(png_file, 'PNG')
def export_nametable(nametable_data, chr_data, png_file, palette=palette): print nametable_data if isinstance(nametable_data, str): nts = nametable.load_nametable(nametable_data) else: nts = nametable_data if isinstance(chr_data, str): sprs = SpriteSet(chr_data) else: sprs = SpriteSet(chr_data) nt = nametable.get_nametable(0, nts) size = (256, 256) img = Image.new('RGB', size) draw = ImageDraw.Draw(img) nt_index = 0 num_nt = nametable.length(nts) if len(sprs) == 512: start = 256 else: start = 0 for y in range(32): for x in range(32): dx = nt_index / 32 dy = nt_index % 32 spr_index = nt[y][x] + start #TODO something strange with X and Y spr = sprs.get(spr_index) draw_sprite(spr, dx, dy, draw, palette) nt_index += 1 img.save(png_file, 'PNG')