TXTF File Format
- Used all over the place for images.
- Look at the first 4 bytes for 'txtf' to determine
if file is a TXTF file.
- Intel style byte ordering .
- 16 bit rgb pixels (0rrrrrgggggbbbbb) (see Pixel
Format below).
File Header (26 bytes)
// txtf header
int signature; // 'txtf'
int version; // TODO: get this value for - always the same
int width; // width in pixels
int height; // height in pixels
short type; // some type field (Cappy knows but won't tell me :)
int hotpointx; // x value of hotpoint in pixels
int hotpointy; // y value of hotpoint in pixels
byte image[width*height*2]; // pixel data
Pixel Format
// PIXEL FORMAT
//
// Artwork is stored as 16 bit graphics. Each component of the pixel is
// made up of red, green and blue. Components have a value between 0 and 31
//
//
typedef unsigned short CC3PIXEL;
// builds a CC3PIXEL from r,g,b where r,g,b are in the range 0..255
#define CC3PIXEL_RGB255(r255,g255,b255) (CC3PIXEL)(((r255 >> 3) << 10) | ((g255 >> 3) << 5) | ((b255 >> 3)))
// breaks the CC3PIXEL into red,green,blue componentes (values will be 0..31)
#define CC3PIXEL_R(cc3pixel) ((cc3pixel>>10)&0x1f)
#define CC3PIXEL_G(cc3pixel) ((cc3pixel>>5 )&0x1f)
#define CC3PIXEL_B(cc3pixel) ((cc3pixel )&0x1f)
// same as CC3PIXEL_xxx but scales the values correctly into the range of 0..255
#define CC3PIXEL_R255(cc3pixel) ((CC3PIXEL_R(cc3pixel) << 3) | (CC3PIXEL_R(cc3pixel) >> 2))
#define CC3PIXEL_G255(cc3pixel) ((CC3PIXEL_G(cc3pixel) << 3) | (CC3PIXEL_G(cc3pixel) >> 2))
#define CC3PIXEL_B255(cc3pixel) ((CC3PIXEL_B(cc3pixel) << 3) | (CC3PIXEL_B(cc3pixel) >> 2))