wow_blp/
lib.rs

1//! Parser for World of Warcraft BLP (texture) files.
2//!
3//! This crate provides support for reading and writing BLP texture files used in
4//! World of Warcraft and Warcraft III. BLP is Blizzard's proprietary texture format
5//! that supports various compression methods including JPEG compression, palettized
6//! images, and DXT compression.
7//!
8//! # Supported Versions
9//!
10//! - **BLP0** - Used in Warcraft III ROC Beta builds
11//! - **BLP1** - Common in Warcraft III TFT (versions 1.12.1+)
12//! - **BLP2** - Used in World of Warcraft (versions 1.12.1 through 5.4.8)
13//!
14//! # Supported Encodings
15//!
16//! - **RAW1** - Palettized images with 256 colors
17//! - **RAW3** - Uncompressed RGBA bitmaps
18//! - **JPEG** - JPEG compressed images
19//! - **DXTn** - S3TC compression algorithms (BLP2 only)
20//!
21//! # Examples
22//!
23//! ## Loading a BLP file
24//!
25//! ```no_run
26//! use wow_blp::{parser::load_blp, convert::blp_to_image};
27//!
28//! let blp_file = load_blp("texture.blp").expect("Failed to load BLP");
29//! let mipmap_level = 0;
30//! let image = blp_to_image(&blp_file, mipmap_level).expect("Failed to convert");
31//! ```
32//!
33//! ## Saving an image as BLP
34//!
35//! ```no_run
36//! use image::DynamicImage;
37//! use wow_blp::{
38//!     convert::{image_to_blp, BlpTarget, BlpOldFormat, AlphaBits, FilterType},
39//!     encode::save_blp,
40//! };
41//!
42//! # let image = DynamicImage::new_rgba8(256, 256);
43//! let make_mipmaps = true;
44//! let target = BlpTarget::Blp1(BlpOldFormat::Raw1 {
45//!     alpha_bits: AlphaBits::Bit1,
46//! });
47//! let blp = image_to_blp(image, make_mipmaps, target, FilterType::Nearest)
48//!     .expect("Failed to convert");
49//! save_blp(&blp, "output.blp").expect("Failed to save");
50//! ```
51
52#![doc = include_str!("../README.md")]
53#![forbid(unsafe_code)]
54#![warn(missing_docs)]
55#![cfg_attr(docsrs, feature(doc_cfg))]
56
57/// Conversion utilities to/from DynamicImage
58pub mod convert;
59/// Encoding BLP format into stream of bytes
60pub mod encode;
61/// Decoding BLP format from raw bytes
62pub mod parser;
63/// Utilities for mipmaps filename generation
64pub mod path;
65/// Defines structure of parsed BLP file
66pub mod types;
67
68pub use types::*;