blob: c024adcea02fdeefa2d247e5bdec0a270950c964 [file] [log] [blame]
Constantin Kaplinskya2adc8d2006-05-25 05:01:55 +00001/* Copyright (C) 2002-2005 RealVNC Ltd. All Rights Reserved.
Pierre Ossman8c466192011-03-02 12:45:57 +00002 * Copyright 2011 Pierre Ossman <ossman@cendio.se> for Cendio AB
Constantin Kaplinskya2adc8d2006-05-25 05:01:55 +00003 *
4 * This is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by
6 * the Free Software Foundation; either version 2 of the License, or
7 * (at your option) any later version.
8 *
9 * This software is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
13 *
14 * You should have received a copy of the GNU General Public License
15 * along with this software; if not, write to the Free Software
16 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,
17 * USA.
18 */
19#ifndef __RFB_COLOURMAP_H__
20#define __RFB_COLOURMAP_H__
21namespace rfb {
22 struct Colour {
23 Colour() : r(0), g(0), b(0) {}
24 Colour(int r_, int g_, int b_) : r(r_), g(g_), b(b_) {}
25 int r, g, b;
26 bool operator==(const Colour& c) const {return c.r == r && c.g == g && c.b == b;}
27 bool operator!=(const Colour& c) const {return !(c == *this);}
28 };
29
30 class ColourMap {
31 public:
32 virtual void lookup(int index, int* r, int* g, int* b)=0;
DRC28c6bcc2011-11-03 00:53:57 +000033 virtual ~ColourMap() {}
Constantin Kaplinskya2adc8d2006-05-25 05:01:55 +000034 };
Pierre Ossman8c466192011-03-02 12:45:57 +000035
36 class SimpleColourMap : public ColourMap {
37 public:
38 SimpleColourMap(int size = 256) { table = new Colour[size]; };
DRC28c6bcc2011-11-03 00:53:57 +000039 virtual ~SimpleColourMap() { delete [] table; };
Pierre Ossman8c466192011-03-02 12:45:57 +000040
41 void lookup(int index, int* r, int* g, int* b)
42 { *r = table[index].r; *g = table[index].g; *b = table[index].b; };
43
44 void set(int index, int r, int g, int b)
45 { table[index].r = r; table[index].g = g; table[index].b = b; };
46
47 protected:
48 Colour *table;
49 };
Constantin Kaplinskya2adc8d2006-05-25 05:01:55 +000050}
51#endif