related: tdf#155735: clamp RGB values
So when a green matrix is used, everything becomes green. Also set alpha to 1.0 so at least a green matrix on black returns green and not black Change-Id: I9104c7511545fb244750b066bb1e996b6ce229f2 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/154167 Tested-by: Jenkins Reviewed-by: Xisco Fauli <xiscofauli@libreoffice.org>
This commit is contained in:
@@ -164,10 +164,14 @@ namespace basegfx
|
||||
aColorMatrix.set(0, 0, aSourceColor.getRed());
|
||||
aColorMatrix.set(1, 0, aSourceColor.getGreen());
|
||||
aColorMatrix.set(2, 0, aSourceColor.getBlue());
|
||||
aColorMatrix.set(3, 0, 1.0);
|
||||
// TODO: add support for alpha
|
||||
|
||||
aColorMatrix = maMatrix * aColorMatrix;
|
||||
return ::basegfx::BColor(aColorMatrix.get(0, 0), aColorMatrix.get(1, 0), aColorMatrix.get(2, 0));
|
||||
return ::basegfx::BColor(
|
||||
std::clamp(aColorMatrix.get(0, 0), 0.0, 1.0),
|
||||
std::clamp(aColorMatrix.get(1, 0), 0.0, 1.0),
|
||||
std::clamp(aColorMatrix.get(2, 0), 0.0, 1.0));
|
||||
}
|
||||
|
||||
OUString BColorModifier_matrix::getModifierName() const
|
||||
|
||||
@@ -293,21 +293,16 @@ public:
|
||||
const basegfx::BColorModifierSharedPtr aBColorModifier
|
||||
= std::make_shared<basegfx::BColorModifier_matrix>(aMatrix);
|
||||
|
||||
BColor aExpectedWhite(0.0, 3.0, 0.0);
|
||||
CPPUNIT_ASSERT_EQUAL(aExpectedWhite, aBColorModifier->getModifiedColor(maWhite));
|
||||
BColor aExpectedGray(0.0, 1.5, 0.0);
|
||||
CPPUNIT_ASSERT_EQUAL(aExpectedGray, aBColorModifier->getModifiedColor(maGray));
|
||||
CPPUNIT_ASSERT_EQUAL(maBlack, aBColorModifier->getModifiedColor(maBlack));
|
||||
CPPUNIT_ASSERT_EQUAL(maGreen, aBColorModifier->getModifiedColor(maWhite));
|
||||
CPPUNIT_ASSERT_EQUAL(maGreen, aBColorModifier->getModifiedColor(maGray));
|
||||
CPPUNIT_ASSERT_EQUAL(maGreen, aBColorModifier->getModifiedColor(maBlack));
|
||||
|
||||
CPPUNIT_ASSERT_EQUAL(maGreen, aBColorModifier->getModifiedColor(maRed));
|
||||
CPPUNIT_ASSERT_EQUAL(maGreen, aBColorModifier->getModifiedColor(maGreen));
|
||||
CPPUNIT_ASSERT_EQUAL(maGreen, aBColorModifier->getModifiedColor(maBlue));
|
||||
BColor aExpectedYellow(0.0, 2.0, 0.0);
|
||||
CPPUNIT_ASSERT_EQUAL(aExpectedYellow, aBColorModifier->getModifiedColor(maYellow));
|
||||
BColor aExpectedMagenta = aExpectedYellow;
|
||||
CPPUNIT_ASSERT_EQUAL(aExpectedMagenta, aBColorModifier->getModifiedColor(maMagenta));
|
||||
BColor aExpectedCyan = aExpectedYellow;
|
||||
CPPUNIT_ASSERT_EQUAL(aExpectedCyan, aBColorModifier->getModifiedColor(maCyan));
|
||||
CPPUNIT_ASSERT_EQUAL(maGreen, aBColorModifier->getModifiedColor(maYellow));
|
||||
CPPUNIT_ASSERT_EQUAL(maGreen, aBColorModifier->getModifiedColor(maMagenta));
|
||||
CPPUNIT_ASSERT_EQUAL(maGreen, aBColorModifier->getModifiedColor(maCyan));
|
||||
|
||||
CPPUNIT_ASSERT(aBColorModifier->operator==(*aBColorModifier));
|
||||
const basegfx::BColorModifierSharedPtr aBColorModifierInvert
|
||||
|
||||
Reference in New Issue
Block a user