Ejemplo n.º 1
0
def module_main(argv):
    if len(argv) == 7:
        level_id = int(argv[5], 0)
        level_header = level_info.load_level_header(level_id=level_id)
        output_pal = palette.assemble_palette(level_header.load_list.palettes)
        main(argv[6], output_pal, int(argv[1], 0), int(argv[2], 0), int(argv[3], 0), int(argv[4]))
    else:
        print 'Usage: {0} <chunk_id> <offset> <count> <size> <level_palette> <output.png>'.format(argv[0])
Ejemplo n.º 2
0
def main(level_header, output_file, tiles_per_row):
    output_pal = palette.assemble_palette(level_header.load_list.palettes)
    tiles = extract_tiles(level_header)

    output_data, output_w, output_h = graphics.layout_tiles(tiles, 8, 8, rows_of_tiles(len(tiles), tiles_per_row))

    with open(output_file, 'wb') as f:
        w = png.Writer(output_w, output_h, palette=output_pal)
        w.write_array(f, output_data)
Ejemplo n.º 3
0
def module_main(argv):
    if len(argv) == 7:
        level_id = int(argv[5], 0)
        level_header = level_info.load_level_header(level_id=level_id)
        output_pal = palette.assemble_palette(level_header.load_list.palettes)
        main(argv[6], output_pal, int(argv[1], 0), int(argv[2], 0),
             int(argv[3], 0), int(argv[4]))
    else:
        print 'Usage: {0} <chunk_id> <offset> <count> <size> <level_palette> <output.png>'.format(
            argv[0])
Ejemplo n.º 4
0
def main(level_header, output_file, tiles_per_row):
    output_pal = palette.assemble_palette(level_header.load_list.palettes)
    tiles = tileset.extract_tiles(level_header)

    metatile_data = decompress_data(chunk.read_chunk(level_header.metatile_chunk))
    meta_info = parse_metatile_info(metatile_data)
    del metatile_data

    def assemble_metatile(info):
        flipped_tiles = [graphics.flip_image(tiles[i], 8, hf, vf) for i, hf, vf in info]
        return graphics.layout_tiles(flipped_tiles, 8, 8, [[0, 1], [2, 3]])[0]

    meta_imgs = [assemble_metatile(info) for info in meta_info]

    output_data, output_w, output_h = graphics.layout_tiles(meta_imgs, 16, 16, tileset.rows_of_tiles(len(meta_imgs), tiles_per_row))

    with open(output_file, 'wb') as f:
        w = png.Writer(output_w, output_h, palette=output_pal)
        w.write_array(f, output_data)
Ejemplo n.º 5
0
import sys

import lvtools.chunk as chunk
from lvtools.compression import decompress_data
from lvtools.level import LevelHeader
import lvtools.palette as palette
import lvtools.util as util

level_header_id = int(sys.argv[1], 0)
output_file = sys.argv[2]

header_data = decompress_data(chunk.read_chunk(level_header_id))
header = LevelHeader()
header.load(header_data)
pal = palette.assemble_palette(header.load_list.palettes)
util.dump_file(output_file, palette.pack_palette(pal))