BLP file

101,313pages on
this wiki

Redirected from BLP Files

WoW AddOn

A BLP file is a texture file format known to be used for games, including many Blizzard games such as World of Warcraft.

The BLP file structure consists of a header including the palette, and up to 16 pre-rendered 'mipmaps'. Texture sizes must be powers of two, though the two dimensions do not have to be equal; 512x256 is valid, but 512x200 is not. The first mipmap ('mipmap' level 0) is the full size image; each subsequent mipmap halves both dimensions. The final 'mipmap' should normally be 1x1.

Structure Edit

BLP version 2 header Edit

struct blp2header {
  uint8_t    ident[4];           // "BLP2" magic number
  uint32_t   type;               // 0 = JPG, 1 = BLP / DXTC / Uncompressed
  uint8_t    compression;        // 1 = BLP, 2 = DXTC, 3 = Uncompressed
  uint8_t    alpha_depth;        // 0, 1, 4, or 8
  uint8_t    alpha_type;         // 0, 1, 7, or 8
  uint8_t    has_mips;           // 0 = no mips, 1 = has mips
  uint32_t   width;              // Image width in pixels, usually a power of 2
  uint32_t   height;             // Image height in pixels, usually a power of 2
  uint32_t   mipmap_offsets[16]; // The file offsets of each mipmap, 0 for unused
  uint32_t   mipmap_lengths[16]; // The length of each mipmap data block
  uint32_t   palette[265];       // A set of 256 ARGB values used as a color palette
} blp2header;

Notes Edit

  • The actual number of 'mip' levels determined by image size
  • For WoW 'type' should always be 1. WoW does not currently use JPG format. BLP files using JPG compression is beyond the scope of this article.
  • WoW has shipped with a small number of BLPs with dimensions that are not powers of two; 768x128 is used for many cube map textures, for example. In this case, the final stored mipmap may not be 1x1. (this last part may not be accurate)
  • Compression type 3 'Uncompressed' appeared in Cataclysm, and data layout is canonical A8R8G8B8, which is essentially uncompressed 24-bit color with 8-bit alpha.
  • The header always includes a 256-entry color table. Each entry a 32-bit BGRA 8888 value. This table is only used for BLP format image data, but is present in all BLPs regardless.

Compression Edit

BLP, DXT1, DXT3, DXT5 or Uncompressed 8-bit per channel ARGB.

BLP compression Edit

This is the BLP specific image format, where the 'compression' is via the use of a palette, and the use of alpha flags where 'alpha' data is omitted if flags indicate that there is no alpha data at the end of the regular image data for a given 'mip' level.

If 'compression' is 1, each mipmap is stored as an array of 8-bit values, one per pixel, left to right, top to bottom. Each value is an index to the palette.

If 'alpha_depth' is > 0, an alpha channel will immediately follow the image data, and comes in 1, 4, and 8 bit varieties. The 1 and 4 bit versions have multiple values packed into a single byte, with the least significant bit belonging to the first packed value.

Uncompressed Edit

If 'compression' is 3, each mipmap contains plain 32-bit BGRA data.

The 'alpha_depth' flag represents a set of bit flags rather than depth, as all images of this type seem to have 4 bytes per pixel regardless of depth, and it has been seen to exceed 8. Their meaning is unknown.

DXTC compression Edit

DXT is an industry standard texture compression format, designed originally for efficiency in real time graphics rendering and decompression in hardware. Most current 3D hardware supports loading some form of DXTC data directly. See Wikipedia's entry on DXT compression for more detail.

If 'compression' is 2, each mipmap is composed of 4×4 blocks of pixels. The blocks and the pixels within each block are ordered from left to right, top to bottom.

DXT1 Edit

If 'alpha_type' is 0, then DXT1 compression is used.

Each block is 64 bits and begins with two 16 bit values, and are used to derived a 4 color palette. The values are interpreted as 565 RGB colors, with the least significant bits corresponding to blue, to create the first two colors in the palette.

If the first value is less than or equal to the second, the final entry of the palette is reserved. If 'alpha_depth' is 0, the reserved color is black. If 'alpha_depth' is 1, the reserved color is transparent. The remaining colors are created by interpolating between the first two colors in the palette. The remaining 32 bits are 16 2-bit values acting as a lookups to specify the colors in the block.

DXT3 Edit

If 'alpha_type' is 1, then DXT3 compression is used.

Each block is 128 bits and begins identically to DXT1, except that no special color is reserved in the palette. It is followed by 16 4-bit values corresponding to the alpha values for each of the pixels in the block.

DXT5 Edit

If 'alpha_type' is 7, then DXT5 compression is used. This format was first used for Burning Crusade images.

Each block is 128 bits and begins with two 8-bit values to create an 8 element lookup table for alpha values. The first two elements in the lookup table are copies of those values. If the first value is less than or equal to the second, the final two entries of the lookup table are reserved for transparent and opaque. The remaining entries are created by interpolating between the first two entries in the lookup table. The next 48 bits make up 16 3-bit values acting as lookups specifying the alpha values for each of the pixels in the block. The remaining 64 bits are identical to DXT1, except that no special color is reserved in the palette.

Sample Files Edit

Below is a list of BLP files, each with some unique characteristic.

File Encoding Features
Interface\GLUES\LoadingBar\Loading-BarGlow.blp BLP No alpha
Interface\CURSOR\Attack.blp BLP 1-bit alpha
Interface\CURSOR\Buy.blp BLP 8-bit alpha
Interface\Icons\Trade_Alchemy.blp DXT1 No alpha
Interface\AuctionFrame\BuyoutIcon.blp DXT1 1-bit alpha
Interface\Icons\INV_Fishingpole_02.blp DXT3 4-bit alpha
Interface\Icons\Ability_Rogue_Shadowstep.blp DXT5 8-bit alpha
Interface\BUTTONS\UI-PaidCharacterCustomization-Button.blp Uncomp BGRA color

The following files require an MPQ viewer to access, as they aren't exposed by Blizzard's AddOn Kit.

File Encoding Features
Character\Tauren\Female\TAURENFEMALESKIN00_01_EXTRA.blp BLP 4-bit alpha
Environments\Stars\HellFireSkyNebula03.blp DXT5 No alpha
Textures\SunGlare.blp Uncomp alpha_depth=136
TILESET\Terrain Cube Maps\TCB_CrystalSong_A.blp DXT1 width=768
TILESET\Terrain Cube Maps\oilslickenvA.blp Uncomp alpha_depth=1

Conversion tools Edit

There exist BLP tools to convert both from and to the BLP format. They can be found in UI Authors resource list.

See Also Edit

Around Wikia's network

Random Wiki