GRAPHICS: Return flag if palette was updated for the palette lookup

This commit is contained in:
Eugene Sandulenko 2022-07-03 23:24:18 +02:00
parent 1edcbcb53e
commit c87c02c5ae
No known key found for this signature in database
GPG key ID: 014D387312D34F08
2 changed files with 7 additions and 3 deletions

View file

@ -32,14 +32,16 @@ PaletteLookup::PaletteLookup(const byte *palette, uint len) {
memcpy(_palette, palette, len * 3); memcpy(_palette, palette, len * 3);
} }
void PaletteLookup::setPalette(const byte *palette, uint len) { bool PaletteLookup::setPalette(const byte *palette, uint len) {
// Check if the passed palette matched the one we have // Check if the passed palette matched the one we have
if (len == _paletteSize && !memcmp(_palette, palette, len * 3)) if (len == _paletteSize && !memcmp(_palette, palette, len * 3))
return; return false;
_paletteSize = len; _paletteSize = len;
memcpy(_palette, palette, len * 3); memcpy(_palette, palette, len * 3);
_colorHash.clear(); _colorHash.clear();
return true;
} }
byte PaletteLookup::findBestColor(byte cr, byte cg, byte cb) { byte PaletteLookup::findBestColor(byte cr, byte cg, byte cb) {

View file

@ -128,8 +128,10 @@ public:
* *
* @param palette the palette data, in interleaved RGB format * @param palette the palette data, in interleaved RGB format
* @param len the number of palette entries to be read * @param len the number of palette entries to be read
*
* @return true if palette was changed and false if it was the same
*/ */
void setPalette(const byte *palette, uint len); bool setPalette(const byte *palette, uint len);
/** /**
* @brief This method returns closest color from the palette * @brief This method returns closest color from the palette