BLP文件格式

.BLP files are texture files used in games made by Blizzard Entertainment, also used in other games like Neverwinter Nights. While Blizzard provides an Interface AddOn Kit for extracting the user interface files from the World of Warcraft .MPQs, they do not provide a utility to view the .BLP files contained within. Also, .BLP graphics were used for Warcraft III, and are also stored within .MPQs.

Format
The file starts with a proprietary header, followed by the texture data. The texture data are typically stored in DXT1, DXT3, uncompressed or possibly DXT5. It is important to note that the size of the image is a power of 2.

Converters

Several third party applications exist that can convert .BLP files to .tga files and vice versa. Some of the programs were made for Warcraft III textures, however, and don't work for all Blizzard game textures. These converters have become very important to the Warcraft III modding community, and have been the doorway to the vast amount of customised skins available for download.

Specification

Note that all types are little-endian.
Only the BLP2 format is shown here; for the BLP1 format, refer to BLP version 1 format specifications

BLP2 Format

  1. struct BLP2Header
  2. {
  3.     FourCC      ID; // Always 'BLP2'
  4.     UInt32      Type;
  5.     UInt8       Encoding;
  6.     UInt8       AlphaDepth;
  7.     UInt8       AlphaEncoding;
  8.     UInt8       HasMips;
  9.     UInt32      Width;
  10.     UInt32      Height;
  11.     UInt32      Offsets[16];
  12.     UInt32      Lengths[16];
  13.     RGBAColor8  Palette[256];
  14. };

Type
    0: JPEG compression
    1: Uncompressed or DirectX compression

Encoding
    1: Uncompressed
    2: DirectX compression

AlphaDepth
    0: No alpha channel
    1: 1 bit alpha
    8: 8 bit alpha

AlphaEncoding
    0: DXT1 alpha (0 or 1 bit alpha)
    1: DXT2/3 alpha (4 bit alpha)
    7: DXT4/5 alpha (interpolated alpha)

HasMips
    0: No mip levels
    1: Mip levels present (the number of levels is determined by the image size)

Width, Height: Dimensions of the image in pixels (always a power of two)

