diff --git a/engines/cine/pal.cpp b/engines/cine/pal.cpp index b8b2580cf07..a1c5b6f6757 100644 --- a/engines/cine/pal.cpp +++ b/engines/cine/pal.cpp @@ -184,6 +184,18 @@ Graphics::PixelFormat Palette::colorFormat() const { return _format; } +void Palette::setColorFormat(const Graphics::PixelFormat format) { + _format = format; + + _rBits = (8 - format.rLoss); + _gBits = (8 - format.gLoss); + _bBits = (8 - format.bLoss); + + _rMax = (1 << _rBits) - 1; + _gMax = (1 << _gBits) - 1; + _bMax = (1 << _bBits) - 1; +} + // a.k.a. transformPaletteRange Palette &Palette::saturatedAddColor(byte firstIndex, byte lastIndex, signed r, signed g, signed b) { assert(firstIndex < colorCount() && lastIndex < colorCount()); @@ -218,15 +230,7 @@ Palette &Palette::load(const byte *colors, const Graphics::PixelFormat format, c assert(format.gShift / 8 == (format.gShift + MAX(0, 8 - format.gLoss - 1)) / 8); // G must be inside one byte assert(format.bShift / 8 == (format.bShift + MAX(0, 8 - format.bLoss - 1)) / 8); // B must be inside one byte - _format = format; - - _rBits = (8 - format.rLoss); - _gBits = (8 - format.gLoss); - _bBits = (8 - format.bLoss); - - _rMax = (1 << _rBits) - 1; - _gMax = (1 << _gBits) - 1; - _bMax = (1 << _bBits) - 1; + setColorFormat(format); _colors.clear(); _colors.resize(numColors); diff --git a/engines/cine/pal.h b/engines/cine/pal.h index 806a8ab5acc..4d59a6e9980 100644 --- a/engines/cine/pal.h +++ b/engines/cine/pal.h @@ -70,6 +70,7 @@ public: Graphics::PixelFormat colorFormat() const; private: + void setColorFormat(const Graphics::PixelFormat format); void saturatedAddColor(byte index, signed r, signed g, signed b); private: