找回密码
 点一下
查看: 2536|回复: 1

The BLP file format

[复制链接]
发表于 2008-6-20 15:15:51 | 显示全部楼层 |阅读模式
The BLP file contain the JPEG header and the JPEG raw data separated.
BLP stands for "Blip" file which I guess is a "BLIzzard Picture".
There are two types of BLPs:
- JPG-BLPs: use JPG compression
- Paletted BLPs: use palettes and 1 or 2 bytes per pixel depending

The general format of JPG-BLPs:

Header:
char[4]: file ID ("BLP1")
int: 0 for JPG-BLP, 1 for Paletted
int: 0x00000008 = has alpha, 0x00000000 = no alpha
int: image width
int: image height
int: flag for alpha channel and team colors (usually 3, 4 or 5), 3 and 4 means color and alpha information for paletted files,
5 means only color information, if >=5 on 'unit' textures, it won't show the team color.
int: always 0x00000001, if 0x00000000 the model that uses this texture will be messy.
int[16]: mipmap offset (offset from the begining of the file)
int[16]: mipmap size (size of mipmaps)

Header:char[4]: file ID ("BLP1")int: 0 for JPG-BLP, 1 for Palettedint: 0x00000008 = has alpha, 0x00000000 = no alphaint: image widthint: image heightint: flag for alpha channel and team colors (usually 3, 4 or 5), 3 and 4 means color and alpha information for paletted files,5 means only color information, if >=5 on 'unit' textures, it won't show the team color.int: always 0x00000001, if 0x00000000 the model that uses this texture will be messy.int[16]: mipmap offset (offset from the begining of the file)int[16]: mipmap size (size of mipmaps)

If it's a JPG-BLP we go on with:
int: jpg header size (header size) "h" (usually 0x00000270)
byte[h]: header
followed by 0 bytes until the begining of the jpeg data, we can safely erase these 0 bytes if we fix the mipmap offset specified above
byte[16, mipmap size]: starting from each of the 16 mipmap offset addresses we read 'mipmap size' bytes raw jpeg data till the end of the file, having the header and the mipmap data we can process the picture like ordinary JPG files

If it's a paletted BLP we go here:
byte[4, 255]: the BGRA palette defining 256 colors by their BGRA values, each 1 byte
byte[width x height]: the ColorIndex of each pixel from top left to bottom right, ColorIndex refers to the above defined color palette
byte[width x height]: the AlphaIndex of each pixel on a standard greyscale palette for the alpha channel, where 0 is fully transparent and 255 is opaque,
if the picturetype flag is set to 5, the image doesn't have an alpha channel, so this section will be omitted
发表于 2008-6-20 17:31:52 | 显示全部楼层
你还是先吧某东西翻译出来吧
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 点一下

本版积分规则

Archiver|移动端|小黑屋|地精研究院

GMT+8, 2024-12-22 16:03 , Processed in 0.135068 second(s), 18 queries .

Powered by Discuz! X3.5

© 2001-2023 Discuz! Team.

快速回复 返回顶部 返回列表