Offsets[0]: Offset from the start of the file to the image data
Lengths[0]: Length in bytes of the image data
Palette: 4-byte BGRA color values for paletted textures (this field is present regardless of whether the texture actually uses palettes


Type 1 Encoding 1 AlphaDepth 0 (uncompressed paletted image with no alpha)

Each byte of the image data is an index into Palette which contains the actual RGB value for the pixel. Although the palette entries are 32-bits, the alpha value of each Palette entry may contain garbage and should be discarded.

Type 1 Encoding 1 AlphaDepth 1 (uncompressed paletted image with 1-bit alpha)

This is the same as Type 1 Encoding 1 AlphaDepth 0 except that immediately following the index array is a second image array containing 1-bit alpha values for each pixel. The first byte of the array is for pixels 0 through 7, the second byte for pixels 8 through 15 and so on. Bit 0 of each byte corresponds to the first pixel (leftmost) in the group, bit 7 to the rightmost. A set bit indicates the pixel is opaque while a zero bit indicates a transparent pixel.

Type 1 Encoding 1 AlphaDepth 8 (uncompressed paletted image with 8-bit alpha)

This is the same as Type 1 Encoding 1 AlphaDepth 0 except that immediately following the index array is a second image array containing the actual 8-bit alpha values for each pixel. This second array starts at BLP2Header.Offset[0] + BLP2Header.Width * BLP2Header.Height.

Type 1 Encoding 2 AlphaDepth 0 (DXT1 no alpha)

The image data are formatted using DXT1 compression with no alpha channel.

Type 1 Encoding 2 AlphaDepth 1 (DXT1 one bit alpha)

The image data are formatted using DXT1 compression with a one-bit alpha channel.

Type 1 Encoding 2 AlphaDepth 8 AlphaEncoding 1(DXT3)

The image data are formatted using DXT3 compression.

Type 1 Encoding 2 AlphaDepth 8 AlphaEncoding 7(DXT5)

The image data are formatted using DXT5 compression.

External links

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
### 回答1: BLP2Header 是一种数据结构体,用于表示 Warcraft III 游戏中的贴图文件格式。它包含了贴图文件的基本信息,例如文件类型、尺寸、压缩格式等。 下面是 BLP2Header 的定义: ``` struct BLP2Header { uint32_t signature; // 文件头标识, 固定为 "BLP2" uint32_t type; // 文件类型, 固定为 1 uint32_t flags; // 文件属性 uint32_t width; // 图像宽度 uint32_t height; // 图像高度 uint32_t mipmap_offsets[16]; // 各级贴图数据的偏移量 uint32_t mipmap_sizes[16]; // 各级贴图数据的大小 uint32_t jpeg_data_size; // JPEG 图像数据大小 uint32_t jpeg_data_offset; // JPEG 图像数据偏移量 uint8_t alpha_depth; // Alpha 通道位深度, 0 表示没有 Alpha 通道 uint8_t alpha_type; // Alpha 通道类型 uint8_t has_mipmaps; // 是否有多级贴图 uint8_t four_cc[4]; // 压缩类型标识 }; ``` 其中,各个字段的含义如下: - `signature`:文件头标识,固定为 "BLP2"。 - `type`:文件类型,固定为 1。 - `flags`:文件属性,具体含义取决于实际使用的贴图文件。 - `width`:图像宽度,以像素为单位。 - `height`:图像高度,以像素为单位。 - `mipmap_offsets`:各级贴图数据的偏移量,用于多级贴图。 - `mipmap_sizes`:各级贴图数据的大小,用于多级贴图。 - `jpeg_data_size`:JPEG 图像数据大小,用于基于 JPEG 压缩的贴图。 - `jpeg_data_offset`:JPEG 图像数据偏移量,用于基于 JPEG 压缩的贴图。 - `alpha_depth`:Alpha 通道位深度,0 表示没有 Alpha 通道。 - `alpha_type`:Alpha 通道类型,具体含义取决于实际使用的贴图文件。 - `has_mipmaps`:是否有多级贴图。 - `four_cc`:压缩类型标识,用于指定贴图的压缩格式。 ### 回答2: BLP2Header 结构体是用于存储BLP2文件格式头部信息的数据结构。BLP2是一种用于存储游戏纹理的文件格式,主要用于魔兽世界等游戏。BLP2Header 结构体的定义一般如下: ``` struct BLP2Header { uint32_t magic; // 文件类型标识,通常为 "BLP2" uint32_t version; // 文件版本号,用于区分不同版本的BLP2文件 uint32_t flags; // 文件标志位,包含一些布尔值标志,用于指示文件的特性 uint32_t width; // 纹理的宽度 uint32_t height; // 纹理的高度 uint32_t mipmapOffsets[16]; // 各层级mipmap数据在文件中的偏移量 uint32_t mipmapSizes[16]; // 各层级mipmap数据的大小 uint32_t paletteType; // 调色板类型,表示纹理中使用的调色板类型 uint32_t alphaBits; // Alpha位数,表示每个像素的Alpha分量的位数 uint32_t alphaType; // Alpha类型,表示Alpha通道的编码方式 }; ``` BLP2Header 结构体中的成员变量用于存储BLP2文件头部的各个字段信息。其中,magic字段用于标识文件类型是否为BLP2格式;version字段表示文件的版本号;flags字段存储布尔值标志,用于表示文件的一些特性;width和height字段分别表示纹理的宽度和高度;mipmapOffsets和mipmapSizes数组分别存储各层级mipmap数据在文件中的偏移量和大小;paletteType字段表示纹理中使用的调色板类型;alphaBits字段表示每个像素的Alpha分量的位数;alphaType字段表示Alpha通道的编码方式。 通过解析BLP2Header结构体中的字段,可以获取到BLP2文件的关键信息,进而进行纹理的加载和处理等操作。 ### 回答3: BLP2Header 结构体是一种用于描述BLP2(Binary Large Palette)图像文件头部的数据结构。BLP2 是一种用于存储游戏中纹理图像的文件格式BLP2Header 结构体通常包含以下字段: 1. `uint32_t magicNumber`:魔数,用于标识BLP2文件的文件类型。它通常是一个特定的值,比如0x31504c42(ASCII码解读为"BLP1")。 2. `uint32_t version`:BLP2文件的版本号。它代表了该文件格式的兼容性和功能。 3. `uint32_t compression`:图像数据的压缩方式。它通常可以是以下几种取值之一:0代表无压缩,1代表将每一块区域进行了压缩(block compression)。 4. `uint32_t alphaDepth`:图像的Alpha通道深度。它表示Alpha通道所占的位数,用于描述图像的透明度。 5. `uint32_t alphaEncoding`:Alpha通道的编码方式。它指定了Alpha通道的编码方法,如DXT1、DXT3、DXT5等。 6. `uint32_t alphaOffset`:Alpha通道数据在文件中的偏移量。它表示Alpha通道数据在文件中的位置。 7. `uint32_t alphaSize`:Alpha通道数据的大小。它表示Alpha通道数据的占用空间。 8. `uint32_t alphaWidth`:Alpha通道的宽度。它表示Alpha通道数据的图像宽度。 9. `uint32_t alphaHeight`:Alpha通道的高度。它表示Alpha通道数据的图像高度。 10. `uint32_t width`:图像的宽度。它表示图像数据的图像宽度。 11. `uint32_t height`:图像的高度。它表示图像数据的图像高度。 12. `uint32_t mipMapOffset[16]`:各级别的MipMap偏移量。MipMap是一种多级别的图像金字塔结构,用于提高图像在不同缩放级别下的质量和表现。 这些字段用于描述BLP2文件的头部信息,以便读取和解码其中的图像数据。通过解析BLP2Header结构体的各个字段,我们可以获得图像的宽度、高度、Alpha通道信息等,从而进一步处理和渲染这些图像数据。

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值