Crate wow_blp

Crate wow_blp 

Source
Expand description

Parser for World of Warcraft BLP (texture) files.

This crate provides support for reading and writing BLP texture files used in World of Warcraft and Warcraft III. BLP is Blizzard’s proprietary texture format that supports various compression methods including JPEG compression, palettized images, and DXT compression.

§Supported Versions

  • BLP0 - Used in Warcraft III ROC Beta builds
  • BLP1 - Common in Warcraft III TFT (versions 1.12.1+)
  • BLP2 - Used in World of Warcraft (versions 1.12.1 through 5.4.8)

§Supported Encodings

  • RAW1 - Palettized images with 256 colors
  • RAW3 - Uncompressed RGBA bitmaps
  • JPEG - JPEG compressed images
  • DXTn - S3TC compression algorithms (BLP2 only)

§Examples

§Loading a BLP file

use wow_blp::{parser::load_blp, convert::blp_to_image};

let blp_file = load_blp("texture.blp").expect("Failed to load BLP");
let mipmap_level = 0;
let image = blp_to_image(&blp_file, mipmap_level).expect("Failed to convert");

§Saving an image as BLP

use image::DynamicImage;
use wow_blp::{
    convert::{image_to_blp, BlpTarget, BlpOldFormat, AlphaBits, FilterType},
    encode::save_blp,
};

let make_mipmaps = true;
let target = BlpTarget::Blp1(BlpOldFormat::Raw1 {
    alpha_bits: AlphaBits::Bit1,
});
let blp = image_to_blp(image, make_mipmaps, target, FilterType::Nearest)
    .expect("Failed to convert");
save_blp(&blp, "output.blp").expect("Failed to save");

§wow-blp

Parser and encoder for Blizzard BLP texture files used in Warcraft III and World of Warcraft.

Crates.io Version docs.rs License

§Status

Implemented - Full BLP parsing and encoding functionality.

§Features

  • Parse and encode all BLP versions (BLP0, BLP1, BLP2)
  • Support for all compression formats:
    • JPEG compression with alpha channel
    • RAW1 (256-color palettized) with 0/1/4/8-bit alpha
    • RAW3 (uncompressed BGRA)
    • DXT1/3/5 compression (S3TC)
  • Mipmap support (internal and external)
  • Convert between BLP and standard image formats
  • High-performance DXT compression using texpresso

§Supported Versions

  • BLP0 - Warcraft III Beta (external mipmaps)
  • BLP1 - Warcraft III (1.x+)
  • BLP2 - World of Warcraft (all versions)
    • Classic (1.12.1)
    • The Burning Crusade (2.4.3)
    • Wrath of the Lich King (3.3.5a)
    • Cataclysm (4.3.4)
    • Mists of Pandaria (5.4.8)

§Installation

Add to your Cargo.toml:

[dependencies]
wow-blp = "0.3.0"

Or use cargo add:

cargo add wow-blp

§Usage

§Loading BLP Files

use wow_blp::{parser::load_blp, convert::blp_to_image};

// Load BLP file
let blp_file = load_blp("texture.blp")?;

// Convert to standard image format
let image = blp_to_image(&blp_file, 0)?; // mipmap level 0

// Save as PNG
image.save("texture.png")?;

§Creating BLP Files

use wow_blp::{
    convert::{image_to_blp, BlpTarget, Blp2Format, DxtAlgorithm},
    encode::save_blp,
};
use image::imageops::FilterType;

// Load source image
let image = image::open("input.png")?;

// Convert to BLP2 with DXT5 compression
let blp = image_to_blp(
    image,
    true, // generate mipmaps
    BlpTarget::Blp2(Blp2Format::Dxt5 {
        has_alpha: true,
        compress_algorithm: DxtAlgorithm::ClusterFit,
    }),
    FilterType::Lanczos3
)?;

// Save BLP file
save_blp(&blp, "output.blp")?;

§Format Options

use wow_blp::convert::{BlpTarget, BlpOldFormat, Blp2Format, AlphaBits, DxtAlgorithm};

// BLP0 (Warcraft III Beta) - External mipmaps
let blp0 = BlpTarget::Blp0(BlpOldFormat::Jpeg { has_alpha: true });

// BLP1 (Warcraft III) - Palettized
let blp1 = BlpTarget::Blp1(BlpOldFormat::Raw1 {
    alpha_bits: AlphaBits::Bit8
});

// BLP2 (World of Warcraft) - DXT compression
let blp2_dxt = BlpTarget::Blp2(Blp2Format::Dxt5 {
    has_alpha: true,
    compress_algorithm: DxtAlgorithm::ClusterFit
});

// BLP2 - Uncompressed
let blp2_raw = BlpTarget::Blp2(Blp2Format::Raw3);

§Working with Mipmaps

use wow_blp::{parser::load_blp, convert::blp_to_image};

// Load BLP file first
let blp_file = load_blp("texture.blp")?;

// Access specific mipmap level
let mipmap_2 = blp_to_image(&blp_file, 2)?;

// Get mipmap count
let count = blp_file.header.mipmaps_count();

// For BLP0, external mipmap files are handled automatically
// texture.blp → texture.b00, texture.b01, etc.

§Examples

See the examples directory for more usage examples:

  • load.rs - Load and convert BLP to PNG
  • save.rs - Convert PNG to BLP

§Performance

  • DXT compression/decompression is parallelized using rayon
  • Direct GPU upload support for DXT formats
  • Efficient palette quantization for RAW1 format

§License

Licensed under either of

at your option.

§Credits

Based on the image-blp crate by zloy_tulen.

Re-exports§

pub use types::*;

Modules§

convert
Conversion utilities to/from DynamicImage
encode
Encoding BLP format into stream of bytes
parser
Decoding BLP format from raw bytes
path
Utilities for mipmaps filename generation
types
Defines structure of parsed BLP file