22 #ifndef GRAPHICS_PALETTE_H 23 #define GRAPHICS_PALETTE_H 25 #include "common/hashmap.h" 44 static const uint16 npos = 0xFFFF;
59 Palette(
const byte *data, uint size);
66 bool operator==(
const Palette &rhs)
const {
return equals(rhs); }
67 bool operator!=(
const Palette &rhs)
const {
return !equals(rhs); }
69 bool equals(
const Palette &p)
const;
71 bool contains(
const Palette &p)
const;
73 const byte *data()
const {
return _data; }
74 uint size()
const {
return _size; }
76 void set(uint entry, byte r, byte g, byte b) {
77 assert(entry < _size);
78 _data[entry * 3 + 0] = r;
79 _data[entry * 3 + 1] = g;
80 _data[entry * 3 + 2] = b;
83 void get(uint entry, byte &r, byte &g, byte &b)
const {
84 assert(entry < _size);
85 r = _data[entry * 3 + 0];
86 g = _data[entry * 3 + 1];
87 b = _data[entry * 3 + 2];
95 uint
find(byte r, byte g, byte b)
const {
96 for (uint i = 0; i < _size; i++) {
97 if (_data[i * 3 + 0] == r && _data[i * 3 + 1] == g && _data[i * 3 + 2] == b)
110 byte
findBestColor(byte r, byte g, byte b,
bool useNaiveAlg =
false)
const;
125 void set(
const byte *colors, uint start, uint num);
126 void set(
const Palette &p, uint start, uint num);
138 void grab(byte *colors, uint start, uint num)
const;
162 bool setPalette(
const byte *palette, uint len);
172 byte
findBestColor(byte r, byte g, byte b,
bool useNaiveAlg =
false);
184 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:142
Definition: formatinfo.h:28
uint find(byte r, byte g, byte b) const
Definition: palette.h:95
Simple class for handling a palette data.
Definition: palette.h:39
void grab(byte *colors, uint start, uint num) const