-
Notifications
You must be signed in to change notification settings - Fork 0
/
Palette.h
46 lines (35 loc) · 1.13 KB
/
Palette.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
/**
* Utility class that represents an image's palette.
*
* @author Francis BISSON
*/
#ifndef PALETTE_H
#define PALETTE_H
// INCLUDES ////////////////////////////////////////////////////////////////////
#include <boost/shared_ptr.hpp>
#include <SDL/SDL.h>
#include "Color.h"
#include "Types.h"
// CLASS DEFINITION ////////////////////////////////////////////////////////////
class Palette
{
friend class Image;
public:
Palette();
Palette(Byte nbColors);
Palette(Byte nbColors, Color* colors);
Palette(const Palette& palette);
virtual ~Palette();
virtual Palette& operator= (const Palette& palette);
virtual Color GetColor(Byte index);
virtual void SetColor(Byte index, const Color& color);
virtual Byte GetNbColors() const { return m_NbColors; }
protected:
Byte m_NbColors;
// We use SDL_Color instead of Color to avoid an additional overhead when
// changing an image's palette
SDL_Color* m_Colors;
};
// UTILITY TYPEDEFS ////////////////////////////////////////////////////////////
typedef boost::shared_ptr<Palette> PalettePtr;
#endif // PALETTE_H