Skip to main content

Crate rustydemon_blp2

Crate rustydemon_blp2 

Source
Expand description

§rustydemon-blp2

A Rust library for reading BLP texture files (BLP0, BLP1, BLP2).

BLP is a texture format used in several popular games. This crate parses all three format versions and all standard color encodings, returning decoded pixels as raw RGBA bytes.

§Quick start

use rustydemon_blp2::BlpFile;

let blp = BlpFile::open("texture.blp")?;
println!("{}×{}, {} mip level(s)", blp.width, blp.height, blp.mipmap_count());

// Decode the base (largest) mipmap — always RGBA, 4 bytes per pixel.
let (pixels, w, h) = blp.get_pixels(0)?;
assert_eq!(pixels.len(), (w * h * 4) as usize);

§Format support

FormatEncodingAlpha modes
BLP0 / BLP1Palette, DXT1/3/5, ARGB8888, JPEG0 / 1 / 4 / 8-bit
BLP2Palette, DXT1/3/5, ARGB8888, JPEG0 / 1 / 4 / 8-bit

§Output format

BlpFile::get_pixels always returns RGBA (red first, alpha last), 4 bytes per pixel, in row-major order. This differs from the on-disk ARGB8888 representation (which is BGRA) — the swap is applied automatically.

§Mipmaps

BLP files can store up to 16 mipmap levels. Level 0 is always the largest (base) image. Each successive level is half the dimensions of the previous one, clamped to a minimum of 1×1. Requesting a level beyond the available range silently clamps to the last valid level.

Re-exports§

pub use error::BlpError;

Modules§

error

Structs§

BlpFile
A parsed BLP texture file.

Enums§

ColorEncoding
How the pixel data inside a BLP file is encoded.
PixelFormat
The sub-format used when ColorEncoding is Dxt.