Author | Message | Time |
---|---|---|
Ringo | Hmm, where to start :o Iv been following this tutorial for the last few days, on MPQ's, and have been able to use storm to extract the (listfile), read it and extract all the icons. But the problem is, reading the .blp image format, and was wundering if anyone has any research laying around? Iv come across alot of .blp viewers/converts, so i can only asume the format is fairly well known through out. Iv only had an hour to work with it, so im not very far at all. The questions i need to ask are: How many image formats do .blp use and what are they? What image format are the icons in icons-WAR3.bni? (because it hints .tga, but doesnt seem to be .tga format) Why does AVG scream virus when i remove the .blp header and try load the jpg data as a jpg image? What are all the unknowns in the .blp header? Does the image data always start from position 0xA0 in the .blp file? This is what i have figgerd out in the last hour (width and height), but im hoping somone will explain it :P Iv uploaded the .blp icon files so ppl can poke around and help out :). [code] [Solved, updated format as a referance] (DWORD) BLP1 -- .blp version/ID (DWORD) 0x01 -- Pallet Indication (DWORD) 0x08 -- Image Mode/mipmaps? (still kinda unknown) (DWORD) 0x40 -- Resoluton Width (pixels) (DWORD) 0x40 -- Resoluton Height (pixels) (DWORD) Unknown (useage?) (DWORD) 0x01 (DWORD[16]) Image Data pos in file (IDO) (DWORD[16]) Image data lengh as from pos (IDL) If PalletIndication = 1 Then (DWORD[256]) Pallet Each image block is scaled down by half the Resoluton Width and Height of the last, and many of the image blocks wont be used. The Resoluton Width and Height will be that of the first image block in the file, and from this scale down accordingly. (VOID[IDO(1), IDL(1)]) Image Block (Width by Height)) (VOID[IDO(2), IDL(2)]) Image Block " / &H2 (VOID[IDO(3), IDL(3)]) Image Block " / &H4 (VOID[IDO(4), IDL(4)]) Image Block " / &H8 (VOID[IDO(5), IDL(5)]) Image Block " / &H10 (VOID[IDO(6), IDL(6)]) Image Block " / &H20 (VOID[IDO(7), IDL(7)]) Image Block " / &H40 (VOID[IDO(8), IDL(8)]) Image Block " / &H80 (VOID[IDO(9), IDL(9)]) Image Block " / &H100 (VOID[IDO(10), IDL(10)]) Image Block " / &H200 (VOID[IDO(11), IDL(11)]) Image Block " / &H400 (VOID[IDO(12), IDL(12)]) Image Block " / &H800 (VOID[IDO(13), IDL(13)]) Image Block " / &H1000 (VOID[IDO(14), IDL(14)]) Image Block " / &H2000 (VOID[IDO(15), IDL(15)]) Image Block " / &H4000 (VOID[IDO(16), IDL(16)]) Image Block " / &H8000 [/code] Header of a .blp icon from icons-WAR3.bni [code] w=64[0x40] / h=128[0x80] [23:32:22] wcg_w3_ref.blp 12102 000000 -- 42 4C 50 31 01 00 00 00 08 00 00 00 40 00 00 00 BLP1........@... 000010 -- 40 00 00 00 03 00 00 00 01 00 00 00 9C 04 00 00 @............... 000020 -- 9C 24 00 00 9C 2C 00 00 9C 2E 00 00 1C 2F 00 00 .$...,......./.. 000030 -- 3C 2F 00 00 44 2F 00 00 00 00 00 00 00 00 00 00 </..D/.......... 000040 -- 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................ 000050 -- 00 00 00 00 00 00 00 00 00 00 00 00 00 20 00 00 ............. .. 000060 -- 00 08 00 00 00 02 00 00 80 00 00 00 20 00 00 00 ............ ... 000070 -- 08 00 00 00 02 00 00 00 00 00 00 00 00 00 00 00 ................ 000080 -- 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................ 000090 -- 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................ 0000A0 -- 11 0F 04 00 15 12 05 00 19 16 06 00 1D 19 07 00 ................ 0000B0 -- 1B 14 0F 00 1C 19 0F 00 12 10 10 00 18 12 10 00 ................ 0000C0 -- 1D 1D 1D 00 23 1C 09 00 35 1D 0D 00 27 22 09 00 ....#...5...'".. 0000D0 -- 2A 25 0A 00 36 28 0C 00 2A 2A 2A 00 37 37 37 00 *%..6(..***.777. 0000E0 -- 4A 23 0C 00 5B 26 0B 00 5B 2D 0B 00 46 35 0C 00 J#..[&..[-..F5.. 0000F0 -- 57 3E 0B 00 5B 3D 0B 00 43 3B 10 00 67 30 0A 00 W>..[=..C;..g0.. 000100 -- 7C 33 08 00 7F 3C 08 00 55 43 0B 00 56 49 0B 00 |3...<..UC..VI.. 000110 -- 4B 43 12 00 55 4B 15 00 5C 52 17 00 61 41 04 00 KC..UK..\R..aA.. [/code] Header for a .blp texture file from war3 demo: [code] w=256[0x100] / h=64[0x40] [01:02:27] ManaBurnBeam.blp 7840 000000 -- 42 4C 50 31 00 00 00 00 00 00 00 00 00 01 00 00 BLP1............ 000010 -- 40 00 00 00 05 00 00 00 01 00 00 00 9C 04 00 00 @............... 000020 -- 83 13 00 00 B5 19 00 00 61 1C 00 00 40 1D 00 00 ........a...@... 000030 -- CD 1D 00 00 17 1E 00 00 45 1E 00 00 73 1E 00 00 ........E...s... 000040 -- 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................ 000050 -- 00 00 00 00 00 00 00 00 00 00 00 00 E7 0E 00 00 ................ 000060 -- 32 06 00 00 AC 02 00 00 DF 00 00 00 8D 00 00 00 2............... 000070 -- 4A 00 00 00 2E 00 00 00 2E 00 00 00 2D 00 00 00 J...........-... 000080 -- 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................ 000090 -- 00 00 00 00 00 00 00 00 00 00 00 00 70 02 00 00 ............p... 0000A0 -- FF D8 FF E0 00 10 4A 46 49 46 00 01 01 00 00 01 ......JFIF...... 0000B0 -- 00 01 00 00 FF FE 00 2A 49 6E 74 65 6C 28 52 29 .......*Intel(R) 0000C0 -- 20 4A 50 45 47 20 4C 69 62 72 61 72 79 2C 20 76 JPEG Library, v 0000D0 -- 65 72 73 69 6F 6E 20 31 2C 35 2C 34 2C 33 36 00 ersion 1,5,4,36. 0000E0 -- FF DB 00 43 00 0D 09 0A 0B 0A 08 0D 0B 0A 0B 0E ...C............ 0000F0 -- 0E 0D 0F 13 20 15 13 12 12 13 27 1C 1E 17 20 2E .... .....'... . 000100 -- 29 31 30 2E 29 2D 2C 33 3A 4A 3E 33 36 46 37 2C )10.)-,3:J>36F7, 000110 -- 2D 40 57 41 46 4C 4E 52 53 52 32 3E 5A 61 5A 50 -@WAFLNRSR2>ZaZP 000120 -- 60 4A 51 52 4F FF DB 00 43 01 0E 0E 0E 13 11 13 `JQRO...C....... 000130 -- 26 15 15 26 4F 35 2D 35 4F 4F 4F 4F 4F 4F 4F 4F &..&O5-5OOOOOOOO 000140 -- 4F 4F 4F 4F 4F 4F 4F 4F 4F 4F 4F 4F 4F 4F 4F 4F OOOOOOOOOOOOOOOO 000150 -- 4F 4F 4F 4F 4F 4F 4F 4F 4F 4F 4F 4F 4F 4F 4F 4F OOOOOOOOOOOOOOOO 000160 -- 4F 4F 4F 4F 4F 4F 4F 4F 4F 4F FF C4 01 A2 00 00 OOOOOOOOOO...... [/code] Im greatfull for any help, thanks in advance. | February 18, 2006, 1:49 AM |
HeRo | I don't know if this will help you, but I had it bookmarked for some reason. Converting a graphic to Blizzard's BLP format, creating a TGA file (which is optionally partially or fully transparent) along the way. http://toogam.bespin.org/wow/psptut.htm Edit: Possibly this to?: Description: One of the most famous BLP to TGA/JPG converters for Windows. I use this one myself. http://www.wc3sear.ch/index.php?p=Tools&ID=6&sid= | February 18, 2006, 8:18 AM |
Ringo | Thanks, but im looking for infomation on the BLP format its self (they are tutorials on how to use somones BLP converter) But the 2nd link you post, was a better converter than what i have at the moment, and its also wrote in VB6, so now know it shouldnt be a problem, thanks for that :) Iv also learned abit more about blp files today from googleing, and as i understand, there is 3 tyes of BLP id's: BNL0 For W3 Beta BLP1 For W3 BLP2 For WoW And that the byte after the blp ID is a pallet indication byte, which will be false on jpeg format, true on a palleted blp format (like icons) Iv updated the top post with what i have learned today, but am still a long shot from being able to load the picture. Untill i can get *any* infomation on the format for the icons, or blp in general, im a stuck :( Loads of you have successfully done icons-WAR3.bni, correct? I dont really have alot to work with, Please help anyone ::) | February 18, 2006, 6:33 PM |
Myndfyr | Have you seen this yet Ringo? If you get something in a language other than VB, I'd be interested to see what you come up with. | February 18, 2006, 8:22 PM |
Ringo | [quote author=MyndFyre link=topic=14286.msg146369#msg146369 date=1140294135] Have you seen this yet Ringo? If you get something in a language other than VB, I'd be interested to see what you come up with. [/quote] nice! I was reading somthing about mipmap's today, and am now starting to put 2 and 2 together :P That document pritty much answers most of my questions, so thanks a million! I just need time to digest it and to trial and error :P thanks again! [EDIT]: YAY i did it! The icons look abit cut down on the right side, but il fix that in the morning. Thanks again for that link MyndFyre :p | February 18, 2006, 9:22 PM |
Ringo | Alright, sorry to double post, but i cant contain my excitement in 1 post :) Heres the code i finished off this morning to load the blp file if anyone wants to add icons-WAR3.bni support and have already over come the first step of MPQ's. Iv made it very simple to understand, and there maybe a few graphical bugs still :P It will return all bitmaps in the blp file. [code] 'Strut for returned bitmap Public Type BITMAPSTRUT Width As Long Height As Long handle As Long End Type 'image array of differnt scaled icons (of the same icon image) Public W3IconTest() As BITMAPSTRUT If LoadBLP(App.Path & "\wcg_w3_ref.blp", W3IconTest) = False Then MsgBox "unable to load the blp file" End If [/code] And to open and read the blp its self: ( those of you who dont like VB6 code, look away now :) ) [code] 'Header for blizzards .blp(1) files (this code is anti jpeg, for now) Private Type BLP1_HEADER bBLPid As Long bIsPal As Long bMipMaps As Long bWidth As Long bHeight As Long bUnknown1 As Long bUnknown2 As Long bPicPtr(15) As Long bPicLen(15) As Long End Type 'for the pallet Private Type RGBQUAD rgbBlue As Byte rgbGreen As Byte rgbRed As Byte rgbReserved As Byte End Type 'Bit Map Private Type BITMAPINFOHEADER biSize As Long biWidth As Long biHeight As Long biPlanes As Integer biBitCount As Integer biCompression As Long biSizeImage As Long biXPelsPerMeter As Long biYPelsPerMeter As Long biClrUsed As Long biClrImportant As Long End Type 'for the API containing both pallet and bitmap header Private Type BITMAPINFO_8 bmiHeader As BITMAPINFOHEADER bmiColors(255) As RGBQUAD End Type Private Declare Sub CopyMemory Lib "kernel32" Alias "RtlMoveMemory" (ByRef Destination As Any, ByRef Source As Any, ByVal numbytes As Long) Private Declare Function CreateDIBitmap_8 Lib "gdi32" Alias "CreateDIBitmap" (ByVal hdc As Long, lpInfoHeader As BITMAPINFOHEADER, ByVal dwUsage As Long, lpInitBits As Any, lpInitInfo As BITMAPINFO_8, ByVal wUsage As Long) As Long Private Declare Function GetDC Lib "user32" (ByVal hWnd As Long) As Long Private Declare Function DeleteDC Lib "gdi32" (ByVal hdc As Long) As Long Private Declare Function DeleteObject Lib "gdi32" (ByVal hObject As Long) As Long Public Function LoadBLP(ByVal FilePath As String, ByRef BMPArray() As BITMAPSTRUT) As Boolean Dim FF As Integer: FF = FreeFile Dim FileData() As Byte Dim tmpBMP() As Byte Dim blpHeader As BLP1_HEADER Dim BMP8 As BITMAPINFO_8 Dim i As Integer Dim hdc As Long LoadBLP = False 'open file and extract data Open FilePath For Binary As #FF ReDim FileData(LOF(FF) - 1) Get FF, , FileData Close #FF 'copy header data into header type Call CopyMemory(blpHeader, FileData(0), 156) 'Check its a blp file If Not blpHeader.bBLPid = &H31504C42 Then Exit Function 'BLP1 'Check its a raw blp format (not jpeg) If Not blpHeader.bIsPal = 1 Then Exit Function 'its jpeg 'copy the pallet into are bitmap RGBQUAD Call CopyMemory(BMP8.bmiColors(0), FileData(156), 1024) 'add needed info to the bitmap header for when the API creates it With BMP8.bmiHeader .biSize = Len(BMP8.bmiHeader) .biWidth = blpHeader.bWidth .biHeight = blpHeader.bHeight .biPlanes = 1 .biBitCount = 8 End With 'Create a bitmap in memory from the set data, and get the handle to it For i = 0 To 15 'Check theres a pointer to the picture data, other wise last image was loaded last for If blpHeader.bPicPtr(i) = 0 And i > 0 Then Exit For 'Copy the first bitmap into tmpBMP() ReDim tmpBMP(blpHeader.bPicLen(i) - 1) Call CopyMemory(tmpBMP(0), FileData(blpHeader.bPicPtr(i)), blpHeader.bPicLen(i)) 'flip/mirror/lower bits of the bitmap data Call MakeBitmap_8(tmpBMP(), BMP8.bmiHeader.biWidth, BMP8.bmiHeader.biHeight) 'Create a bitmap and put it into the correct index of BMPArray hdc = GetDC(0) ReDim Preserve BMPArray(i) BMPArray(i).Width = BMP8.bmiHeader.biWidth BMPArray(i).Height = BMP8.bmiHeader.biHeight BMPArray(i).handle = CreateDIBitmap_8(hdc, BMP8.bmiHeader, &H4, tmpBMP(0), BMP8, &H0) Call DeleteDC(hdc) 'lower image size to the next image block's size BMP8.bmiHeader.biWidth = BMP8.bmiHeader.biWidth / 2 BMP8.bmiHeader.biHeight = BMP8.bmiHeader.biHeight / 2 'Alwas return true if a bitmap was created LoadBLP = True Next i 'erase the file/bitmap datas Erase FileData() Erase tmpBMP() End Function Private Sub MakeBitmap_8(imgArray() As Byte, Lines As Long, BytesLine As Long) Dim tmpBM() As Byte, G As Long, GBMP As Long, i As Long, i2 As Long, tmpBMX As Long If (BytesLine Mod 4) = 0 Then tmpBMX = BytesLine - 1 Else tmpBMX = (BytesLine \ 4) * 4 + 3 End If G = Lines * BytesLine GBMP = Lines * (tmpBMX + 1) - 1 ReDim tmpBM(UBound(imgArray)) CopyMemory tmpBM(0), imgArray(0), UBound(imgArray) + 1 ReDim imgArray(GBMP) For i = 0 To BytesLine * Lines - BytesLine Step BytesLine CopyMemory imgArray(i2), tmpBM(G - i - BytesLine), BytesLine i2 = i2 + tmpBMX + 1 Next i Erase tmpBM() End Sub [/code] And remember, when your project is unloaded, this doesnt mean that any bitmaps it put in memory will be deleted, so we have to do this manualy, example: [code] on error resume next dim i as interger for i = 0 to ubound(W3IconTest) Call MurderBitMap(W3IconTest(i).Handle) next i Public Sub MurderBitMap(KillHandle As Long) 'Deletes the bitmap If KillHandle = 0 Then Exit Sub If DeleteObject(KillHandle) >= 1 Then KillHandle = 0 End If End Sub [/code] [EDIT]: Once all image blocks from wcg_w3_ref.blp are drawn, it should look somthing like this: [img]http://www.geocities.com/ringomail712/ShouldLookLike.bmp[/img] | February 19, 2006, 5:07 PM |
Quarantine | ...you are a maniac Ringo ;P | February 20, 2006, 6:07 PM |