diff options
author | Armin Le Grand <alg@apache.org> | 2013-11-05 16:13:12 +0000 |
---|---|---|
committer | Armin Le Grand <alg@apache.org> | 2013-11-05 16:13:12 +0000 |
commit | 1e79e8da3f8042f7d7bd94b2c9f03cff7545b05c (patch) | |
tree | fb36d37e8e2f40c7dc311e2d0bf41209ea477ab7 /basegfx | |
parent | af5fd1e2966d1b45f8565ca694c38ee44706e44c (diff) |
i123500 redefined ColorModifiers and ColorModifierStack, redefined GraphicAttr to be expressed as primitives if needed, enhanced render and export quality if graphic is modified using graphic attributes
Notes
Notes:
merged as: f120005ea41d59caf4b7d7f6017f3549d25b4287
Diffstat (limited to 'basegfx')
-rw-r--r-- | basegfx/inc/basegfx/color/bcolor.hxx | 6 | ||||
-rw-r--r-- | basegfx/inc/basegfx/color/bcolormodifier.hxx | 397 | ||||
-rw-r--r-- | basegfx/source/color/bcolormodifier.cxx | 336 |
3 files changed, 646 insertions, 93 deletions
diff --git a/basegfx/inc/basegfx/color/bcolor.hxx b/basegfx/inc/basegfx/color/bcolor.hxx index 724fe057afab..0319b09745e7 100644 --- a/basegfx/inc/basegfx/color/bcolor.hxx +++ b/basegfx/inc/basegfx/color/bcolor.hxx @@ -193,18 +193,20 @@ namespace basegfx } // clamp color to [0.0..1.0] values in all three intensity components - void clamp() + BColor& clamp() { mfX = basegfx::clamp(mfX, 0.0, 1.0); mfY = basegfx::clamp(mfY, 0.0, 1.0); mfZ = basegfx::clamp(mfZ, 0.0, 1.0); + return *this; } - void invert() + BColor& invert() { mfX = 1.0 - mfX; mfY = 1.0 - mfY; mfZ = 1.0 - mfZ; + return *this; } static const BColor& getEmptyBColor() diff --git a/basegfx/inc/basegfx/color/bcolormodifier.hxx b/basegfx/inc/basegfx/color/bcolormodifier.hxx index afdc38c8b9a7..4009239b00c4 100644 --- a/basegfx/inc/basegfx/color/bcolormodifier.hxx +++ b/basegfx/inc/basegfx/color/bcolormodifier.hxx @@ -19,77 +19,376 @@ * *************************************************************/ - - #ifndef _BGFX_COLOR_BCOLORMODIFIER_HXX #define _BGFX_COLOR_BCOLORMODIFIER_HXX #include <basegfx/color/bcolor.hxx> +#include <boost/utility.hpp> +#include <boost/shared_ptr.hpp> #include <vector> ////////////////////////////////////////////////////////////////////////////// namespace basegfx { - /** Descriptor for type of color modification + /** base class to define color modifications + + The basic idea is to have instances of color modifiers where each + of these can be asked to get a modified version of a color. This + can be as easy as to return a fixed color, but may also do any + other computation based on the given source color and the local + algorythm to apply. + + This base implementation defines the abstract base class. Every + derivation offers another color blending effect, when needed with + parameters for that blending defined as members. + + As long as aw080 is not applied, an operator== is needed to implement + the operator== of the primitive based on this instances. + + For the exact definitions of the color blending applied refer to the + implementation of the method getModifiedColor + + BColorModifier is not copyable (no copy constructor, no assigment + operator); local values cannot be changed after construction. The + instances are cheap and the idea is to create them on demand. To + be able to reuse these as much as possible, a define for a + ::boost::shared_ptr named BColorModifierSharedPtr exists below. + All usages should handle instances of BColorModifier encapsulated + into these shared pointers. */ - enum BColorModifyMode + class BColorModifier : private boost::noncopyable { - BCOLORMODIFYMODE_REPLACE, // replace all color with local color - BCOLORMODIFYMODE_INTERPOLATE, // interpolate color between given and local with local value - BCOLORMODIFYMODE_GRAY, // convert color to gray - BCOLORMODIFYMODE_BLACKANDWHITE, // convert color to B&W, local value is treshhold - BCOLORMODIFYMODE_INVERT, // invert color - BCOLORMODIFYMODE_LUMINANCE_TO_ALPHA // convert color to alpha value (used for Svg Mask) + private: + protected: + // noone is allowed to incarnate the abstract base class + // except derivations + BColorModifier() {} + + public: + // noone should directly destroy it; all incarnations should be + // handled in a boost::shared_ptr of type BColorModifierSharedPtr + virtual ~BColorModifier(); + + // compare operator + virtual bool operator==(const BColorModifier& rCompare) const = 0; + bool operator!=(const BColorModifier& rCompare) const + { + return !(operator==(rCompare)); + } + + // compute modified color + virtual ::basegfx::BColor getModifiedColor(const ::basegfx::BColor& aSourceColor) const = 0; }; +} // end of namespace basegfx + +////////////////////////////////////////////////////////////////////////////// + +namespace basegfx +{ + /** convert color to gray - /** Class to hold a color, value and mode for a color modification. Color modification is - done calling the getModifiedColor() method + returns a color where red green and blue are replaced with the + luminance value calculated based on the source color by using + the following weights: r * 0.30, g * 0.59, b * 0.11 */ - class BColorModifier + class BColorModifier_gray : public BColorModifier { + private: protected: - ::basegfx::BColor maBColor; - double mfValue; - BColorModifyMode meMode; + public: + BColorModifier_gray() + : BColorModifier() + { + } + + virtual ~BColorModifier_gray(); + + // compare operator + virtual bool operator==(const BColorModifier& rCompare) const; + + // compute modified color + virtual ::basegfx::BColor getModifiedColor(const ::basegfx::BColor& aSourceColor) const; + }; +} // end of namespace basegfx + +////////////////////////////////////////////////////////////////////////////// +namespace basegfx +{ + /** invert color + + returns a color where red green and blue are inverted using 1.0 - n + */ + class BColorModifier_invert : public BColorModifier + { + private: + protected: public: - BColorModifier( - const ::basegfx::BColor& rBColor, - double fValue = 0.5, - BColorModifyMode eMode = BCOLORMODIFYMODE_REPLACE) - : maBColor(rBColor), - mfValue(fValue), - meMode(eMode) - {} - - // compare operator(s) - bool operator==(const BColorModifier& rCompare) const + BColorModifier_invert() + : BColorModifier() { - return (maBColor == rCompare.maBColor && mfValue == rCompare.mfValue && meMode == rCompare.meMode); } - bool operator!=(const BColorModifier& rCompare) const + virtual ~BColorModifier_invert(); + + // compare operator + virtual bool operator==(const BColorModifier& rCompare) const; + + // compute modified color + virtual ::basegfx::BColor getModifiedColor(const ::basegfx::BColor& aSourceColor) const; + }; +} // end of namespace basegfx + +////////////////////////////////////////////////////////////////////////////// + +namespace basegfx +{ + /** convert to alpha based on luminance + + returns a color where red green and blue are first weighted and added + to build a luminance value which is then inverted and used for red, + green and blue. The weights are r * 0.2125 + g * 0.7154 + b * 0.0721. + This derivation is used for the svg importer and does exactly what SVG + defines for this needed case. + */ + class BColorModifier_luminance_to_alpha : public BColorModifier + { + private: + protected: + public: + BColorModifier_luminance_to_alpha() + : BColorModifier() + { + } + + virtual ~BColorModifier_luminance_to_alpha(); + + // compare operator + virtual bool operator==(const BColorModifier& rCompare) const; + + // compute modified color + virtual ::basegfx::BColor getModifiedColor(const ::basegfx::BColor& aSourceColor) const; + }; +} // end of namespace basegfx + +////////////////////////////////////////////////////////////////////////////// + +namespace basegfx +{ + /** replace color + + does not use the source color at all, but always returns the + given color, replacing everything. Useful e.g. for unified shadow + creation + */ + class BColorModifier_replace : public BColorModifier + { + private: + ::basegfx::BColor maBColor; + + protected: + public: + BColorModifier_replace(const ::basegfx::BColor& rBColor) + : BColorModifier(), + maBColor(rBColor) { - return !(operator==(rCompare)); } + virtual ~BColorModifier_replace(); + // data access const ::basegfx::BColor& getBColor() const { return maBColor; } + + // compare operator + virtual bool operator==(const BColorModifier& rCompare) const; + + // compute modified color + virtual ::basegfx::BColor getModifiedColor(const ::basegfx::BColor& aSourceColor) const; + }; +} // end of namespace basegfx + +////////////////////////////////////////////////////////////////////////////// + +namespace basegfx +{ + /** interpolate color + + returns an interpolated color mixed by the given value (f) in the range + [0.0 .. 1.0] and the given color (col) as follows: + + col * (1 - f) + aSourceColor * f + */ + class BColorModifier_interpolate : public BColorModifier + { + private: + ::basegfx::BColor maBColor; + double mfValue; + + protected: + public: + BColorModifier_interpolate(const ::basegfx::BColor& rBColor, double fValue) + : BColorModifier(), + maBColor(rBColor), + mfValue(fValue) + { + } + + virtual ~BColorModifier_interpolate(); + + // data access + const ::basegfx::BColor& getBColor() const { return maBColor; } + double getValue() const { return mfValue; } + + // compare operator + virtual bool operator==(const BColorModifier& rCompare) const; + + // compute modified color + virtual ::basegfx::BColor getModifiedColor(const ::basegfx::BColor& aSourceColor) const; + }; +} // end of namespace basegfx + +////////////////////////////////////////////////////////////////////////////// + +namespace basegfx +{ + /** convert color to black and white + + returns black when the luminance of the given color is less than + the given treshhold value in the range [0.0 .. 1.0], else white + */ + class BColorModifier_black_and_white : public BColorModifier + { + private: + double mfValue; + + protected: + public: + BColorModifier_black_and_white(double fValue) + : BColorModifier(), + mfValue(fValue) + { + } + + virtual ~BColorModifier_black_and_white(); + + // data access + double getValue() const { return mfValue; } + + // compare operator + virtual bool operator==(const BColorModifier& rCompare) const; + + // compute modified color + virtual ::basegfx::BColor getModifiedColor(const ::basegfx::BColor& aSourceColor) const; + }; +} // end of namespace basegfx + +////////////////////////////////////////////////////////////////////////////// + +namespace basegfx +{ + /** gamma correction + + Input is a gamma correction value in the range ]0.0 .. 10.0]; the + color values get correted using + + col(r,g,b) = clamp(pow(col(r,g,b), 1.0 / gamma), 0.0, 1.0) + */ + class BColorModifier_gamma : public BColorModifier + { + private: + double mfValue; + double mfInvValue; + + /// bitfield + bool mbUseIt : 1; + + protected: + public: + BColorModifier_gamma(double fValue); + + virtual ~BColorModifier_gamma(); + + // data access double getValue() const { return mfValue; } - BColorModifyMode getMode() const { return meMode; } + + // compare operator + virtual bool operator==(const BColorModifier& rCompare) const; + + // compute modified color + virtual ::basegfx::BColor getModifiedColor(const ::basegfx::BColor& aSourceColor) const; + }; +} // end of namespace basegfx + +////////////////////////////////////////////////////////////////////////////// + +namespace basegfx +{ + /** Red, Green, Blue, Luminance and Contrast correction + + Input are percent values from [-1.0 .. 1-0] which correspond to -100% to 100% + correction of Red, Green, Blue, Luminance or Contrast. 0.0 means no change of + the corresponding channel. All these are combined (but can be used single) to + - be able to cover a bigger change range utilizing the cmobination + - allow execution by a small, common, precalculated table + */ + class BColorModifier_RGBLuminanceContrast : public BColorModifier + { + private: + double mfRed; + double mfGreen; + double mfBlue; + double mfLuminance; + double mfContrast; + + double mfContrastOff; + double mfRedOff; + double mfGreenOff; + double mfBlueOff; + + /// bitfield + bool mbUseIt : 1; + + protected: + public: + BColorModifier_RGBLuminanceContrast(double fRed, double fGreen, double fBlue, double fLuminance, double fContrast); + + virtual ~BColorModifier_RGBLuminanceContrast(); + + // data access + double getRed() const { return mfRed; } + double getGreen() const { return mfGreen; } + double getBlue() const { return mfBlue; } + double getLuminance() const { return mfLuminance; } + double getContrast() const { return mfContrast; } + + // compare operator + virtual bool operator==(const BColorModifier& rCompare) const; // compute modified color - ::basegfx::BColor getModifiedColor(const ::basegfx::BColor& aSourceColor) const; + virtual ::basegfx::BColor getModifiedColor(const ::basegfx::BColor& aSourceColor) const; }; +} // end of namespace basegfx + +////////////////////////////////////////////////////////////////////////////// + +namespace basegfx +{ + /// typedef to allow working with shared instances of BColorModifier + /// for the whole mechanism + typedef ::boost::shared_ptr< BColorModifier > BColorModifierSharedPtr; - /** Class to hold a stack of BColorModifiers and to get the modified color with - applying all existing entry changes + /** Class to hold a stack of BColorModifierSharedPtrs and to get the modified color with + applying all existing entry changes as defined in the stack. Instances of BColorModifier + can be pushed and popped to change the stack. + + All references to BColorModifier members use shared pointers, thus instances of + BColorModifierStack can be copied by the default mechanisms if needed. */ class BColorModifierStack { protected: - ::std::vector< BColorModifier > maBColorModifiers; + ::std::vector< BColorModifierSharedPtr > maBColorModifiers; public: sal_uInt32 count() const @@ -97,33 +396,17 @@ namespace basegfx return maBColorModifiers.size(); } - const BColorModifier& getBColorModifier(sal_uInt32 nIndex) const + const BColorModifierSharedPtr& getBColorModifier(sal_uInt32 nIndex) const { OSL_ENSURE(nIndex < count(), "BColorModifierStack: Access out of range (!)"); return maBColorModifiers[nIndex]; } - ::basegfx::BColor getModifiedColor(const ::basegfx::BColor& rSource) const - { - if(count()) - { - ::basegfx::BColor aRetval(rSource); - ::std::vector< BColorModifier >::const_iterator aEnd(maBColorModifiers.end()); - - while(aEnd != maBColorModifiers.begin()) - { - aRetval = (--aEnd)->getModifiedColor(aRetval); - } - - return aRetval; - } - else - { - return rSource; - } - } + // get the color in it's modified form by applying all existing BColorModifiers, + // from back to front (the newest first) + ::basegfx::BColor getModifiedColor(const ::basegfx::BColor& rSource) const; - void push(const BColorModifier& rNew) + void push(const BColorModifierSharedPtr& rNew) { maBColorModifiers.push_back(rNew); } @@ -135,6 +418,8 @@ namespace basegfx }; } // end of namespace basegfx +////////////////////////////////////////////////////////////////////////////// + #endif // _BGFX_COLOR_BCOLORMODIFIER_HXX ////////////////////////////////////////////////////////////////////////////// diff --git a/basegfx/source/color/bcolormodifier.cxx b/basegfx/source/color/bcolormodifier.cxx index 517fe417cae6..67ad15452579 100644 --- a/basegfx/source/color/bcolormodifier.cxx +++ b/basegfx/source/color/bcolormodifier.cxx @@ -19,8 +19,6 @@ * *************************************************************/ - - // MARKER(update_precomp.py): autogen include statement, do not remove #include "precompiled_basegfx.hxx" @@ -30,46 +28,314 @@ namespace basegfx { - ::basegfx::BColor BColorModifier::getModifiedColor(const ::basegfx::BColor& aSourceColor) const + BColorModifier::~BColorModifier() + { + } +} // end of namespace basegfx + +////////////////////////////////////////////////////////////////////////////// + +namespace basegfx +{ + BColorModifier_gray::~BColorModifier_gray() + { + } + + bool BColorModifier_gray::operator==(const BColorModifier& rCompare) const + { + return 0 != dynamic_cast< const BColorModifier_gray* >(&rCompare); + } + + ::basegfx::BColor BColorModifier_gray::getModifiedColor(const ::basegfx::BColor& aSourceColor) const + { + const double fLuminance(aSourceColor.luminance()); + + return ::basegfx::BColor(fLuminance, fLuminance, fLuminance); + } +} // end of namespace basegfx + +////////////////////////////////////////////////////////////////////////////// + +namespace basegfx +{ + BColorModifier_invert::~BColorModifier_invert() + { + } + + bool BColorModifier_invert::operator==(const BColorModifier& rCompare) const + { + return 0 != dynamic_cast< const BColorModifier_invert* >(&rCompare); + } + + ::basegfx::BColor BColorModifier_invert::getModifiedColor(const ::basegfx::BColor& aSourceColor) const + { + return ::basegfx::BColor(1.0 - aSourceColor.getRed(), 1.0 - aSourceColor.getGreen(), 1.0 - aSourceColor.getBlue()); + } +} // end of namespace basegfx + +////////////////////////////////////////////////////////////////////////////// + +namespace basegfx +{ + BColorModifier_luminance_to_alpha::~BColorModifier_luminance_to_alpha() + { + } + + bool BColorModifier_luminance_to_alpha::operator==(const BColorModifier& rCompare) const + { + return 0 != dynamic_cast< const BColorModifier_luminance_to_alpha* >(&rCompare); + } + + ::basegfx::BColor BColorModifier_luminance_to_alpha::getModifiedColor(const ::basegfx::BColor& aSourceColor) const + { + const double fAlpha(1.0 - ((aSourceColor.getRed() * 0.2125) + (aSourceColor.getGreen() * 0.7154) + (aSourceColor.getBlue() * 0.0721))); + + return ::basegfx::BColor(fAlpha, fAlpha, fAlpha); + } +} // end of namespace basegfx + +////////////////////////////////////////////////////////////////////////////// + +namespace basegfx +{ + BColorModifier_replace::~BColorModifier_replace() + { + } + + bool BColorModifier_replace::operator==(const BColorModifier& rCompare) const { - switch(meMode) + const BColorModifier_replace* pCompare = dynamic_cast< const BColorModifier_replace* >(&rCompare); + + if(!pCompare) { - case BCOLORMODIFYMODE_INTERPOLATE : - { - return interpolate(maBColor, aSourceColor, mfValue); - } - case BCOLORMODIFYMODE_GRAY : - { - const double fLuminance(aSourceColor.luminance()); - return ::basegfx::BColor(fLuminance, fLuminance, fLuminance); - } - case BCOLORMODIFYMODE_BLACKANDWHITE : - { - const double fLuminance(aSourceColor.luminance()); - - if(fLuminance < mfValue) - { - return ::basegfx::BColor::getEmptyBColor(); - } - else - { - return ::basegfx::BColor(1.0, 1.0, 1.0); - } - } - case BCOLORMODIFYMODE_INVERT : - { - return ::basegfx::BColor(1.0 - aSourceColor.getRed(), 1.0 - aSourceColor.getGreen(), 1.0 - aSourceColor.getBlue()); - } - case BCOLORMODIFYMODE_LUMINANCE_TO_ALPHA: + return false; + } + + return getBColor() == pCompare->getBColor(); + } + + ::basegfx::BColor BColorModifier_replace::getModifiedColor(const ::basegfx::BColor& /*aSourceColor*/) const + { + return maBColor; + } +} // end of namespace basegfx + +////////////////////////////////////////////////////////////////////////////// + +namespace basegfx +{ + BColorModifier_interpolate::~BColorModifier_interpolate() + { + } + + bool BColorModifier_interpolate::operator==(const BColorModifier& rCompare) const + { + const BColorModifier_interpolate* pCompare = dynamic_cast< const BColorModifier_interpolate* >(&rCompare); + + if(!pCompare) + { + return false; + } + + return getBColor() == pCompare->getBColor() && getValue() == pCompare->getValue(); + } + + ::basegfx::BColor BColorModifier_interpolate::getModifiedColor(const ::basegfx::BColor& aSourceColor) const + { + return interpolate(maBColor, aSourceColor, mfValue); + } +} // end of namespace basegfx + +////////////////////////////////////////////////////////////////////////////// + +namespace basegfx +{ + BColorModifier_black_and_white::~BColorModifier_black_and_white() + { + } + + bool BColorModifier_black_and_white::operator==(const BColorModifier& rCompare) const + { + const BColorModifier_black_and_white* pCompare = dynamic_cast< const BColorModifier_black_and_white* >(&rCompare); + + if(!pCompare) + { + return false; + } + + return getValue() == pCompare->getValue(); + } + + ::basegfx::BColor BColorModifier_black_and_white::getModifiedColor(const ::basegfx::BColor& aSourceColor) const + { + const double fLuminance(aSourceColor.luminance()); + + if(fLuminance < mfValue) + { + return ::basegfx::BColor::getEmptyBColor(); + } + else + { + return ::basegfx::BColor(1.0, 1.0, 1.0); + } + } +} // end of namespace basegfx + +////////////////////////////////////////////////////////////////////////////// + +namespace basegfx +{ + BColorModifier_gamma::BColorModifier_gamma(double fValue) + : BColorModifier(), + mfValue(fValue), + mfInvValue(fValue), + mbUseIt(!basegfx::fTools::equal(fValue, 1.0) && basegfx::fTools::more(fValue, 0.0) && basegfx::fTools::lessOrEqual(fValue, 10.0)) + { + if(mbUseIt) + { + mfInvValue = 1.0 / mfValue; + } + } + + BColorModifier_gamma::~BColorModifier_gamma() + { + } + + bool BColorModifier_gamma::operator==(const BColorModifier& rCompare) const + { + const BColorModifier_gamma* pCompare = dynamic_cast< const BColorModifier_gamma* >(&rCompare); + + if(!pCompare) + { + return false; + } + + // getValue is sufficient, mfInvValue and mbUseIt are only helper values + return getValue() == pCompare->getValue(); + } + + ::basegfx::BColor BColorModifier_gamma::getModifiedColor(const ::basegfx::BColor& aSourceColor) const + { + if(mbUseIt) + { + ::basegfx::BColor aRetval( + pow(aSourceColor.getRed(), mfInvValue), + pow(aSourceColor.getGreen(), mfInvValue), + pow(aSourceColor.getBlue(), mfInvValue)); + + aRetval.clamp(); + return aRetval; + } + else + { + return aSourceColor; + } + } +} // end of namespace basegfx + +////////////////////////////////////////////////////////////////////////////// + +namespace basegfx +{ + BColorModifier_RGBLuminanceContrast::BColorModifier_RGBLuminanceContrast(double fRed, double fGreen, double fBlue, double fLuminance, double fContrast) + : BColorModifier(), + mfRed(basegfx::clamp(fRed, -1.0, 1.0)), + mfGreen(basegfx::clamp(fGreen, -1.0, 1.0)), + mfBlue(basegfx::clamp(fBlue, -1.0, 1.0)), + mfLuminance(basegfx::clamp(fLuminance, -1.0, 1.0)), + mfContrast(basegfx::clamp(fContrast, -1.0, 1.0)), + mfContrastOff(1.0), + mfRedOff(0.0), + mfGreenOff(0.0), + mfBlueOff(0.0), + mbUseIt(false) + { + if(!basegfx::fTools::equalZero(mfRed) + || !basegfx::fTools::equalZero(mfGreen) + || !basegfx::fTools::equalZero(mfBlue) + || !basegfx::fTools::equalZero(mfLuminance) + || !basegfx::fTools::equalZero(mfContrast)) + { + // calculate slope + if(mfContrast >= 0.0) { - const double fAlpha(1.0 - ((aSourceColor.getRed() * 0.2125) + (aSourceColor.getGreen() * 0.7154) + (aSourceColor.getBlue() * 0.0721))); - return ::basegfx::BColor(fAlpha, fAlpha, fAlpha); + mfContrastOff = 128.0 / (128.0 - (mfContrast * 127.0)); } - default : // BCOLORMODIFYMODE_REPLACE + else { - return maBColor; + mfContrastOff = ( 128.0 + (mfContrast * 127.0)) / 128.0; } + + // calculate unified contrast offset + const double fPreparedContrastOff((128.0 - mfContrastOff * 128.0) / 255.0); + const double fCombinedOffset(mfLuminance + fPreparedContrastOff); + + // set full offsets + mfRedOff = mfRed + fCombinedOffset; + mfGreenOff = mfGreen + fCombinedOffset; + mfBlueOff = mfBlue + fCombinedOffset; + + mbUseIt = true; + } + } + + BColorModifier_RGBLuminanceContrast::~BColorModifier_RGBLuminanceContrast() + { + } + + bool BColorModifier_RGBLuminanceContrast::operator==(const BColorModifier& rCompare) const + { + const BColorModifier_RGBLuminanceContrast* pCompare = dynamic_cast< const BColorModifier_RGBLuminanceContrast* >(&rCompare); + + if(!pCompare) + { + return false; } + + // no need to compare other values, these are just helpers + return getRed() == pCompare->getRed() + && getGreen() == pCompare->getGreen() + && getBlue() == pCompare->getBlue() + && getLuminance() == pCompare->getLuminance() + && getContrast() == pCompare->getContrast(); + } + + ::basegfx::BColor BColorModifier_RGBLuminanceContrast::getModifiedColor(const ::basegfx::BColor& aSourceColor) const + { + if(mbUseIt) + { + return basegfx::BColor( + basegfx::clamp(aSourceColor.getRed() * mfContrastOff + mfRedOff, 0.0, 1.0), + basegfx::clamp(aSourceColor.getGreen() * mfContrastOff + mfGreenOff, 0.0, 1.0), + basegfx::clamp(aSourceColor.getBlue() * mfContrastOff + mfBlueOff, 0.0, 1.0)); + } + else + { + return aSourceColor; + } + } +} // end of namespace basegfx + +////////////////////////////////////////////////////////////////////////////// + +namespace basegfx +{ + ::basegfx::BColor BColorModifierStack::getModifiedColor(const ::basegfx::BColor& rSource) const + { + if(maBColorModifiers.empty()) + { + return rSource; + } + + ::basegfx::BColor aRetval(rSource); + + for(sal_uInt32 a(maBColorModifiers.size()); a;) + { + a--; + aRetval = maBColorModifiers[a]->getModifiedColor(aRetval); + } + + return aRetval; } } // end of namespace basegfx |