Simple class for handling a palette data. More...
#include <palette.h>
Public Member Functions | |
Palette (uint size) | |
Construct a new Palette object. More... | |
Palette (const byte *data, uint size) | |
Construct a new Palette object. More... | |
Palette (const Palette &p) | |
Palette & | operator= (const Palette &rhs) |
bool | operator== (const Palette &rhs) const |
bool | operator!= (const Palette &rhs) const |
bool | equals (const Palette &p) const |
bool | contains (const Palette &p) const |
const byte * | data () const |
uint | size () const |
void | set (uint entry, byte r, byte g, byte b) |
void | get (uint entry, byte &r, byte &g, byte &b) const |
uint | find (byte r, byte g, byte b) const |
byte | findBestColor (byte r, byte g, byte b, bool useNaiveAlg=false) const |
void | clear () |
void | set (const byte *colors, uint start, uint num) |
void | set (const Palette &p, uint start, uint num) |
void | grab (byte *colors, uint start, uint num) const |
void | grab (Palette &p, uint start, uint num) const |
Static Public Member Functions | |
static Palette | createEGAPalette () |
Static Public Attributes | |
static const uint16 | npos = 0xFFFF |
Simple class for handling a palette data.
The palette data is specified in interleaved RGB format. That is, the first byte of the memory block 'colors' points at is the red component of the first new color; the second byte the green component of the first new color; the third byte the blue component, the last byte to the alpha (transparency) value. Then the second color starts, and so on. So memory looks like this: R1-G1-B1-R2-G2-B2-R3-...
Graphics::Palette::Palette | ( | uint | size | ) |
Construct a new Palette object.
size | the number of palette entries |
Graphics::Palette::Palette | ( | const byte * | data, |
uint | size | ||
) |
Construct a new Palette object.
data | the palette data, in interleaved RGB format |
size | the number of palette entries |
|
static |
Constructs a new palette containing the standarad EGA palette
|
inline |
Finds the index of an exact color from the palette.
byte Graphics::Palette::findBestColor | ( | byte | r, |
byte | g, | ||
byte | b, | ||
bool | useNaiveAlg = false |
||
) | const |
Finds the index of the closest color from the palette.
useNaiveAlg | if true, use a simpler algorithm |
void Graphics::Palette::set | ( | const byte * | colors, |
uint | start, | ||
uint | num | ||
) |
Replace the specified range of the palette with new colors. The palette entries from 'start' till (start+num-1) will be replaced - so a full palette update is accomplished via start=0, num=256.
colors | the new palette data, in interleaved RGB format |
start | the first palette entry to be updated |
num | the number of palette entries to be updated |
void Graphics::Palette::grab | ( | byte * | colors, |
uint | start, | ||
uint | num | ||
) | const |
Grabs a specified part of the currently active palette. The format is the same as for setPalette.
colors | the palette data, in interleaved RGB format |
start | the first platte entry to be read |
num | the number of palette entries to be read |