Crates.io | snes-gfx |
lib.rs | snes-gfx |
version | 0.1.5 |
source | src |
created_at | 2024-09-23 15:09:38.559053 |
updated_at | 2024-09-27 13:55:54.831737 |
description | A library for processing SNES-graphics data and nametables. |
homepage | |
repository | https://github.com/NibbleOfAnOctet/shadowresources/tree/main/libs/snes-gfx |
max_upload_size | |
id | 1384211 |
size | 11,384 |
The tool uses data in the original LittleEndian SNES formats. The tool can convert 2BPP, 4BPP and 8BPP tiles as well as and tilemaps into RGB images. The crate is under construction and stuff will definitely break between versions.
The library is coded as a learning experience, and will probably not follow best-practices.
use snes_gfx::{
palette::{Format, Palette},
tilemap::Tilemap,
tileset::{Tileset, TilesetIterators, TilesetTrait},
};
[...]
// Load necessary data from little endian byte data.
let palette = Palette::new(&palette_data);
let tileset = Tileset::new(&tileset_data, format);
let tilemap = Tilemap::new(&tilemap_data);
// Generate tilemap
tilemap
.generate_image(32, &tileset, &palette)
.save("tilemap.png")
.expect("Could not save tilemap image!");
// Create an iterator over tileset images
let images = tileset.image_iter(1, &palette);
// Merge into tileset 16 tiles wide
Tileset::merge_tiles(&images.collect(), 16)
.save("tileset.png")
.expect("Could not save tileset image!");