This document describes version 0 of the TIZ file format. TIZ is a compressed tileset format, made to be compatible with the (uncompressed) TIS format used in Baldur's Gate and related games.
The file starts with a header, followed by one or more tiles.
Note: all integers are in msb first (Motorola) order.
| Offset | Size | Data | Description |
|---|---|---|---|
| 0 | 4 | "TIZ0" (0x54 0x49 0x5a 0x30) | ID. TIZ for compressed TIS, 0 is the file format version. |
| 4 | 2 | 16-bit unsigned integer | Number of tiles in the file. |
| 6 | 2 | reserved | Reserved for future use. Set to 0x00 0x00. |
Tiles are always 64x64 pixels, and can be stored in one of three different formats. Common to all formats is that they start with a TILx header, followed by the number of bytes to the next tile.
| Format | ID | Description |
|---|---|---|
| 0 | "TIL0" (0x54 0x49 0x4c 0x30) | This is a zlib compressed version of the original TIS format. This compression is not lossy. |
| 1 | "TIL1" (0x54 0x49 0x4c 0x31) | This is a JPEG compressed tile, with the palette and alpha mask stored separately. The image data is compressed with JPEG (lossy), and the palette and alpha mask are compressed with zlib (non-lossy). |
| 2 | "TIL2" (0x54 0x49 0x4c 0x32) | This is a JPEG compressed tile. The image data is compressed with JPEG (lossy). This format can not be used for tiles with alpha information (overlay tiles). |
| Offset | Size | Data | Description |
|---|---|---|---|
| 0 | 4 | "TIL0" (0x54 0x49 0x4c 0x30) | This identifies the tile as being stored in format 0. |
| 4 | 2 | 16-bit unsigned integer | Length of the tile data. |
| 6 | see previous | Compressed TIS tile |
Image data compressed with zlib deflate at Z_BEST_COMPRESSION
(level 9).
The image data is the same as the raw TIS format: It starts with 256 palette values in {R,G,B,a} format (4 bytes each, 1024 bytes total), followed by 4096 bytes of 8-bit image data. |
| Offset | Size | Data | Description |
|---|---|---|---|
| 0 | 4 | "TIL1" (0x54 0x49 0x4c 0x31) | This identifies the tile as being stored in format 1. |
| 4 | 2 | 16-bit unsigned integer | Length of the tile data. |
| 6 | 2 | 16-bit unsigned integer | Length of the compressed palette and alpha mask. |
| 8 | see previous | Compressed palette and alpha mask |
Palette and alpha mask data compressed with zlib deflate
at Z_BEST_COMPRESSION (level 9).
It starts with 256 palette values in {R,G,B} format (3 bytes each, 768 bytes total), followed by 512 bytes of 1-bit alpha mask data, stored in msb first order (8 bytes per line, 64 lines). A zero bit indicates a transparent pixel, a one indicates an opaque pixel. |
| depends | offset 4 - offset 6 - 2 | Compressed bitmap | The bitmap is compressed as a 24-bit JPEG image. |
| Offset | Size | Data | Description |
|---|---|---|---|
| 0 | 4 | "TIL2" (0x54 0x49 0x4c 0x32) | This identifies the tile as being stored in format 2. |
| 4 | 2 | 16-bit unsigned integer | Length of the tile data. |
| 6 | see previous | Compressed image | The bitmap is compressed as a 24-bit JPEG image. |