The format class describes one of two kinds of pixel formats: indexed color and direct color.
Indexed color pixel formats describe of pixel values that index into a palette (See ptc::Palette).
Direct color pixel formats describe pixels that have red, green, blue and alpha information packed into each pixel.
Format objects are typically used when creating surface classes with Surface::Surface(), and when opening consoles with Console::open()(const char title[],const Format &format,int pages).
Default constructor.
bits, r, g, b and a are all set to zero.
Creates an indexed pixel format where each pixel entry represents an index into a palette.
Currently the only indexed format supported is 8 bit indexed color, ie. 256 color.
If the bits parameter is not equal to 8 then an error exception will be thrown.
Creates a direct color pixel format with the red, green, blue and alpha masks r, g, b and a.
For each of the mask values set bits (1) represent bits allocated to the color component, and clear bits (0) represent unused bits.
Here are some common direct color pixel formats:
// 32 bit RGB888 Format format(32,0x00FF0000,0x0000FF00,0x000000FF); // 24 bit RGB888 Format format(24,0xFF0000,0x00FF00,0x0000FF); // 16 bit RGB565 Format format(16,0xF800,0x07E0,0x001F); // 15 bit RGB555 Format format(16,0x7C00,0x03E0,0x001F); // 8 bit RGB332 Format format(8,0xE0,0x1C,0x03); // 32 bit ARGB8888 Format format(32,0x00FF0000,0x0000FF00,0x000000FF,0xFF000000); // 16 bit ARGB1555 Format format(16,0x7C00,0x03E0,0x001F,0x8000);
An error exception is thrown if the bits parameter is not 8, 16, 24 or 32.
Copy constructor.
Destructor.
Gets the red component mask of the format object.
The red color mask is only valid if the format object is direct color.
A format object is direct color if it was created by the Format::Format()(int bits,int32 r,int32 g,int32 b,int32 a) constructor.
If the format object is not direct color then the red mask is always zero.
Gets the green component mask of the format object.
The green color mask is only valid if the format object is direct color.
A format object is direct color if it was created by the Format::Format()(int bits,int32 r,int32 g,int32 b,int32 a) constructor.
If the format object is not direct color then the green mask is always zero.
Gets the blue component mask of the format object.
The blue color mask is only valid if the format object is direct color.
A format object is direct color if it was created by the Format::Format()(int bits,int32 r,int32 g,int32 b,int32 a) constructor.
If the format object is not direct color then the blue mask is always zero.
Gets the alpha component mask of the format object.
The alpha color mask is only valid if the format object is direct color.
A format object is direct color if it was created by the Format::Format()(int bits,int32 r,int32 g,int32 b,int32 a) constructor.
If the format object is not direct color then the alpha mask is always zero.
Gets the bits per pixel of the format object.
Bits per pixel is either 8, 16, 24 or 32 in direct color, or 8 in indexed color.
Gets the bytes per pixel of the format object.
Bytes per pixel is either 1, 2, 3 or 4 in direct color, or 1 in indexed color.
Checks if the format is direct color.
A format object is direct color if it was created by the Format::Format()(int bits,int32 r,int32 g,int32 b,int32 a) constructor.
Checks if the format is indexed color.
A format object is indexed color if it was created by the Format(int bits) constructor.
Assignment operator.
Equality operator.
Inequality operator.