wowlib 0.0.0
Read & write World of Warcraft client files — a C++26 core
Loading...
Searching...
No Matches
blp.hpp File Reference

The BLP entity (namespace wowlib::formats::blp): Blizzard's texture format. More...

#include <algorithm>
#include <array>
#include <cstddef>
#include <cstdint>
#include <span>
#include <type_traits>
#include <vector>
#include <welder/vocabulary.hpp>
#include <wowlib/core/buffer.hpp>
#include <wowlib/core/error.hpp>
#include <wowlib/core/file_key.hpp>
#include <wowlib/formats/common/fourcc.hpp>
#include <wowlib/formats/common/types.hpp>
#include <wowlib/formats/common/validation.hpp>
#include <wowlib/fs/filesystem.hpp>
#include <wowlib/formats/common/file_entity.hpp>
Include dependency graph for blp.hpp:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Classes

struct  wowlib::formats::blp::detail::BLPHeader
 The 148-byte BLP2 file header, exactly as on disk (the 1024-byte palette follows it). More...
struct  wowlib::formats::blp::detail::StoredLayout
 The on-disk placement a read recorded, replayed by write() while the payloads are unmodified so unusual files (inter-mip gaps, trailing bytes, non-contiguous or shared mip placement) still round-trip byte-perfectly. More...
struct  wowlib::formats::blp::detail::StoredLayout::Run
 One run of file bytes covered by neither the header region nor any mip payload (an inter-mip gap or a trailing tail). More...
struct  wowlib::formats::blp::Image
struct  wowlib::formats::blp::EncodeSettings
struct  wowlib::formats::blp::BLP

Namespaces

namespace  wowlib
namespace  wowlib::formats
namespace  wowlib::formats::blp
namespace  wowlib::formats::blp::detail

Enumerations

enum class  wowlib::formats::blp::ColorEncoding : std::uint8_t {
  wowlib::formats::blp::Jpeg = 0 , wowlib::formats::blp::Palettized = 1 , wowlib::formats::blp::Dxt = 2 , wowlib::formats::blp::Bgra = 3 ,
  wowlib::formats::blp::BgraAlt = 4
}
 How a BLP's pixel payload is encoded (the header's colorEncoding byte). More...
enum class  wowlib::formats::blp::PixelFormat : std::uint8_t {
  wowlib::formats::blp::Dxt1 = 0 , wowlib::formats::blp::Dxt3 = 1 , wowlib::formats::blp::Argb8888 = 2 , wowlib::formats::blp::Argb1555 = 3 ,
  wowlib::formats::blp::Argb4444 = 4 , wowlib::formats::blp::Rgb565 = 5 , wowlib::formats::blp::A8 = 6 , wowlib::formats::blp::Dxt5 = 7 ,
  wowlib::formats::blp::Unspecified = 8 , wowlib::formats::blp::Argb2565 = 9 , wowlib::formats::blp::Bc5 = 11
}
 The client-side pixel format hint (the header's preferredFormat byte). More...

Variables

constexpr std::uint32_t wowlib::formats::blp::BlpMagic = fourcc("BLP2", FourCCEndian::Forward)
 The BLP2 magic: the literal bytes "BLP2" (a forward FourCC, unlike the reversed chunk ids).
constexpr std::uint32_t wowlib::formats::blp::BlpVersion1 = 1
 The BLP2 header version field; always 1 in every shipped client.
constexpr std::size_t wowlib::formats::blp::BlpMaxMips = 16
 The mip table capacity: a BLP addresses at most 16 levels.
constexpr std::size_t wowlib::formats::blp::BlpPaletteSize = 256
 The palette entry count (one byte-sized index space).
constexpr std::size_t wowlib::formats::blp::BlpHeaderBytes = 0x494
 The full header region: 148-byte header + 1024-byte palette.

Detailed Description

The BLP entity (namespace wowlib::formats::blp): Blizzard's texture format.

A BLP2 file is NOT chunked: a fixed 148-byte header + 1024-byte palette (0x494 bytes total) is followed by up to 16 mipmap payloads located by the header's offset/size tables. The pixel payload is palettized (256-color indices + a separate 0/1/4/8-bit alpha plane), DXT-compressed (BC1/BC2/BC3, and BC5 in later clients), or raw BGRA. The format is version-stable across every WoW release — vanilla through The War Within read the same layout — so unlike the chunked formats the entity carries no ClientVersion axis.

wowlib stores the mip payloads verbatim (byte-perfect round-trip: the original mip placement, inter-mip gaps and trailing bytes are preserved and replayed while the payloads are unmodified) and moves pixels through the codec classes in codec.hpp: decode() produces a top-left row-major RGBA8 Image from any stored level, encode() rebuilds the whole file — palette quantization, DXT compression (stb_dxt) and the mip chain — from one.

See also
https://wowdev.wiki/BLP

Definition in file blp.hpp.