aboutsummaryrefslogtreecommitdiff
path: root/engines
diff options
context:
space:
mode:
authorKari Salminen2009-04-04 17:57:00 +0000
committerKari Salminen2009-04-04 17:57:00 +0000
commitaf0efd8938f896305e18a10f4cdd260f426f2b24 (patch)
tree5746fbfe1f1d33b2e2978611526321ea56977237 /engines
parent3efc9ad51eb39b0c8ac8680fc79be1b34767d2dd (diff)
downloadscummvm-rg350-af0efd8938f896305e18a10f4cdd260f426f2b24.tar.gz
scummvm-rg350-af0efd8938f896305e18a10f4cdd260f426f2b24.tar.bz2
scummvm-rg350-af0efd8938f896305e18a10f4cdd260f426f2b24.zip
Add saturatedAddColor-function in which you can specify the added color's format (This replaces saturatedAddNormalizedColor).
Make colorFormat()-accessor function to return a const reference for speed. svn-id: r39851
Diffstat (limited to 'engines')
-rw-r--r--engines/cine/pal.cpp12
-rw-r--r--engines/cine/pal.h19
2 files changed, 15 insertions, 16 deletions
diff --git a/engines/cine/pal.cpp b/engines/cine/pal.cpp
index ce26ae89b2..2a4f931494 100644
--- a/engines/cine/pal.cpp
+++ b/engines/cine/pal.cpp
@@ -233,7 +233,7 @@ bool Palette::isValid() const {
return _format != Graphics::PixelFormat() && _format.aLoss == 8;
}
-Graphics::PixelFormat Palette::colorFormat() const {
+const Graphics::PixelFormat &Palette::colorFormat() const {
return _format;
}
@@ -259,11 +259,11 @@ Palette &Palette::saturatedAddColor(Palette& output, byte firstIndex, byte lastI
return output;
}
-Palette &Palette::saturatedAddNormalizedColor(Palette& output, byte firstIndex, byte lastIndex, signed rNormalized, signed gNormalized, signed bNormalized, signed dividend, signed denominator) {
- assert(denominator != 0);
- const signed r = _format.rMax() * rNormalized * dividend / denominator;
- const signed g = _format.gMax() * gNormalized * dividend / denominator;
- const signed b = _format.bMax() * bNormalized * dividend / denominator;
+Palette &Palette::saturatedAddColor(Palette& output, byte firstIndex, byte lastIndex, signed rSource, signed gSource, signed bSource, const Graphics::PixelFormat &sourceFormat) {
+ // Convert the source color to the internal color format ensuring that no divide by zero will happen
+ const signed r = _format.rMax() * rSource / MAX<int>(sourceFormat.rMax(), 1);
+ const signed g = _format.gMax() * gSource / MAX<int>(sourceFormat.gMax(), 1);
+ const signed b = _format.bMax() * bSource / MAX<int>(sourceFormat.bMax(), 1);
return saturatedAddColor(output, firstIndex, lastIndex, r, g, b);
}
diff --git a/engines/cine/pal.h b/engines/cine/pal.h
index 030621a2f4..ccb87b8c61 100644
--- a/engines/cine/pal.h
+++ b/engines/cine/pal.h
@@ -139,19 +139,18 @@ public:
Palette &rotateRight(byte firstIndex, byte lastIndex);
Palette &saturatedAddColor(Palette& output, byte firstIndex, byte lastIndex, signed r, signed g, signed b);
- /*! \brief Saturated add a normalized RGB color to current palette's subset and save the modified colors in the given output palette.
+ /*! \brief Saturated add an RGB color in given color format 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 rNormalized The normalized red color component
- * \param gNormalized The normalized green color component
- * \param bNormalized The normalized blue color component
- * \param dividend Dividend of the normalized color component values
- * \param denominator Denominator of the normalized color component values
- * \note The normalized color component multiplier value (i.e. in range [-1, +1]) is given as a fractional number
- * so each input color component is multiplied by it and the color component's maximum (Specified by this palette's color format)
+ * \param rSource The red color component in the source color format
+ * \param gSource The green color component in the source color format
+ * \param bSource The blue color component in the source color format
+ * \param sourceFormat The source color format (i.e. the color format of the given RGB color)
+ * \note This function basically converts the given color to the palette's internal color format
+ * and adds that using the normal saturatedAddColor-function.
*/
- Palette &saturatedAddNormalizedColor(Palette& output, byte firstIndex, byte lastIndex, signed rNormalized, signed gNormalized, signed bNormalized, signed dividend, signed denominator);
+ Palette &saturatedAddColor(Palette& output, byte firstIndex, byte lastIndex, signed rSource, signed gSource, signed bSource, const Graphics::PixelFormat &sourceFormat);
/*! \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)
@@ -173,7 +172,7 @@ public:
bool isValid() const;
/*! \brief The original color format in which this palette was loaded. */
- Graphics::PixelFormat colorFormat() const;
+ const Graphics::PixelFormat &colorFormat() const;
/*! \brief Sets current palette to global OSystem's palette using g_system->setPalette. */
void setGlobalOSystemPalette() const;