Add a "fill" method to Palette.

svn-id: r41952
This commit is contained in:
Johannes Schickel 2009-06-29 16:49:38 +00:00
parent bfe8ec6d66
commit 07cdbd273d
2 changed files with 15 additions and 0 deletions

View File

@ -3308,6 +3308,12 @@ void Palette::clear() {
memset(_palData, 0, _numColors * 3);
}
void Palette::fill(int firstCol, int numCols, uint8 value) {
assert(firstCol >= 0 && firstCol + numCols <= _numColors);
memset(_palData + firstCol * 3, CLIP<int>(value, 0, 63), numCols * 3);
}
void Palette::copy(const Palette &source, int firstCol, int numCols, int dstStart) {
if (numCols == -1)
numCols = MIN(source.getNumColors(), _numColors) - firstCol;

View File

@ -104,6 +104,15 @@ public:
*/
void clear();
/**
* Fill the given indexes with the given component value.
*
* @param firstCol the first color, which should be overwritten.
* @param numCols number of colors, which schould be overwritten.
* @param value color component value, which should be stored.
*/
void fill(int firstCol, int numCols, uint8 value);
/**
* Copy data from another palette.
*