HomeUser Control Panel (unavailable in archive)ForumsTutorialsArt GalleryResourcesMaps

BLP conversion & MPQ format specs

07-30-2006, 01:30 AM#1
SFilip
Well I've been trying to make my own simple BLP converter so I searched these forums a bit and eventually found BlacKDicK's format specs. If I understood it correctly, a blp is simply jpg with a larger header which means that I could simply convert it by cutting blp header part. For the sake of testing I made a simple jpg using paint and converted it to blp using warcraft 3 viewer. Then I opened it with a hex editor, found jpg header and removed everything before it. It worked just fine although the file size was greater than the original jpg. Then I tried something different - I took the war3mapMap.blp file from a melee map and tried to convert it the same way. However it didn't work, the image software detected that the file jpeg, but didn't want to open it from some reason. What did I do wrong here?
Also another question...has anyone got MPQ format specs? I'd also like to try to make some simple MPQ extracting software if possible without any 3rd party dlls.
Thanks in advance.
07-30-2006, 01:56 AM#2
Zoxc
You can find BLP specs here: http://wc3campaigns.net/tools/specs/index.html

Here is MPQ: http://wc3campaigns.net/tools/specs/...mMPQFormat.txt

Quote:
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
07-30-2006, 02:20 AM#3
SFilip
thanks for the mpq link, but the blp specs still don't seem to solve my problem...they are just about the same like the ones i already read...and according to them there should be a clean jpg file right after the blp header.
07-30-2006, 02:51 AM#4
Vexorian
And there is. But the jpg header is somewhere else, well ijl uses a very non-standard color space. I got issues when trying to convert a blp into jpg without recompressing cause windows showed an image with funny colors.
07-31-2006, 10:51 AM#5
BlacKDicK
SFilip, there are also pallete based BLPs. Also notice that the Jpeg Header is shared among many "Mip maps".

Vex, the jpeg-blps are using IJL_OTHER color space, I can help you later on with your blp conversion issue.
08-23-2006, 06:10 PM#6
Ion
Well the BLP format is actually an "indexed JPG". What I mean here is, you have the BLP header wich contains the actual offsets to the mipmaps in the file (there can be a maximum of 16 mipmaps). Actually concerning the paletted BLP's, no textures use them as far as I know. So stick with assuming the file is JPG 'til you find any paletted BLP's.
I pasted a code example from my BLP-JPG converter. This is written is Blitz3D, but should be pretty much straight forward.

-------------------------------------------

Code:
Function LoadBLP(fname$)

fileBLP = ReadFile(fname$)

;First we start reading the BLP header (duh!)
;The filetag is a 4-byte text tag.
filetag$ = Chr(ReadByte(fileBLP))+Chr(ReadByte(fileBLP))+Chr(ReadByte(fileBLP))+Chr(ReadByte(fileBLP))
blpType = ReadInt(fileBLP)
alpha  = ReadInt(fileBLP)
imgw = ReadInt(fileBLP)
imgh = ReadInt(fileBLP)
flag = ReadInt(fileBLP)
dummy = ReadInt(fileBLP)

;Read the file-offsets for the 16 mipmaps.
For i = 0 To 15
	mipmapOffset(i) = ReadInt(fileBLP)
Next

;Read the size of the mipmap-chunks too.
For i = 0 To 15
	mipmapSize(i) = ReadInt(fileBLP)
Next

;if jpg
;i assume..


;Read the JPG header!
jpgHeaderSize = ReadInt(fileBLP)
out=WriteFile ("Output JPG.jpg")

For i = 0 To jpgHeaderSize-1

	WriteByte out,ReadByte(fileBLP)

Next



;Now process the 16 mipmaps.
For i = 0 To 15

        ;Jump to the mipmap chunk.
	SeekFile fileBLP,mipmapoffset(i)

                ;Read and write the mipmap itself.
		For m = 0 To mipmapsize(i)
	
			WriteByte out,ReadByte(fileBLP)
	
		Next

Next

;Done. Close file and get a beer.
CloseFile fileBLP
GetABeer()
09-02-2006, 04:59 AM#7
Quantam
Okay, I have to ask: is that name (SFilip) a pun on SFile, or just coincidence?
09-02-2006, 11:18 AM#8
Zoxc
Philip (or Filip if you like :D) is a name.. but...