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

#2291 in Parser implementations

33 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

~11MB
~58K SLoC