gvrtex

Crates.iogvrtex
lib.rsgvrtex
version0.1.2
created_at2025-04-18 00:35:17.797622+00
updated_at2025-09-19 04:31:50.609762+00
descriptiongvrtex is a library for interfacing with the GVR texture format used on GameCube/Wii
homepage
repositoryhttps://github.com/Exortile/gvrtex
max_upload_size
id1638687
size102,844
Sten-Kristjan Prantsu (Exortile)

documentation

README

gvrtex

gvrtex is a Rust library for interfacing with the GVR texture format used in GameCube/Wii games, for example Sonic Riders. It's essentially the same as a regular TPL texture file (the official texture file format for GameCube/Wii), but with GVR headers instead. The image data in the file remains the same as it is for TPL files, so that the game console can read it.

More details on the GVR texture format can be found on the PuyoTools Wiki.

Examples

To encode an image into a GVR file (the supported image formats can be found here):

use gvrtex::error::TextureEncodeError;
use gvrtex::formats::DataFormat;
use gvrtex::TextureEncoder;

fn example(img_path: &str) -> Result<Vec<u8>, TextureEncodeError> {
    let mut encoder = TextureEncoder::new_gcix(DataFormat::Dxt1)?;
    let encoded_file = encoder.encode(img_path)?;
    Ok(encoded_file)
}

To encode a GVR file with a quantized color palette (can be 4-bit indexed or 8-bit indexed):

use gvrtex::error::TextureEncodeError;
use gvrtex::formats::{DataFormat, PixelFormat};
use gvrtex::TextureEncoder;

fn example(img_path: &str) -> Result<Vec<u8>, TextureEncodeError> {
    let mut encoder = TextureEncoder::new_gcix_palettized(PixelFormat::RGB5A3, DataFormat::Index8)?;
    let encoded_file = encoder.encode(img_path)?;
    Ok(encoded_file)
}

To decode a GVR file into the respective image file:

use gvrtex::error::TextureDecodeError;
use gvrtex::TextureDecoder;

fn example(gvr_path: &str, save_path: &str) -> Result<(), TextureDecodeError> {
    // Reads the contents of the file in gvr_path, but doesn't decode it yet.
    let mut decoder = TextureDecoder::new(gvr_path)?;

    // Decode file, saving the result in the decoder
    decoder.decode()?;

    // Save the decoded image to the given path. The image format is derived from the file
    // extension in the path.
    decoder.save(save_path)?;

    Ok(())
}

Credits

  • PuyoTools for the internal encoding and decoding algorithms, as well as information on the GVR file format.
Commit count: 26

cargo fmt