22 #ifndef GRAPHICS_PALETTE_H 23 #define GRAPHICS_PALETTE_H 25 #include "common/hashmap.h" 32 #define PALETTE_COUNT 256 33 #define PALETTE_SIZE (256 * 3) 50 static const uint16 npos = 0xFFFF;
65 Palette(
const byte *data, uint size);
77 bool operator==(
const Palette &rhs)
const {
return equals(rhs); }
78 bool operator!=(
const Palette &rhs)
const {
return !equals(rhs); }
80 bool equals(
const Palette &p)
const;
82 bool contains(
const Palette &p)
const;
84 const byte *data()
const {
return _data; }
85 uint size()
const {
return _size; }
87 void set(uint entry, byte r, byte g, byte b) {
88 assert(entry < _size);
89 _data[entry * 3 + 0] = r;
90 _data[entry * 3 + 1] = g;
91 _data[entry * 3 + 2] = b;
94 void get(uint entry, byte &r, byte &g, byte &b)
const {
95 assert(entry < _size);
96 r = _data[entry * 3 + 0];
97 g = _data[entry * 3 + 1];
98 b = _data[entry * 3 + 2];
106 uint
find(byte r, byte g, byte b)
const {
107 for (uint i = 0; i < _size; i++) {
108 if (_data[i * 3 + 0] == r && _data[i * 3 + 1] == g && _data[i * 3 + 2] == b)
121 byte
findBestColor(byte r, byte g, byte b,
bool useNaiveAlg =
false)
const;
136 void set(
const byte *colors, uint start, uint num);
137 void set(
const Palette &p, uint start, uint num);
149 void grab(byte *colors, uint start, uint num)
const;
173 bool setPalette(
const byte *palette, uint len);
183 byte
findBestColor(byte r, byte g, byte b,
bool useNaiveAlg =
false);
195 uint32 *createMap(
const byte *srcPalette, uint len,
bool useNaiveAlg =
false);
byte findBestColor(byte r, byte g, byte b, bool useNaiveAlg=false) const
Palette(uint size)
Construct a new Palette object.
Definition: palette.h:153
Definition: formatinfo.h:28
uint find(byte r, byte g, byte b) const
Definition: palette.h:106
Simple class for handling a palette data.
Definition: palette.h:45
static Palette createEGAPalette()
void grab(byte *colors, uint start, uint num) const