diff options
author | Kari Salminen | 2009-03-24 21:45:35 +0000 |
---|---|---|
committer | Kari Salminen | 2009-03-24 21:45:35 +0000 |
commit | 51751cd0691b25bcdb882b72ab8c8347d8b3cfbb (patch) | |
tree | a51a833a710134993e0d117e644e1636347f36a9 | |
parent | b85b6929bdd7c238a58ca0ab1ad0158e457d949e (diff) | |
download | scummvm-rg350-51751cd0691b25bcdb882b72ab8c8347d8b3cfbb.tar.gz scummvm-rg350-51751cd0691b25bcdb882b72ab8c8347d8b3cfbb.tar.bz2 scummvm-rg350-51751cd0691b25bcdb882b72ab8c8347d8b3cfbb.zip |
Cine::Palette: Add fillWithBlack and saturatedAddNormalizedGray-methods.
svn-id: r39676
-rw-r--r-- | engines/cine/pal.cpp | 20 | ||||
-rw-r--r-- | engines/cine/pal.h | 3 |
2 files changed, 23 insertions, 0 deletions
diff --git a/engines/cine/pal.cpp b/engines/cine/pal.cpp index 2d8774f59a..b2ce45ded8 100644 --- a/engines/cine/pal.cpp +++ b/engines/cine/pal.cpp @@ -211,6 +211,16 @@ uint Palette::colorCount() const { return _colors.size(); } +Palette &Palette::fillWithBlack() { + for (uint i = 0; i < _colors.size(); i++) { + _colors[i].r = 0; + _colors[i].g = 0; + _colors[i].b = 0; + } + + return *this; +} + EndianType Palette::endianType() const { return (_bigEndian ? CINE_BIG_ENDIAN : CINE_LITTLE_ENDIAN); } @@ -247,6 +257,16 @@ 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); + + return saturatedAddColor(output, firstIndex, lastIndex, r, g, b); +} + // a.k.a. transformColor // Parameter color components (i.e. r, g and b) are in range [-7, 7] // e.g. r = 7 sets the resulting color's red component to maximum diff --git a/engines/cine/pal.h b/engines/cine/pal.h index afb86c871c..2bb93245cf 100644 --- a/engines/cine/pal.h +++ b/engines/cine/pal.h @@ -116,8 +116,11 @@ 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); uint colorCount() const; + Palette &fillWithBlack(); + /*! \brief The original endian type in which this palette was loaded. * \note This will always return either CINE_BIG_ENDIAN or CINE_LITTLE_ENDIAN (So no CINE_NATIVE_ENDIAN). */ |