TIM Graphics Format

Header

NameSizeDescription
Header8 Bytes
 Signature4 Bytes0x10 0x00 0x00 0x00
 BPP Mode1 ByteThis tells what bit mode the graphics is in. 0x08 signifies 4bpp, 0x09 signifies 8bpp, 0x02 signifies 16 bpp, and 0x03 signifies 24 bpp mode.
 Reserved3 Bytes0x00 0x00 0x00
Palette Info12+ BytesOnly present for bit modes less than 16.
 Length of the CLUT Data4 Bytes This is the length of the CLUT Data + 12 (accounting for 12 bytes before the CLUT Data starts).

It should equal: Number of Colors in CLUT * Number of CLUTs * 2 + 0xC

 Palette Org X2 BytesX coordinate in frame buffer.
 Palette Org Y2 BytesY coordinate in frame buffer.
 Number of Colors in CLUT2 BytesDepends on the BPP Mode. The value for 4 bpp is 16, and for 8 bpp is 256.
 Number of CLUTs2 BytesThis is the number of CLUT groupings.
 CLUT DataNumber of CLUTs * Number of Colors in CLUT * 2
Image Info12+ BytesPresent for all modes.
 Length of the Image Data4 Bytes This is the length of the Image Data + 12 (accounting for 12 bytes before Image Data starts).

It should equal: Image Width * 2 * Image Height + 0xC

 Image Org X2 BytesFrame buffer X coordinate.
 Image Org Y2 BytesFrame buffer Y coordinate.
 Image Width2 Bytes* See below
 Image Height2 BytesThis is the height of the image in pixels.
 Image DataVariesContains data on all the pixels in the image.

* Note: To get the actual Width, you must multiply the number by either 4 in 4bpp, 2 in 8bpp, 1 in 16bpp, or 1.5 in 24bpp mode to get it in terms of Pixels.

CLUTs

Each CLUT entry is 2 Bytes and all the colors are stored in the order TBGR (Transparency, Blue, Green, and Red). The Transparency bit is only 1 bit, while the others are 5 bits each.

Note: For the CLUT Date in 4bpp, there are 16 Colors per CLUT, 32 bytes per CLUT. In 8bpp, there are 256 Colors per CLUT, 512 bytes per CLUT.

Actual Image Data

4 bpp mode: Each byte contains 2 pixels (4 bits per pixel). Each 4 bits is a numeric refernce to the CLUT Data.
8 bpp mode: Each byte contains 1 pixel (8 bits per pixel). Each byte is a numeric refernce to the CLUT Data.
16 bpp mode: Each 2 bytes contain 1 pixel (16 bits per pixel) which is in the same format as the CLUT itself.
24 bpp mode: Each 3 bytes contain 1 pixel (24 bytes per pixel). It is the same as the CLUT except each color is 1 byte instead of 5 bits.