.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.
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:
- A header, containing information about the file: 32+16=48 bits
- Image headers, one for each image
- Image data
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.
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.)
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.
- Great explanation and an example of how to work with s16 at The Creatures Developer Resource (colour handling adaptable to c16)
- Download SpriteBuilder