diff options
-rw-r--r-- | engines/cine/pal.cpp | 11 | ||||
-rw-r--r-- | engines/cine/pal.h | 13 |
2 files changed, 17 insertions, 7 deletions
diff --git a/engines/cine/pal.cpp b/engines/cine/pal.cpp index b2ce45ded8..f3031c3b60 100644 --- a/engines/cine/pal.cpp +++ b/engines/cine/pal.cpp @@ -257,12 +257,11 @@ Palette &Palette::saturatedAddColor(Palette& output, byte firstIndex, byte lastI return output; } -Palette &Palette::saturatedAddNormalizedGray(Palette& output, byte firstIndex, byte lastIndex, double normalizedGray) { - // Calculate the gray value rounded up away from zero - const double signedHalf = ((normalizedGray >= 0) ? +0.5 : -0.5); - const signed r = (signed)(_rMax * normalizedGray + signedHalf); - const signed g = (signed)(_gMax * normalizedGray + signedHalf); - const signed b = (signed)(_bMax * normalizedGray + signedHalf); +Palette &Palette::saturatedAddNormalizedGray(Palette& output, byte firstIndex, byte lastIndex, int grayDividend, int grayDenominator) { + assert(grayDenominator != 0); + const signed r = _rMax * grayDividend / grayDenominator; + const signed g = _gMax * grayDividend / grayDenominator; + const signed b = _bMax * grayDividend / grayDenominator; return saturatedAddColor(output, firstIndex, lastIndex, r, g, b); } diff --git a/engines/cine/pal.h b/engines/cine/pal.h index 2bb93245cf..3364f55857 100644 --- a/engines/cine/pal.h +++ b/engines/cine/pal.h @@ -116,7 +116,18 @@ public: Palette &rotateRight(byte firstIndex, byte lastIndex); Palette &saturatedAddColor(Palette& output, byte firstIndex, byte lastIndex, signed r, signed g, signed b); - Palette &saturatedAddNormalizedGray(Palette& output, byte firstIndex, byte lastIndex, double normalizedGray); + + /*! \brief Saturated add a normalized gray value to current palette's subset and save the modified colors in the given output palette. + * \param output The output palette (Only this palette is modified) + * \param firstIndex First color index of the palette's subset (Inclusive range) + * \param lastIndex Last color index of the palette's subset (Inclusive range) + * \param grayDividend Dividend of the normalized gray value + * \param grayDenominator Denominator of the normalized gray value + * \note The normalized gray value (i.e. in range [-1, +1]) is given as a fractional number + * (i.e. the normalized gray value is calculated by dividing grayDividend by grayDenominator). + */ + Palette &saturatedAddNormalizedGray(Palette& output, byte firstIndex, byte lastIndex, signed grayDividend, signed grayDenominator); + uint colorCount() const; Palette &fillWithBlack(); |