S
scmark15
Guest
Here is some notes I made using a hex editor and playing around...
Code: [Select]
Updated: for those who just wanna copy and paste to have a copy (see my next post to see what was fixed)
Code: [Select]
Code:
Everything below is from this 4x4 pixel image with 4 colors (Red, Green, Blue & White)...+-------+-------+-------+-------+| Red | Red | Green | Green |+-------+-------+-------+-------+| Red | Red | Green | Green |+-------+-------+-------+-------+| Blue | Blue | White | White |+-------+-------+-------+-------+| Blue | Blue | White | White |+-------+-------+-------+-------+--------- 4-Bit TIM (Paletted)--------------- HEADER --------------------------------- Format: 10 00 00 00 TIM Magic BPP: 08 00 00 00 4bpp-- CLUT DATA HEADER------------------------ Length: 2C 00 00 00 44 bytes (32 bytes/palette + 12 bytes for this header) palX: 00 00 0px palY: 00 00 0px colr#: 10 00 16 (Always 16) #CLUT: 01 00 1 CLUT-- CLUT - 2 byte (ABGR[1555] Color) little endian------- HEX -> HEX -> BINARY -> COLOR -> COLOR-REF LE -> BE -> A BBBBB GGGGG RRRRR -> - -> - ----------------------------------------------------------- 1F 00 -> 00 1F -> 0 00000 00000 11111 -> RED -> 0000 E0 03 -> 03 E0 -> 0 00000 11111 00000 -> GREEN -> 0001 00 7C -> 7C 00 -> 0 11111 00000 00000 -> BLUE -> 0010 FF 7F -> 7F FF -> 0 11111 11111 11111 -> WHITE -> 0100 There is only 4 Colors in palette rest is "Black" padding -> 00 00 00 00 -> 0 00000 00000 00000 -> BLACK -> 1000 00 00 -> 0 00000 00000 00000 -> BLACK -> 1001 00 00 -> 0 00000 00000 00000 -> BLACK -> 1010 ...repeat until this CLUT is a total of 32 bytes/16 color entries (last index: 00 00 -> 0 00000 00000 00000 -> BLACK -> 1111) (Example: We only have 4 colors so there will be 24 bytes of padding or "00 00" 12 times (PADDING: 00 00 -> 0 00000 00000 00000 -> BLACK --> XXXX)-- IMAGE HEADER --------------------------- Length: 14 00 00 00 20 bytes (1 byte for each 2 pixel set + 12 bytes for this header) Hres: C0 03 960 Vres: 00 00 0 Width: 01 00 4px (multiplied by 4 to get actual) Height: 04 00 4px-- IMAGE DATA (Like 8-bit TIM, REFERENCED, only 4 bits instead of 8 bits)---------------- HEX -> BINARY -> PX2Cr | PX1Cr -> px2 px1 -> - | - ------------------------------------------------ 00 -> 0000 0000 -> RED | RED 11 -> 0001 0001 -> GREEN | GREEN 00 -> 0000 0000 -> RED | RED 11 -> 0001 0001 -> GREEN | GREEN 22 -> 0010 0010 -> BLUE | BLUE 33 -> 0100 0100 -> WHITE | WHITE 22 -> 0010 0010 -> BLUE | BLUE 33 -> 0100 0100 -> WHITE | WHITE Read 2 pixels at a time but second pixel is output'd first (ie right to left) 1st byte... 1st 4-bit set -> 2nd pixel 2nd 4-bit set -> 1st pixel 2nd byte... 3rd 4-bit set -> 4th pixel 4th 4-bit set -> 3rd pixel 3rd byte... 5th 4-bit set -> 6th pixel 6th 4-bit set -> 5th pixel 4th byte... 7th 4-bit set -> 8th pixel 8th 4-bit set -> 7th pixel Visual Example (4 x 2 px image): +-------+-------+-------+-------+ | 2nd | 1st | 4th | 3rd | +-------+-------+-------+-------+ | 6th | 5th | 8th | 7th | +-------+-------+-------+-------+ So... 00 -> Output is: RED | RED 11 -> Output is: GREEN | GREEN 01 -> Output is: GREEN | RED 10 -> Output is: RED | GREEN ^-- RED is 0 and GREEN is 1IMAGE (1 CLUT):+-------+-------+-------+-------+| Red | Red | Green | Green |+-------+-------+-------+-------+| Red | Red | Green | Green |+-------+-------+-------+-------+| Blue | Blue | White | White |+-------+-------+-------+-------+| Blue | Blue | White | White |+-------+-------+-------+-------+====================================================================--------- 8-Bit TIM (Paletted)--------------- HEADER --------------------------------- Format: 10 00 00 00 TIM Magic BPP: 09 00 00 00 8bpp-- CLUT DATA HEADER------------------------ Length: 0C 02 00 00 524 bytes (512 bytes/palette + 12 bytes for this header) palX: 00 00 0px palY: 00 00 0px colr#: 00 01 256 (Always 256) #CLUT: 01 00 1 CLUT-- CLUT - 2 byte (ABGR[1555] Color) little endian ------- *Each CLUT or Color LookUp Table is 256 colors or 512 bytes HEX -> HEX -> BINARY -> COLOR -> COLOR-REF LE -> BE -> A BBBBB GGGGG RRRRR -> - -> - ------------------------------------------------------------ 1F 00 -> 00 1F -> 0 00000 00000 11111 -> RED -> color00 E0 03 -> 03 E0 -> 0 00000 11111 00000 -> GREEN -> color01 00 7C -> 7C 00 -> 0 11111 00000 00000 -> BLUE -> color02 FF 7F -> 7F FF -> 0 11111 11111 11111 -> WHITE -> color03 There is only 4 Colors in palette rest is "Black" padding -> 00 00 ... 00 00 -> 0 00000 00000 00000 -> BLACK -> color04 00 00 -> 0 00000 00000 00000 -> BLACK -> color05 ...repeat until this CLUT is a total of 512 bytes/256 color entries (Example: We only have 4 colors so there will be 504 bytes of padding or "00 00" 252 times (PADDING: 00 00 -> 0 00000 00000 00000 -> BLACK -> colorXX)-- IMAGE HEADER --------------------------- Length: 1C 00 00 00 28 bytes (1 byte for each pixel + 12 bytes for this header) Hres: C0 03 960 Vres: 00 00 0 Width: 02 00 4px (multiplied by 2 to get actual) Height: 04 00 4px-- IMAGE DATA (Just like paletted BMP, REFERENCE each color from CLUT) -- HEX -> REF -> COLOR ----------------------- 00 -> color00 -> RED 00 -> color00 -> RED 01 -> color01 -> GREEN 01 -> color01 -> GREEN 00 -> color00 -> RED 00 -> color00 -> RED 01 -> color01 -> GREEN 01 -> color01 -> GREEN 02 -> color02 -> BLUE 02 -> color02 -> BLUE 03 -> color03 -> WHITE 03 -> color03 -> WHITE 02 -> color02 -> BLUE 02 -> color02 -> BLUE 03 -> color03 -> WHITE 03 -> color03 -> WHITEIMAGE (1 CLUT):+-------+-------+-------+-------+| Red | Red | Green | Green |+-------+-------+-------+-------+| Red | Red | Green | Green |+-------+-------+-------+-------+| Blue | Blue | White | White |+-------+-------+-------+-------+| Blue | Blue | White | White |+-------+-------+-------+-------+====================================================================------- 16-Bit TIM (NO CLUT DATA)------------ HEADER --------------------------------- Format: 10 00 00 00 TIM Magic BPP: 02 00 00 00 16bpp-- IMAGE DATA HEADER----------------------- Length: 2C 00 00 00 44 bytes (2 bytes for each pixel + 12 bytes for this header) Hres: C0 03 960 Vres: 00 00 0 Width: 04 00 4px Height: 04 00 4px-- RAW IMAGE DATA - 2 byte (ABGR[1555] Color) little endian------- HEX -> HEX -> BINARY -> COLOR LE -> BE -> A BBBBB GGGGG RRRRR -> - ----------------------------------------------- 1F 00 -> 00 1F -> 0 00000 00000 11111 -> RED 1F 00 -> 00 1F -> 0 00000 00000 11111 -> RED E0 03 -> 03 E0 -> 0 00000 11111 00000 -> GREEN E0 03 -> 03 E0 -> 0 00000 11111 00000 -> GREEN 1F 00 -> 00 1F -> 0 00000 00000 11111 -> RED 1F 00 -> 00 1F -> 0 00000 00000 11111 -> RED E0 03 -> 03 E0 -> 0 00000 11111 00000 -> GREEN E0 03 -> 03 E0 -> 0 00000 11111 00000 -> GREEN 00 7C -> 7C 00 -> 0 11111 00000 00000 -> BLUE 00 7C -> 7C 00 -> 0 11111 00000 00000 -> BLUE FF 7F -> 7F FF -> 0 11111 11111 11111 -> WHITE FF 7F -> 7F FF -> 0 11111 11111 11111 -> WHITE 00 7C -> 7C 00 -> 0 11111 00000 00000 -> BLUE 00 7C -> 7C 00 -> 0 11111 00000 00000 -> BLUE FF 7F -> 7F FF -> 0 11111 11111 11111 -> WHITE FF 7F -> 7F FF -> 0 11111 11111 11111 -> WHITEIMAGE:+-------+-------+-------+-------+| Red | Red | Green | Green |+-------+-------+-------+-------+| Red | Red | Green | Green |+-------+-------+-------+-------+| Blue | Blue | White | White |+-------+-------+-------+-------+| Blue | Blue | White | White |+-------+-------+-------+-------+==================================================================== -------- 24-Bit TIM (NO CLUT DATA)--------- NOTE: Some TIM programs don't support 24-bit TIMs Example...Yu_Ri doesn't but TIM viewer does-- HEADER --------------------------------- Format: 10 00 00 00 TIM Magic BPP: 03 00 00 00 24bpp-- IMAGE DATA HEADER ---------------------- Length: 3C 00 00 00 60 bytes (3 bytes for each pixel + 12 bytes for this header) Hres: C0 03 960 Vres: 00 00 0 Width: 06 00 4px (Divided by 1.5 to get actual) Height: 04 00 4px-- RAW IMAGE DATA - 3 byte RGB[888] big endian ---- HEX -> COLOR RR GG BB -> - ----------------- FF 00 00 -> Red FF 00 00 -> Red 00 FF 00 -> Green 00 FF 00 -> Green FF 00 00 -> Red FF 00 00 -> Red 00 FF 00 -> Green 00 FF 00 -> Green 00 00 FF -> Blue 00 00 FF -> Blue FF FF FF -> White FF FF FF -> White 00 00 FF -> Blue 00 00 FF -> Blue FF FF FF -> White FF FF FF -> WhiteIMAGE:+-------+-------+-------+-------+| Red | Red | Green | Green |+-------+-------+-------+-------+| Red | Red | Green | Green |+-------+-------+-------+-------+| Blue | Blue | White | White |+-------+-------+-------+-------+| Blue | Blue | White | White |+-------+-------+-------+-------+
Last edited: