Skip to content

Tgx file

Julian Offenhäuser edited this page Jan 6, 2020 · 3 revisions

File outline:

  • Header (8 bytes)
  • Compressed pixel data
struct TgxHeader {
    uint32_t width;
    uint32_t height;
};

Pixel format:

Single uint16 (big-endian). First bit is unused, 5 bits red, 5 bits green, 5 bits blue.

Pixel data:

Consists of 1-byte command tokens. The least significant 5 bits are used to store the length of the following pixel stream (add one). The most significant 3 bits form the command. Valid commands are:

  • 0: Raw pixel data, length number of pixels follow.
  • 1: Transparent pixels, skip length number of pixels (no bytes following)
  • 2: Repeating pixel, read one pixel and add length times to the image
  • 4: Line break, increase y and reset x position (no bytes following)
Clone this wiki locally