GRAPHICS: Add hasPalette and grabPalette to ManagedSurface

This commit is contained in:
Cameron Cawley 2022-12-17 22:08:24 +00:00 committed by Eugene Sandulenko
parent 2caa338dbd
commit 8f85390b4c
2 changed files with 24 additions and 0 deletions

View file

@ -748,6 +748,18 @@ void ManagedSurface::clear(uint32 color) {
fillRect(getBounds(), color);
}
void ManagedSurface::grabPalette(byte *colors, uint start, uint num) const {
assert(start < 256 && (start + num) <= 256);
const uint32 *src = &_palette[start];
for (; num > 0; --num, colors += 3) {
uint32 p = *src++;
colors[0] = p & 0xff;
colors[1] = (p >> 8) & 0xff;
colors[2] = (p >> 16) & 0xff;
}
}
void ManagedSurface::setPalette(const byte *colors, uint start, uint num) {
assert(start < 256 && (start + num) <= 256);
uint32 *dest = &_palette[start];