TBG Images (*.tbg) - Anonym271/7scarlet-tools GitHub Wiki

TBG Image Files

The TBG format is the main image format the game uses. It is extremely simple and uncompressed. Unlike in the archive files the numbers in TBG images are stored in the little endian format (the regular one on Intel CPUs).

Header

Offset Type Name Description
0x00 int32 magic Magic number (always "tbg\0")
0x04 uint32 data_offset Offset of the image data
0x08 uint32 data_length Length of the image data
0x0C uint32 width Width of the image in pixels
0x10 uint32 height Height of the image in pixels
0x14 uint32 flags Contains information about the format. Usually the first three bytes are 0x00 0x10 0x00 and the last one defines the pixel format. I could not yet find any system behind this format but the only two values I have encountered so far are 0x98 for BGR (24 bits per pixel) and 0x0C for BGRA (32 bits per pixel).
0x18 uint32 image_count Probably the image count, is always 1. But could be everything to be honest.
0x1C uint32 unkn1 Unknown, usually 0
0x20 uint32 unkn2 Unknown, usually 0
0x24 float32 resx Horizontal resolution (probably, is always 1)
0x28 float32 resy Vertical resolution (probably, is always 1)

After this header a segment of zeros follows up to position 0x33C (828) that does not seem to have any use. After this the data segment starts.

Data Segment

The offset and length of the data segment is defined in the header. It consists of raw pixel data, line by line, in the format defined in the header (BGR or BGRA).