diff options
Diffstat (limited to '')
-rw-r--r-- | src/palette.cpp | 32 |
1 files changed, 32 insertions, 0 deletions
diff --git a/src/palette.cpp b/src/palette.cpp new file mode 100644 index 0000000..0e3a3b1 --- /dev/null +++ b/src/palette.cpp | |||
@@ -0,0 +1,32 @@ | |||
1 | #include "palette.h" | ||
2 | |||
3 | #include <string.h> | ||
4 | |||
5 | Palette::Palette() : | ||
6 | iCount( 0 ), | ||
7 | piChannels( NULL ) | ||
8 | { | ||
9 | piChannels = new uint8_t[256*3]; | ||
10 | memset( piChannels, 0, 256*3 ); | ||
11 | } | ||
12 | |||
13 | Palette::~Palette() | ||
14 | { | ||
15 | delete[] piChannels; | ||
16 | } | ||
17 | |||
18 | int32_t Palette::addColor( uint8_t iRed, uint8_t iGreen, uint8_t iBlue ) | ||
19 | { | ||
20 | piChannels[iCount*3] = iRed; | ||
21 | piChannels[iCount*3+1] = iGreen; | ||
22 | piChannels[iCount*3+2] = iBlue; | ||
23 | return iCount++; | ||
24 | } | ||
25 | |||
26 | void Palette::getColor( int32_t iIdx, uint8_t &iRed, uint8_t &iGreen, | ||
27 | uint8_t &iBlue ) | ||
28 | { | ||
29 | iRed = piChannels[iIdx*3]; | ||
30 | iGreen = piChannels[iIdx*3+1]; | ||
31 | iBlue = piChannels[iIdx*3+2]; | ||
32 | } | ||