Megadrifter Posted October 31, 2014 Posted October 31, 2014 (edited) Well, I'm working on Mystery Dungeon : Gates to Infinity and I'm currently trying to convert an IMG file to a PNG. Firstly, let's talk about those IMG files. You can find them in /bg/ and /image_2d/ folders. Their header seems to always be 0x20 bytes long. All values in header are Little Endian. [table=width: 500, class: outer_border, align: left] [tr] [td] Offset [/td] [td] Size [/td] [td] Description [/td] [/tr] [tr] [td]0x00[/td] [td]4[/td] [td]Magic ".cte". { 0x00, 0x63, 0x74, 0x65 }[/td] [/tr] [tr] [td]0x04[/td] [td]4[/td] [td]File format. Possible values : 0x02 (RGB8), 0x03 (RGBA8888), 0x04 (ETC1) or 0x05 (??).[/td] [/tr] [tr] [td]0x08[/td] [td]4[/td] [td]Width. Always a multiple of 4.[/td] [/tr] [tr] [td]0x0C[/td] [td]4[/td] [td]Height. Always a multiple of 4.[/td] [/tr] [tr] [td]0x10[/td] [td]4[/td] [td]Pixel length in bits. 0x18 : 24bits pixels. 0x20 : 32bits pixels.[/td] [/tr] [tr] [td]0x18[/td] [td]4[/td] [td]Pixel data start offset. It looks like its value is always 0x80.[/td] [/tr] [/table] The pixel data is Width * Height * Pixel size long. Using the file format as a reference to CLIM file ones, you can convert those IMG into BCLIM files and then use png2clim to create a PNG. You should have to flip the image to obtain the final result. img2png : soon... Edited December 9, 2014 by Megadrifter Modified File format infos
Kaphotics Posted November 1, 2014 Posted November 1, 2014 32bit is alpha, 24bit is standard. I have no idea what you are having trouble with... most of the time you don't need to endian swap and can just read data straight out of the file. not sure why you can't use ETC1.dll, but you can always try porting the code (source code for it can be found here)
Megadrifter Posted November 1, 2014 Author Posted November 1, 2014 I don't endian swap pixel bytes, only the header bytes. When I import ETC1.dll in my project, it says that it can't find the DLL file. I arleady know about the difference between 32bit and 24bit. I'm having trouble with the pixel order. When I pass an IMG file through my EXE, it creates a PNG, with 4*4 pixel blocks. But those ones are always separated by white lines. Also, I don't think the order in which the blocks are is good. I'll try to dig in the source code you gave me. Keep searching a little today.
Kaphotics Posted November 1, 2014 Posted November 1, 2014 To use the dll's methods in your code project, you have to add the dll as a reference. When the program is run, the dll has to be in the same folder as the exe; for png2bclim I have it as a resource and have code to create the dll in the exe's folder if it does not exist.
Megadrifter Posted November 2, 2014 Author Posted November 2, 2014 Ow.. Thanks ! I was using it as a resource, not a reference. I'll keep you informed when I'm done with it. Thanks again for your help.
Megadrifter Posted December 9, 2014 Author Posted December 9, 2014 Got some news for you. I was very busy with some stuff since the last time, but I'm back. I converted an original IMG to a BCLIM, and then tested it with png2bclim, to find some matches between File formats... and it worked well. So : - 0x02 is RGB8; - 0x03 is RGBA8888; - 0x04 is ETC1. I can't find what is 0x05 format, but there're some clues that it is similar to ETC1. I will edit my first post. I'll make a little tool soon to convert directly from IMG to PNG, and much of the code will be from Kaphotics' tool (I'll give you credits for any method I'll take). If anyone wants to help with the last file format, I could give him the method I used.
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now