.IMX is a texture file format used in Gitaroo Man.
Data types used in this document (all little-endian):
- uint32: unsigned 4-byte integer
offset |
size |
data
|
+0x00 |
4 |
0x00584D49 -- magic stamp 'IMX ' (last charcter is a null byte, not a space.)
|
+0x04 |
16 |
all 0
|
+0x14 |
4 |
uint32: image width
|
+0x18 |
4 |
uint32: image height
|
+0x1C |
4 |
uint32: pixel storage mode value1
|
+0x20 |
4 |
uint32: pixel storage mode value2.
value1 and value2 work together like so:
value1 |
value2 |
pixel storage mode
|
0 |
0 |
4-bit indexed (each byte is 2 pixels, lower 4 bits come first), RGBA 8888 palette
|
1 |
1 |
8-bit indexed, RGBA 8888 palette
|
3 |
2 |
24-bit RGB 888
|
4 |
2 |
32-bit RGBA 8888
|
|
Palette
This section only appears if pixel storage mode is indexed, otherwise it skips right to Image Data.
offset |
size |
data
|
+0x00 |
4 |
uint32: size of palette in bytes
|
+0x04 |
? |
Palette, always RGBA 8888? Note: alpha channel is stored roughly at half intensity, see the note below on converting alpha.
|
?+0x00 |
4 |
uint32: unknown, always 2
|
Image Data
offset |
size |
data
|
+0x00 |
4 |
size of image data in bytes
|
+0x04 |
? |
Image data. Note: as with palette, alpha channel is stored roughly at half intensity, see the note below on converting alpha.
|
offset |
size |
data
|
+0x00 |
4 |
uint32: unknown, always 3
|
+0x04 |
4 |
unknown, always 0
|
Note on converting alpha
Alpha in the IMX file has a maximum value of 0x80 (128). To convert to and from alpha that has a maximum value of 0xFF (255), you should do this.
- Go from alpha 0x80 → 0xFF: floor(alpha80/128*255)
- Go from alpha 0xFF → 0x80: ceil(alphaFF/255*128)
(Going above the maximum of 0x80 results in weird effects as a consequence of plugging values greater than 1.0 into the alpha blending formula.)