| 01-31-2004, 08:15 AM | #1 |
I have read the source code of WarCraft Viewer, As I know from it, the first 160 bytes of blp file is the BLP_HEADER data, then, it should be JPG file data followed, but, It seems like some difference from a normal jpg file data, THEN, How can I get the BLP file's JPG format data ?? THX a lot ^^ |
| 01-31-2004, 11:57 AM | #2 |
The first thing is: There are JPEG based BLPs and there are PALLETE based BLPs. I´ll try to help you with the JPEG based BLPs. To me, the BLP_HEADER is 28 bytes, altough other ppl may use diferent aproaches. After those 28 bytes we get a MipMapOffset table with 16 entries. After that we get a MipMapSizeTable with 16 entries. After this second table we get a JpegHeaderSize field. After this field we get the JpegHeaderData. Confused? Let´s bring those together: BLP_HEADER (28 bytes) DWORD MipMapOffsetTable[16] (16 * 4 = 64 bytes) DWORD MipMapSizeTable[16] (16 * 4 = 64 bytes) DWORD JpegHeaderSize (4 Bytes) BYTE JpegHeaderdata[JpegHeaderSize] (Variable size) Usually Blizzard BLPs have 624 bytes for the JpegHeaderSize altough they reserved 1024 bytes for it. (yes, there are some "unused" bytes there). The first MipMap usually starts at offset 1180 (decimal) but it could start right after the JpegHeaderData. BLPs have "MipMaps" inside, this means: the same picture is there with diferent Width x Height. Say BLP_HEADER tels us that it is a 512x256 picture. The first MipMap would be a 512x256 picture.The second MipMap would be a 256x128 picture. The third would be a 128x64 picture and so on. The next MipMap dimensions are half of the previous MipMap. If you want to read the BLP as a JPEG picture you first need to read the JpegHeaderData. Then use the MipMapOffsetTable to locate the MipMap you want to extract. Then read n bytes begining on that offset, where n is the MipMapSize of that selected MipMap. Note that BLPs usually don´t have all the 16 allowed MipMaps, you first need to check if the desired MipMap is there by reading it´s Offset and Size. If either of those values are 0, that MipMap is not there. After you have the JpegHeaderData and the MipMap data, you can merge those (the JpegHeader comes first, of course) and read it as a JPEG picture. |
| 02-18-2004, 06:43 AM | #3 |
THX for BlacKDicK's help I do as you have told me, but I meet a question about a 32bit JPG file A BLP file based on JPG file, it's jpg data is 32bit format, I use the INTEL's IJL jpeg library, Show the blp file like this: http://images.sonicalbum.com/upload_...__%40_mine.JPG The correct is: http://images.sonicalbum.com/upload_...lfrider_24.JPG |
| 02-18-2004, 09:31 PM | #4 |
I can´t see the pictures. |
| 02-20-2004, 02:01 AM | #5 |
Up |
| 02-22-2004, 10:04 AM | #6 |
I get it: The error code is: case 4: image.JPGColor = IJL_YCBCRA_FPX; image.DIBChannels = 4; image.DIBColor = IJL_RGBA_FPX; The right is: case 4: image.JPGColor = IJL_RGBA_FPX; // the difference is here !! image.DIBChannels = 4; image.DIBColor = IJL_RGBA_FPX; |
| 02-26-2004, 12:35 PM | #7 |
Hi everybody !!! I am currently trying to develop a MDX Importer plugin for the Low Polygon modeler MilkShape 3d. I need to convert blp Textures to jpg or bmp. I do as BlacKDicK told and separated all mipmaps with JpegHeader, but I get wrong colors on my Jpeg. For example, DemonGate.blp converted with Wc3 Image Extractor II becomes : http://www.absenceoflight.net/DemonGate.jpg DemonGate.jpg seems to be RGB colors JPG Converted handly, DemonGate.blp becomes : http://www.absenceoflight.net/DemonGate.blp.jpg (IE can't display it , needs to be downloaded ...) DemonGate.jpg.blp seems to be CMYK colors JPG I would like to know if it is possible to convert CMYK datas in the BLP file into RGB datas, so that the colors match. Thank you in advance. |
| 03-01-2004, 02:16 AM | #8 |
Jasc Paint Shop Pro 8 can split the CMYK channels and merge them back, meaning you can get the BLP working properly. If you are programming then you can try to use the internal routines of your JPEG library. The Intel IJL Library can do that (it is the same used by Image Extractor 2). The W3 Viewer is using the IJG Library, so I am not sure wheter this lib has this feature or not. |
| 03-01-2004, 08:32 AM | #9 |
I use IJG library to convert blp to bmp with alpha channel. It works great. I hope I can soon distribut my plugin with your help. Thanks.:D |
