diff options
author | Kari Salminen | 2009-03-25 19:52:08 +0000 |
---|---|---|
committer | Kari Salminen | 2009-03-25 19:52:08 +0000 |
commit | 39f7484c9e5255592c7cd244d65e5904ce095eed (patch) | |
tree | 32c36ea2187594e906fbbd326cb3abefc8b9845c /engines | |
parent | a3a7893f163bdff7845a23c5a4f29709eaffb4a0 (diff) | |
download | scummvm-rg350-39f7484c9e5255592c7cd244d65e5904ce095eed.tar.gz scummvm-rg350-39f7484c9e5255592c7cd244d65e5904ce095eed.tar.bz2 scummvm-rg350-39f7484c9e5255592c7cd244d65e5904ce095eed.zip |
Cine::Palette::saturatedAddNormalizedGray: Use fractional representation (dividend/denominator) of the normalized gray value in range [-1, +1] rather than a floating point.
svn-id: r39691
Diffstat (limited to 'engines')
-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(); |