7 releases

0.7.0 Feb 19, 2024
0.6.0 Feb 4, 2022
0.0.5 May 29, 2021
0.0.3 Feb 5, 2020
0.0.2 Jan 31, 2020

#898 in Parser implementations

Download history 115/week @ 2024-02-14 55/week @ 2024-02-21 21/week @ 2024-02-28 3/week @ 2024-03-06 12/week @ 2024-03-13 17/week @ 2024-03-27 31/week @ 2024-04-03

61 downloads per month

MIT license

31KB
528 lines

nutexb

Nutexb is an image texture format used in Super Smash Bros Ultimate and some other games. The extension ".nutexb" may stand for "Namco Universal Texture Binary".

Image data is stored in a contiguous region of memory with metadata stored in the layer_mipmaps and footer. The supported image formats in [NutexbFormat] use standard compressed and uncompressed formats used for DDS files. The arrays and mipmaps for the image data are stored in a memory layout optimized for the Tegra X1 in a process known as swizzling. This library provides tools for reading and writing nutexb files as well as working with the swizzled image data.

Reading

Read a [NutexbFile] with NutexbFile::read or NutexbFile::read_from_file. The image data needs to be deswizzled first with NutexbFile::deswizzled_data to use with applications that expect a standard row-major memory layout.

use nutexb::NutexbFile;

let nutexb = NutexbFile::read_from_file("col_001.nutexb")?;
let surface_data = nutexb.deswizzled_data();

Writing

The easiest way to create a [NutexbFile] is by calling NutexbFile::from_dds and NutexbFile::from_image when using the "ddsfile" and "image" features, respectively. For manually specifying the surface dimensions and data, use NutexbFile::from_surface.

use nutexb::NutexbFile;

let image = image::open("col_001.png")?;

let nutexb = NutexbFile::from_image(&image.to_rgba8(), "col_001")?;
nutexb.write_to_file("col_001.nutexb")?;
use nutexb::NutexbFile;

let mut reader = std::io::BufReader::new(std::fs::File::open("cube.dds")?);
let dds = ddsfile::Dds::read(&mut reader)?;

let nutexb = NutexbFile::from_dds(&dds, "cube")?;
nutexb.write_to_file("col_001.nutexb")?;

Dependencies

~1.5–4.5MB
~53K SLoC