sporadic
November 12th, 2003, 15:57
Heyas,
Never posted here, but always enjoy browsing the site. I usually find my answers via search, so haven't had a need to post. And I'm not even sure if this is the right place to ask this, but I'm sure you all will have ideas
I'm currently working on reversing a texture file format for a game. The file format seems pretty easy to parse and supports both 32bit and Indexed images. The 32bit images are read in bottom-to-top like a DIB and render perfectly in my utility. The Indexed images have a color table, followed by 1byte per pixel that represents an offset in the color table. The problem though, is that the scan for indexed images doesn't seem sequential and the rendering is all jumbled. The color lookups seem to be correct though (by ratio of colors in the output). I've noticed a few patterns in the final rendering, but none that will clue me in on the scan order. Any clues on why the pixels wouldn't be represented in a linear fashion or has anyone exprienced something like this w/ another graphics files format? Below are my notes on the format (.img) and links to 2 jpg's that show the correct texture and my parsed texture - right and wrong (the correct one was taken from an older version of the game, when they used .png's). I've yet to figure out any use for the 4 unknown DWORD's listed below. Both 32 bit and Indexed images usually have a value < 0x0F in them.
right: hxxp://linux.wku.edu/~sporadic/gfx/right.jpg
wrong: hxxp://linux.wku.edu/~sporadic/gfx/wrong.jpg
i'm looking for help on this, as it's kinda kicking my arse atm
thanks!,
-sporadic
Never posted here, but always enjoy browsing the site. I usually find my answers via search, so haven't had a need to post. And I'm not even sure if this is the right place to ask this, but I'm sure you all will have ideas

I'm currently working on reversing a texture file format for a game. The file format seems pretty easy to parse and supports both 32bit and Indexed images. The 32bit images are read in bottom-to-top like a DIB and render perfectly in my utility. The Indexed images have a color table, followed by 1byte per pixel that represents an offset in the color table. The problem though, is that the scan for indexed images doesn't seem sequential and the rendering is all jumbled. The color lookups seem to be correct though (by ratio of colors in the output). I've noticed a few patterns in the final rendering, but none that will clue me in on the scan order. Any clues on why the pixels wouldn't be represented in a linear fashion or has anyone exprienced something like this w/ another graphics files format? Below are my notes on the format (.img) and links to 2 jpg's that show the correct texture and my parsed texture - right and wrong (the correct one was taken from an older version of the game, when they used .png's). I've yet to figure out any use for the 4 unknown DWORD's listed below. Both 32 bit and Indexed images usually have a value < 0x0F in them.
right: hxxp://linux.wku.edu/~sporadic/gfx/right.jpg
wrong: hxxp://linux.wku.edu/~sporadic/gfx/wrong.jpg
Code:
// note: non-indexed pixel data is last scanline first (read reverse)
// -- still unsure on scan order of indexed pixel data
-= IMG header =-
0x00: 02 00 00 00
0x04: 30 02 41 00 (IMG file type)
0x08: Unkown 4 Byte field
0x0C: Unkown 4 Byte field
0x10: Unkown 4 Byte field
0x14: Unkown 4 Byte field
0x18: 2 Byte Width
0x1A: 2 Byte Height
0x1C: 4 Byte Color Table Size / Offset of Pixel Data
-- end of IMG header
if file is indexed (0x1C > 0) {
-= Color Table =-
0x20: 4 Byte RGBA Quad
... repeats for 0x1C / 4 (# of colors)
-- end of Color Table
-= Begin Pixel Data =-
0x??: 1 Byte Index (points to RGBA Quad in Color Table)
... repeats for 0x18*0x1A (width*height)
-- end of Pixel Data
} else {
-= Begin Pixel Data =-
0x20: 4 Byte RGBA Quad
... repeats for 0x18*0x1A (width*height)
-- end of Pixel Data
}
-- end of file
i'm looking for help on this, as it's kinda kicking my arse atm

thanks!,
-sporadic