[Scummvm-cvs-logs] SF.net SVN: scummvm:[39851] scummvm/trunk/engines/cine
buddha_ at users.sourceforge.net
buddha_ at users.sourceforge.net
Sat Apr 4 19:57:00 CEST 2009
Revision: 39851
http://scummvm.svn.sourceforge.net/scummvm/?rev=39851&view=rev
Author: buddha_
Date: 2009-04-04 17:57:00 +0000 (Sat, 04 Apr 2009)
Log Message:
-----------
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.
Modified Paths:
--------------
scummvm/trunk/engines/cine/pal.cpp
scummvm/trunk/engines/cine/pal.h
Modified: scummvm/trunk/engines/cine/pal.cpp
===================================================================
--- scummvm/trunk/engines/cine/pal.cpp 2009-04-04 17:14:52 UTC (rev 39850)
+++ scummvm/trunk/engines/cine/pal.cpp 2009-04-04 17:57:00 UTC (rev 39851)
@@ -233,7 +233,7 @@
return _format != Graphics::PixelFormat() && _format.aLoss == 8;
}
-Graphics::PixelFormat Palette::colorFormat() const {
+const Graphics::PixelFormat &Palette::colorFormat() const {
return _format;
}
@@ -259,11 +259,11 @@
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);
}
Modified: scummvm/trunk/engines/cine/pal.h
===================================================================
--- scummvm/trunk/engines/cine/pal.h 2009-04-04 17:14:52 UTC (rev 39850)
+++ scummvm/trunk/engines/cine/pal.h 2009-04-04 17:57:00 UTC (rev 39851)
@@ -139,19 +139,18 @@
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 @@
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;
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
More information about the Scummvm-git-logs
mailing list