class RasterFormat
This class serves as description and converter of various pixel formats. U++ normally uses fixed 32-bit RGBA format for all processing, but special formats are required e.g. to deal with image files or to reduce memory requirements.
RASTER_1
|
1 bit per pixel (2 colors, with palette)
|
RASTER_2
|
2 bits per pixel (4 colors, with palette)
|
RASTER_4
|
4 bits per pixel (16 colors, with palette)
|
RASTER_8
|
8 bits per pixel (256 colors, with palette)
|
RASTER_8ALPHA
|
16 bits per pixel; 8 bits for color (256 colors, with palette) and 8 bits for alpha
|
RASTER_16
|
16 bits per pixel (65536 colors without palette), number of bits and placements for individual channels depends on other variables
|
RASTER_24
|
24 bits per pixel RGB (truecolor), number of bits and placements for individual channels depends on other variables
|
RASTER_32
|
32 bits per pixel RGB (truecolor), number of bits and placements for individual channels depends on other variables
|
RASTER_32ALPHA
|
32 bits per pixel RGBA (truecolor), alpha is not premultiplied, number of bits and placements for individual channels depends on other variables
|
RASTER_32PREMULTIPLIED
|
32 bits per pixel RGBA (truecolor), alpha is premultiplied, number of bits and placements for individual channels depends on other variables
|
|
All these values can be combined (using operator|) with
RASTER_MSBFIRST |
|
Indicates that bytes or nibbles are in reversed order (in big endian). |
void Set1lf()
Sets 1 bit per pixel format (RASTER_1).
void Set1mf()
Sets 1 bit per pixel format in reversed MSB mode (RASTER_1|RASTER_MSBFIRST).
void Set2lf()
Sets 2 bits per pixel format (RASTER_2).
void Set2mf()
Sets 2 bits per pixel format in reversed MSB mode (RASTER_2|RASTER_MSBFIRST).
void Set4lf()
Sets 4 bits per pixel format (RASTER_4).
void Set4mf()
Sets 4 bits per pixel format in reversed MSB mode (RASTER_4|RASTER_MSBFIRST).
void Set8()
Sets 8 bits per pixel format (RASTER_8).
void Set8A()
Sets 8+8 bits per pixel format, with 8 bits for color with palette and 8 bits for alpha (RASTER_8ALPHA).
void Set16le(dword rmask, dword gmask, dword bmask)
Sets 16 bits per pixel format with channel placement defined by channel masks in little-endian mode (RASTER_16).
void Set16be(dword rmask, dword gmask, dword bmask)
Sets 16 bits per pixel format with channel placement defined by channel masks in big-endian mode (RASTER_16|RASTER_MSBFIRST).
void Set24le(dword rmask, dword gmask, dword bmask)
Sets 24 bits per pixel format with channel placement defined by channel masks in little-endian mode (RASTER_24).
void Set24be(dword rmask, dword gmask, dword bmask)
Sets 24 bits per pixel format with channel placement defined by channel masks in big-endian mode (RASTER_24|RASTER_MSBFIRST).
void Set32le(dword rmask, dword gmask, dword bmask, dword amask = 0)
Sets 32 bits per pixel format with channel placement defined by channel masks in little-endian mode. If amask is not zero, format is with premultiplied alpha (RASTER_32PREMULTIPLIED), otherwise it is without alpha (RASTER_32).
void Set32be(dword rmask, dword gmask, dword bmask, dword amask = 0)
Sets 32 bits per pixel format with channel placement defined by channel masks in big-endian mode. If amask is not zero, format is with premultiplied alpha (RASTER_32PREMULTIPLIED|RASTER_MSBFIRST), otherwise it is without alpha (RASTER_32|RASTER_MSBFIRST).
void Set32leStraight(dword rmask, dword gmask, dword bmask, dword amask)
Sets 32 bits per pixel format with channel placement defined by channel masks in little-endian mode with non-premultiplied alpha (RASTER_32ALPHA).
void Set32beStraight(dword rmask, dword gmask, dword bmask, dword amask)
Sets 32 bits per pixel format with channel placement defined by channel masks in little-endian mode with non-premultiplied alpha (RASTER_32ALPHA|RASTER_MSBFIRST).
void SetRGBA()
Sets the mode that is bitwise equivalent of standard RGBA quads used in Image.
void SetRGBAStraight()
Similar to SetRGBA, but with non-premultiplied alpha.
int GetType() const
Returns the current format.
int IsRGBA() const
True if format is bitwise equivalent of standard RGBA quads used in Image.
int GetByteCount(int cx) const
Returns a number of bytes required for cx pixels in current format.
int GetBpp() const
Returns the number of bits per pixel of current format.
bool HasAlpha() const
True if current format has alpha.
int GetColorCount() const
Returns the number of colors the current format supports.
int GetPaletteCount() const
Returns the palette size of current format. If format does not have palette, 0 is returned.
void Read(RGBA *t, const byte *s, int cx, const RGBA *palette) const
Converts scanline s of cx pixels in current format to regular RGBA scanline t using palette (ignored for 16 bit and truecolor formats). If format does not have alpha, it is assigned 255 (opaque) to all target pixels.
void Write(byte *t, const RGBA *s, int cx, const PaletteCv *palcv) const
Converts regular RGBA scanline s of cx pixels to scanline t in current format using palcv to convert truecolor to palette formats (ignored for 16 bit and truecolor formats).
|