From f314041b6b37bb9274d9fc79946858341befa0f2 Mon Sep 17 00:00:00 2001 From: Mike Buland Date: Wed, 8 Apr 2015 08:40:05 -0600 Subject: Added image goo + font support. --- src/palette.cpp | 32 ++++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) create mode 100644 src/palette.cpp (limited to 'src/palette.cpp') 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 @@ +#include "palette.h" + +#include + +Palette::Palette() : + iCount( 0 ), + piChannels( NULL ) +{ + piChannels = new uint8_t[256*3]; + memset( piChannels, 0, 256*3 ); +} + +Palette::~Palette() +{ + delete[] piChannels; +} + +int32_t Palette::addColor( uint8_t iRed, uint8_t iGreen, uint8_t iBlue ) +{ + piChannels[iCount*3] = iRed; + piChannels[iCount*3+1] = iGreen; + piChannels[iCount*3+2] = iBlue; + return iCount++; +} + +void Palette::getColor( int32_t iIdx, uint8_t &iRed, uint8_t &iGreen, + uint8_t &iBlue ) +{ + iRed = piChannels[iIdx*3]; + iGreen = piChannels[iIdx*3+1]; + iBlue = piChannels[iIdx*3+2]; +} -- cgit v1.2.3