C16 files

From Creatures Wikia

Jump to: navigation, search

.c16 is the extension for C16 files, used in most Creatures 3/Docking Station images. These files actually store several images, so most agents only need one c16. They can be viewed and edited with Creature Labs' SpriteBuilder, and previewed in Windows using GreenReaper's Sprite Thumbnail Viewer. The c16 is a compressed version of the s16 file, where transparent pixels are grouped together as a pixel count.

C16 files are used by the Creatures Evolution Engine to store compressed sprite data. They're compressed simply by Run Length Encoding (RLE) transparent pixels in the image files.

In the following description, 'uint16' refers to an unsigned 16 bit short integer, and 'uint32' to an unsigned 32 bit integer. Files are stored in little-endian format.

You can find the file naming convention here.


A C16 file consists of three distinct parts:

  1. A header, containing information about the file: 32+16=48 bits
  2. Image headers, one for each image
  3. Image data

File header

The first 32 bits are a bitfield:

  • Bit 0: RGB pixel format; 0=555, 1=565
  • Bit 1: Must be 1! (S16 files have 0 here)
  • Bits 2-31: Unused, should be 0

The next 16 bits are a uint16, the number of sprites in the file.

Image header

Then comes a whole bunch of image headers, one for each sprite in the file:

  • uint32: Offset to beginning of first line in image data
  • uint16: Image width in pixels
  • uint16: Image height in pixels
  • uint32[height-1]: Array of offsets pointing to the start-location of rest of the image lines (Not including line 0, we already know that.)

Image data

Each "line" or 'row' of an image, as pointed to by the image header, is split into one or more "runs". These runs can be either transparent or color runs.

A run begins with a uint16 tag:

  • Bit 0: Run type; 0=Transparent, 1=Color
  • Bits 1-15: specifies the run length in pixels (0 - 32767)

For a color run, the tag will be followed by the given number of 16-bit color pixels. (Black pixels #000000 are to be considered transparent).

For a transparent run, nothing follows the tag.

Each line is terminated by a zero tag (uint16), with an additional zero tag to represent the end of the image.

Related Links

External links

Personal tools