Jump to content

[Gates to Infinity] From IMG file to PNG


Recommended Posts

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 by Megadrifter
Modified File format infos
Link to comment
Share on other sites

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.

14148341398984im01_01_who.png

I'll try to dig in the source code you gave me. Keep searching a little today.

Link to comment
Share on other sites

  • 1 month later...

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.

Link to comment
Share on other sites

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...