| 06-19-2003, 06:22 AM | #1 |
Would anyone know of where I could get a file format specification for .blp images? Or how could I contact the author of the conversion software? I want to make a mac version of the .blp converter software. Any help would be appreciated. |
| 06-19-2003, 02:30 PM | #2 |
************************************************************************ * * BLP FILE SPEC * * by BlacKDlcK * ************************************************************************ * The *.blp files are 2D picture files used on Blizzard Entertainment Games. I guess 'blp' stands for "Blizzard Picture". Their main usage is TEXTUREs. They suport different mip-maps (up to 16). Those are used on the following Blizzard games: 1) "Warcraft III Reign of Chaos BETA" 2) "Warcraft III Reign of Chaos" (the retail and the demo version) 3) "Frozen Throne BETA" Some important things: a) "Warcraft III Reign of Chaos BETA" uses the first version of blp files, also known as "BLP0". b) All other games (for now) are using the "BLP1" version. c) On "Warcraft III Reign of Chaos", they use both JPG-BLPs and Palleted-BLPs. The JPG-BLPs DO NOT get goo compression on Blizzard archive format, "MPQs" since JPEGs are already "huffman compressed". d) On "Frozen Throne BETA" they are only using Palleted-BLPs, since those get better compression on the "MPQs". They´re also using TGA´s (dunno why). ************************************************************************ * * BLPHEADER * ************************************************************************ * Signature As String * 4 'BLP0 or BLP1 ImageType As Long '0 for JPGblp, 1 for Paletted hasAlpha As Long '0x8 = has alpha, 0x0 = no alpha Width As Long 'Image Width Height As Long 'Image Height hasTeamColor As Long 'Got values of 3,4,5 here. If use >=5 on 'unit' textures, it won't show the team color. isValid As Long 'Always =>0x1, if 0x0 the model that uses this texture will be messy. ************************************************************************ * * MIPMAPTABLE (Only present if the file is a BLP1 * ************************************************************************ * MipmapOffset(15) As Long MipMapSize(15) As Long ************************************************************************ * * GENERAL DATA (shared by all mip-maps) * ************************************************************************ * If it is a JPEG-Blp we get: JPEGHeaderSize as Long 'The lenght of the JPEGHeaderData. JPEGHeaderData() as Byte 'The JPEGHeaderData. If it is a Paletted-Blp, we get: Palette(255) as RGBA 'RGBA is 4 bytes ************************************************************************ * * MIP-MAP DATA * ************************************************************************ * If this is a BLP0 file, then we must open a separate mipmap file (*.bxx), where 'xx' is the mip-map level data. The lenght of the mip-map data is the len of the mip-map file. For an example, to use a "Level 1" mipmap, the file name would be: 'name of blp file without .blp' + '.b01' If this is a BLP1 file, then we can grab each mip-map data checking the table above. Go to the MipMapOffset and read MipMapSize bytes. Small tip: Dont ask me why, but on BLP1 files Blizzard added some extra padding bytes between the JPEGHeader and the first Mip-Map data. Those bytes can be safelly erased if you fix each MipMappoffset entry on MipMapTable (subtract the ammount of erased bytes). ************************************************************************ * * Reading the mip-map data * ************************************************************************ * If it is a JPEG-blp, we need to decompress the mipmap to get a RGBA picture. Get the JPEGHeaderData + MipMapData and you'll have a JPEG-JFIF file. If it is a Palleted-blp, we will have 2 bytes for each pixel of the picture: ImageIndex as byte AlphaIndex as byte The ImageIndex reffer to the pallete. The AlphaIndex reffer to a standard grayscale pallete. |
| 06-20-2003, 06:26 AM | #3 |
Hi BlackDick! Thanks for the details, I'll include them in my page about W3E files format. :) And make sure you'll be in my "thanks" list! ;) |
| 06-20-2003, 08:23 AM | #4 |
The first few bytes of my file are: 42 4C 50 31 01 Is the image type supposed to be 32-bit long or char? |
| 06-20-2003, 03:28 PM | #5 |
The first 4 bytes are the file signature (DWORD, long). I just read them as "char" with Visual Basic coz it is easier to check the BLP version. You can also check the first 3 bytes as the signature and then check the 4th byte to grab the BLP version. 99,99..% of the time you will be dealing with "BLP1" since those "BLP0" were just used on the War3 beta last year. But it is better check the BLP version coz the BLP0 mipmaps are "external", so to add support to BLP0 you migh also need to read the external mipmaps. If the file name is "xyz\abcd.blp" and it is a "BLP0", the external mipmaps will be named: xyz\abcd.b00 xyz\abcd.b01 xyz\abcd.b02 ..and so on. |
| 06-21-2003, 04:43 AM | #6 |
Yes, but you said the image type was stored as long. Here, it seems to be char. |
| 06-21-2003, 10:19 PM | #7 |
The image type is also a long. |
| 06-24-2003, 08:23 PM | #8 |
I'm having a hard time following the spec, as some elements are not long ints when you say they should be. >MipmapOffset(15) As Long >MipMapSize(15) As Long What is the 15? |
| 06-24-2003, 09:09 PM | #9 |
Its an array of 16 longs. MipmapOffset(15) As Long is the VB way to declare an array of 16 elements from 0 to 15. |
| 06-24-2003, 09:12 PM | #10 |
Guest | hmm im not sure if this is the right place to put this but perhaps you experts of blp can help.... http://www.wc3campaigns.com/forums/s...threadid=19993 |
| 07-03-2003, 12:56 AM | #11 |
Is there a photoshop import/export plugin for blp files? Because that would be very useful for me |
| 07-03-2003, 05:43 AM | #12 | |
Quote:
No there isnt. Use Image Extractor 2 or W3Viewer, |
| 07-03-2003, 05:41 PM | #13 | |
Quote:
That would INDEED be VERY useful. |
| 07-11-2003, 07:41 PM | #14 |
Guest | Sorry for bringing up an old topic again, but I'm having problems getting my VB6 program to display/save jpeg-blps. I'm using the above posted specs and psuedo code: ReadBLPHeader if BLP1 ReadMipMapTable end if if ImageType = 1 'BMP ReadRGBAPalette else 'JPG ReadJPGHeader end if ReadData ------------------ I've actually gotten the above to work when reading The Frozen Throne Beta blps, as they are BMP-Blps. I can't seem to get the jpeg-blps to work though. What I thought I could do, is basically save the JPGHeader and MipMapData and have the JPEG-JFIF as stated in the specs. I'm pretty sure the problem lies where I read the MipMap data. Am I correct in assuming that I just need to read the data at MipMapOffset(0) to MipMapSize(0) and add that to the jpeg header to get the jpeg-jfif file? TIA magi |
| 07-11-2003, 11:49 PM | #15 |
Read blp header If blp0 then do nothing since blp0 is outdated and harder then read the mipmap tables (2 arrays, 16 elemens each) if imagemode=0 (jpeg) then read 1 long after the miptables (this long is the jpeg header size) if imagemode=1 )paleted) then read a pallete table (256 elements, RGBA) after the miptables if imagemode=0 then read N bytes for the jpeg header , where X is tha long you got above Then you need to build the image. If it is a JPEG, merge the header with one of the mipmaps. If it is a paleted picture, each pixel for each bitmap will be 2 byes: first byte is a index entry to the main palete and the second byte is an entry to an grayscale palette. (alpha channel) |
