TX2

From MultimediaWiki
Revision as of 01:53, 20 April 2007 by Koorogi (talk | contribs) (document the TX2 image format)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigation Jump to search

Uses

This format is used in Disgaea and other games by Nippon Ichi Software.

Format

The file consists of:

  1. a file header
  2. one or more color palettes as indicated in the header
  3. image data

The file may have garbage data after the end of the image. This should be discarded.

Header

Multibyte values in this format are stored with little-endian byte ordering.

typedef struct {
  uint16_t width;
  uint16_t height;
  uint16_t colors;   /* only values 16 and 256 have been observed */
  uint16_t unknown;
  uint16_t colors2;  /* purpose unknown, but always seems to be the same as colors */
  uint16_t palettes; /* number of palettes.  only 1 and 16 observed thus far */
  uint32_t padding;  /* always zero */
} HEADER;

Palette

The palettes follow immediately after the header, and all have the number of entries indicated by the color field in the file header. The palettes have no header of their own, and instead simply consist of each color:

uint32_t color;      /* 0xAABBGGRR in little endian */

In many images with no apparent need for transparency, the alpha value is always 0x80. Images which truly make use of the alpha channel have been observed, but not explored in detail yet.

Image Data

For 256 color images, each byte is a palette index, with bits 4 and 5 swapped. For the purposes of implementing a parser for this format, it is probably more efficient to reorder the palette while reading it, rather than swapping bits for each pixel.

For 16 color images, each byte gives two palette indexes - the first in the low nibble, the second in the high nibble.