Wikia

WoWWiki

Changes: BLP file

Edit

Back to page

(DXTC compression)
 
(40 intermediate revisions by one user not shown)
Line 1: Line 1:
 
{{uiaddon}}
 
{{uiaddon}}
   
'''BLP files''' are Blizzard's texture format, used for many games. ''World of Warcraft'' uses the BLP2 format in particular. The BLP file structure consists of a header, up to 16 mipmaps of the texture, and a palette. 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 #0) is the full size image; each subsequent mipmap halves both dimensions. The final mipmap should be 1x1.
+
A [[BLP file]] is a texture file format known to be used for games, including many Blizzard games such as ''World of Warcraft''.
   
It should be noted that ''World of Warcraft'' does ship a small number of BLP files with dimensions that are not powers of two; 768x128 is used for many cube map textures, for example. In this case, the final mipmap may not be 1x1.
+
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.
   
=== The .BLP header ===
+
== Structure ==
  +
  +
=== BLP version 2 header ===
 
struct blp2header {
 
struct blp2header {
 
uint8_t ident[4]; // "BLP2" magic number
 
uint8_t ident[4]; // "BLP2" magic number
uint32_t type; // Texture type: 0 = JPG, 1 = S3TC
+
uint32_t type; // 0 = JPG, 1 = BLP / DXTC / Uncompressed
uint8_t compression; // Compression mode: 1 = raw, 2 = DXTC
+
uint8_t compression; // 1 = BLP, 2 = DXTC, 3 = Uncompressed
uint8_t alpha_bits; // 0, 1, 4, or 8
+
uint8_t alpha_depth; // 0, 1, 4, or 8
 
uint8_t alpha_type; // 0, 1, 7, or 8
 
uint8_t alpha_type; // 0, 1, 7, or 8
uint8_t has_mips; // 0 = no mips levels, 1 = has mips (number of levels determined by image size)
+
uint8_t has_mips; // 0 = no mips, 1 = has mips
uint32_t width; // Image width in pixels
+
uint32_t width; // Image width in pixels, usually a power of 2
uint32_t height; // Image height in pixels
+
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_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 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;
 
} blp2header;
  +
  +
==== Notes ====
  +
* 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.
   
''World of Warcraft'' does not use JPG textures. A discussion of BLP files using JPG compression is beyond the scope of this article. The type flag should always be 1, which indicates the use of either RAW, DXT1, DXT3, or DXT5 compression. Each compression type will be covered separately.
+
== Compression ==
   
=== The .BLP color palette ===
+
BLP, DXT1, DXT3, DXT5 or Uncompressed 8-bit per channel ARGB.
The header is always followed by a 256-entry color table. Each entry a 32-bit BGRA 8888 value. This table is only used for RAW images, but is present in all BLPs regardless.
 
   
=== RAW compression ===
+
=== BLP compression ===
   
==== RAW1 ====
+
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 <tt>compression</tt> is set to 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 '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 <tt>alpha_bits</tt> is greater than 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.
+
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.
   
==== RAW3 ====
+
=== Uncompressed ===
   
With the <tt>compression</tt> set to 3, each mipmap contains what appears to be 32 bit BGRA data. <tt>alpha_bits</tt> seems to represent 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.
+
If 'compression' is 3, each mipmap contains plain 32-bit BGRA data.
   
=== DXTn compression ===
+
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.
   
If <tt>compression</tt> is set to 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.
+
=== DXTC compression ===
   
See [[Wikipedia:S3TC|Wikipedia's entry on DXT compression]] for the technical details.
+
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:S3TC|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 ====
 
==== DXT1 ====
   
If <tt>alpha_type</tt> is 0, then DXT1 compression is used.
+
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.
+
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.
   
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.
 
If the first value is less than or equal to the second, the final entry of the palette is reserved. If <tt>alpha_bits</tt> is 0, the reserved color is black. If <tt>alpha_bits</tt> 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 ====
 
==== DXT3 ====
   
If <tt>alpha_type</tt> is 1, then DXT3 compression is used.
+
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.
+
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 ====
 
==== DXT5 ====
   
If <tt>alpha_type</tt> is 7, then DXT5 compression is used. This format was first used for Burning Crusade images.
+
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.
+
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.
   
The first two elements in the lookup table are copies of those values.
+
== Sample Files ==
 
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 ===
 
   
 
Below is a list of BLP files, each with some unique characteristic.
 
Below is a list of BLP files, each with some unique characteristic.
Line 68: Line 76:
 
! File !! Encoding !! Features
 
! File !! Encoding !! Features
 
|-
 
|-
| GLUES\LoadingBar\Loading-BarGlow.blp || RAW1 || No alpha
+
| Interface\GLUES\LoadingBar\Loading-BarGlow.blp || BLP || No alpha
 
|-
 
|-
| CURSOR\Attack.blp || RAW1 || 1-bit alpha
+
| Interface\CURSOR\Attack.blp || BLP || 1-bit alpha
 
|-
 
|-
| CURSOR\Buy.blp || RAW1 || 8-bit alpha
+
| Interface\CURSOR\Buy.blp || BLP || 8-bit alpha
 
|-
 
|-
| Icons\Trade_Alchemy.blp || DXT1 || No alpha
+
| Interface\Icons\Trade_Alchemy.blp || DXT1 || No alpha
 
|-
 
|-
| AuctionFrame\BuyoutIcon.blp || DXT1 || 1-bit alpha
+
| Interface\AuctionFrame\BuyoutIcon.blp || DXT1 || 1-bit alpha
 
|-
 
|-
| Icons\INV_Fishingpole_02.blp || DXT3 || 4-bit alpha
+
| Interface\Icons\INV_Fishingpole_02.blp || DXT3 || 4-bit alpha
 
|-
 
|-
| Icons\Ability_Rogue_Shadowstep.blp || DXT5 || 8-bit alpha
+
| Interface\Icons\Ability_Rogue_Shadowstep.blp || DXT5 || 8-bit alpha
 
|-
 
|-
| BUTTONS\UI-PaidCharacterCustomization-Button.blp || RAW3 || BGRA color
+
| Interface\BUTTONS\UI-PaidCharacterCustomization-Button.blp || Uncomp || BGRA color
 
|}
 
|}
   
Line 90: Line 98:
 
! File !! Encoding !! Features
 
! File !! Encoding !! Features
 
|-
 
|-
| Character\Tauren\Female\TAURENFEMALESKIN00_01_EXTRA.blp || RAW1 || 4-bit alpha
+
| Character\Tauren\Female\TAURENFEMALESKIN00_01_EXTRA.blp || BLP || 4-bit alpha
 
|-
 
|-
 
| Environments\Stars\HellFireSkyNebula03.blp || DXT5 || No alpha
 
| Environments\Stars\HellFireSkyNebula03.blp || DXT5 || No alpha
 
|-
 
|-
| Textures\SunGlare.blp || RAW3 || alpha_bits=136
+
| Textures\SunGlare.blp || Uncomp|| alpha_depth=136
 
|-
 
|-
 
| TILESET\Terrain Cube Maps\TCB_CrystalSong_A.blp || DXT1 || width=768
 
| TILESET\Terrain Cube Maps\TCB_CrystalSong_A.blp || DXT1 || width=768
 
|-
 
|-
| TILESET\Terrain Cube Maps\oilslickenvA.blp || RAW3 || alpha_bits=1
+
| TILESET\Terrain Cube Maps\oilslickenvA.blp || Uncomp|| alpha_depth=1
 
|}
 
|}
   
=== Conversion tools ===
+
== Conversion tools ==
 
There exist BLP tools to convert both from and to the BLP format. They can be found in [[UI FAQ/AddOn Author Resources#Resources|UI Authors resource list]].
 
There exist BLP tools to convert both from and to the BLP format. They can be found in [[UI FAQ/AddOn Author Resources#Resources|UI Authors resource list]].
  +
  +
== See Also ==
  +
* [[Wikipedia:.BLP|Wikipedia - BLP Format]]
  +
* [http://www.pxr.dk/wowdev/wiki/index.php?title=BLP WoWDev - BLP Format]
  +
* [[Wikipedia:S3TC|Wikipedia's entry on DXT compression]]

Latest revision as of 02:45, July 16, 2013

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