aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKari Salminen2009-03-16 21:10:15 +0000
committerKari Salminen2009-03-16 21:10:15 +0000
commit97887377f0784bab34f2cb69638174b3243d380c (patch)
tree994771fea0851b9825e693cc4e0c7c8ab418268e
parent9dc2f16f16e4a76a6c957af6bbfc8272736e1512 (diff)
downloadscummvm-rg350-97887377f0784bab34f2cb69638174b3243d380c.tar.gz
scummvm-rg350-97887377f0784bab34f2cb69638174b3243d380c.tar.bz2
scummvm-rg350-97887377f0784bab34f2cb69638174b3243d380c.zip
Cine::Palette: Make saturatedAddColor-methods more like their old counterparts transformPaletteRange and transformColor.
svn-id: r39454
-rw-r--r--engines/cine/pal.cpp18
-rw-r--r--engines/cine/pal.h13
2 files changed, 18 insertions, 13 deletions
diff --git a/engines/cine/pal.cpp b/engines/cine/pal.cpp
index 5d1637084e..244ff74981 100644
--- a/engines/cine/pal.cpp
+++ b/engines/cine/pal.cpp
@@ -236,23 +236,27 @@ void Palette::setEndianType(const EndianType endianType) {
}
// a.k.a. transformPaletteRange
-Palette &Palette::saturatedAddColor(byte firstIndex, byte lastIndex, signed r, signed g, signed b) {
+Palette &Palette::saturatedAddColor(Palette& output, byte firstIndex, byte lastIndex, signed r, signed g, signed b) {
assert(firstIndex < colorCount() && lastIndex < colorCount());
+ assert(firstIndex < output.colorCount() && lastIndex < output.colorCount());
+ assert(output.colorFormat() == colorFormat());
for (uint i = firstIndex; i <= lastIndex; i++)
- saturatedAddColor(i, r, g, b);
+ output._colors[i] = saturatedAddColor(_colors[i], r, g, b);
- return *this;
+ return output;
}
// 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
// e.g. r = -7 sets the resulting color's red component to minimum (i.e. zero)
-void Palette::saturatedAddColor(byte index, signed r, signed g, signed b) {
- _colors[index].r = CLIP<int>(_colors[index].r + r, 0, _rMax);
- _colors[index].g = CLIP<int>(_colors[index].g + g, 0, _gMax);
- _colors[index].b = CLIP<int>(_colors[index].b + b, 0, _bMax);
+Cine::Palette::Color Palette::saturatedAddColor(Cine::Palette::Color baseColor, signed r, signed g, signed b) const {
+ Cine::Palette::Color result;
+ result.r = CLIP<int>(baseColor.r + r, 0, _rMax);
+ result.g = CLIP<int>(baseColor.g + g, 0, _gMax);
+ result.b = CLIP<int>(baseColor.b + b, 0, _bMax);
+ return result;
}
Palette &Palette::load(const byte *buf, const uint size, const Graphics::PixelFormat format, const uint numColors, const EndianType endianType) {
diff --git a/engines/cine/pal.h b/engines/cine/pal.h
index e32990a88d..50033be6e0 100644
--- a/engines/cine/pal.h
+++ b/engines/cine/pal.h
@@ -74,6 +74,11 @@ void transformPaletteRange(byte *srcPal, byte *dstPal, int startColor, int stopC
// TODO: Make use of
// TODO: Test
class Palette {
+private:
+ struct Color {
+ uint8 r, g, b;
+ };
+
public:
/*! \brief Load palette from buffer with given color format, endianness and number of colors.
* \param buf Input buffer
@@ -110,7 +115,7 @@ public:
byte *save(byte *buf, const uint size, const Graphics::PixelFormat format, const uint numColors, const EndianType endianType, const byte firstIndex = 0) const;
Palette &rotateRight(byte firstIndex, byte lastIndex);
- Palette &saturatedAddColor(byte firstIndex, byte lastIndex, signed r, signed g, signed b);
+ Palette &saturatedAddColor(Palette& output, byte firstIndex, byte lastIndex, signed r, signed g, signed b);
uint colorCount() const;
/*! \brief The original endian type in which this palette was loaded.
@@ -124,13 +129,9 @@ public:
private:
void setColorFormat(const Graphics::PixelFormat format);
void setEndianType(const EndianType endianType);
- void saturatedAddColor(byte index, signed r, signed g, signed b);
+ Cine::Palette::Color saturatedAddColor(Cine::Palette::Color baseColor, signed r, signed g, signed b) const;
private:
- struct Color {
- uint8 r, g, b;
- };
-
// The used source format, its endianness etc.
Graphics::PixelFormat _format;
uint _rBits, _gBits, _bBits;