diff options
author | Jan-Marek Glogowski <glogow@fbihome.de> | 2019-05-13 14:00:10 +0000 |
---|---|---|
committer | Tomaž Vajngerl <quikee@gmail.com> | 2019-05-14 03:20:50 +0200 |
commit | d14d1341f2b0cd62098425b36438ae20b887fe93 (patch) | |
tree | e1bb6f188239144e7792e678c903334e099e3b9c /tools | |
parent | 0a3f9a7e113c184355d49dbd6bd2ed75b0980b1e (diff) |
Switch everyone to stricter GetColorError
This replaces the variant in Color with the stricter one of
BitmapColor. I couldn't find any reasoning for the lazy variant
used in Color.
Change-Id: I6dab3ab94a7f24ef5e80299d64267e3be8df888c
Reviewed-on: https://gerrit.libreoffice.org/72234
Tested-by: Jenkins
Reviewed-by: Tomaž Vajngerl <quikee@gmail.com>
Diffstat (limited to 'tools')
-rw-r--r-- | tools/qa/cppunit/test_color.cxx | 20 | ||||
-rw-r--r-- | tools/source/generic/color.cxx | 9 |
2 files changed, 10 insertions, 19 deletions
diff --git a/tools/qa/cppunit/test_color.cxx b/tools/qa/cppunit/test_color.cxx index 9c2a4d9c7049..5bec65027b94 100644 --- a/tools/qa/cppunit/test_color.cxx +++ b/tools/qa/cppunit/test_color.cxx @@ -163,19 +163,19 @@ void Test::test_ApplyTintOrShade() void Test::testGetColorError() { - CPPUNIT_ASSERT_EQUAL(sal_uInt8(0), Color(0xAA, 0xBB, 0xCC).GetColorError(Color(0xAA, 0xBB, 0xCC))); + CPPUNIT_ASSERT_EQUAL(sal_uInt16(0), Color(0xAA, 0xBB, 0xCC).GetColorError(Color(0xAA, 0xBB, 0xCC))); - CPPUNIT_ASSERT_EQUAL(sal_uInt8(0), Color(0xA0, 0xB0, 0xC0).GetColorError(Color(0xA1, 0xB0, 0xC0))); - CPPUNIT_ASSERT_EQUAL(sal_uInt8(0), Color(0xA0, 0xB0, 0xC0).GetColorError(Color(0xA0, 0xB1, 0xC0))); - CPPUNIT_ASSERT_EQUAL(sal_uInt8(0), Color(0xA0, 0xB0, 0xC0).GetColorError(Color(0xA0, 0xB0, 0xC1))); + CPPUNIT_ASSERT_EQUAL(sal_uInt16(1), Color(0xA0, 0xB0, 0xC0).GetColorError(Color(0xA1, 0xB0, 0xC0))); + CPPUNIT_ASSERT_EQUAL(sal_uInt16(1), Color(0xA0, 0xB0, 0xC0).GetColorError(Color(0xA0, 0xB1, 0xC0))); + CPPUNIT_ASSERT_EQUAL(sal_uInt16(1), Color(0xA0, 0xB0, 0xC0).GetColorError(Color(0xA0, 0xB0, 0xC1))); - CPPUNIT_ASSERT_EQUAL(sal_uInt8(1), Color(0xA0, 0xB0, 0xC0).GetColorError(Color(0xA1, 0xB1, 0xC0))); - CPPUNIT_ASSERT_EQUAL(sal_uInt8(1), Color(0xA0, 0xB0, 0xC0).GetColorError(Color(0xA0, 0xB1, 0xC1))); - CPPUNIT_ASSERT_EQUAL(sal_uInt8(1), Color(0xA0, 0xB0, 0xC0).GetColorError(Color(0xA1, 0xB0, 0xC1))); + CPPUNIT_ASSERT_EQUAL(sal_uInt16(2), Color(0xA0, 0xB0, 0xC0).GetColorError(Color(0xA1, 0xB1, 0xC0))); + CPPUNIT_ASSERT_EQUAL(sal_uInt16(2), Color(0xA0, 0xB0, 0xC0).GetColorError(Color(0xA0, 0xB1, 0xC1))); + CPPUNIT_ASSERT_EQUAL(sal_uInt16(2), Color(0xA0, 0xB0, 0xC0).GetColorError(Color(0xA1, 0xB0, 0xC1))); - CPPUNIT_ASSERT_EQUAL(sal_uInt8(1), Color(0xA0, 0xB0, 0xC0).GetColorError(Color(0xA1, 0xB1, 0xC1))); - CPPUNIT_ASSERT_EQUAL(sal_uInt8(1), Color(0xA0, 0xB0, 0xC0).GetColorError(Color(0xA1, 0xB1, 0xC1))); - CPPUNIT_ASSERT_EQUAL(sal_uInt8(1), Color(0xA0, 0xB0, 0xC0).GetColorError(Color(0xA1, 0xB1, 0xC1))); + CPPUNIT_ASSERT_EQUAL(sal_uInt16(3), Color(0xA0, 0xB0, 0xC0).GetColorError(Color(0xA1, 0xB1, 0xC1))); + CPPUNIT_ASSERT_EQUAL(sal_uInt16(3), Color(0xA0, 0xB0, 0xC0).GetColorError(Color(0xA1, 0xB1, 0xC1))); + CPPUNIT_ASSERT_EQUAL(sal_uInt16(3), Color(0xA0, 0xB0, 0xC0).GetColorError(Color(0xA1, 0xB1, 0xC1))); } void Test::testInvert() diff --git a/tools/source/generic/color.cxx b/tools/source/generic/color.cxx index 4640ef85f290..061435ed61c9 100644 --- a/tools/source/generic/color.cxx +++ b/tools/source/generic/color.cxx @@ -28,15 +28,6 @@ #include <tools/helpers.hxx> #include <basegfx/color/bcolortools.hxx> -sal_uInt8 Color::GetColorError( const Color& rCompareColor ) const -{ - const long nErrAbs = labs(long(rCompareColor.R) - R) + - labs(long(rCompareColor.G) - G) + - labs(long(rCompareColor.B) - B); - - return sal_uInt8(FRound(double(nErrAbs) / 3.0)); -} - void Color::IncreaseLuminance(sal_uInt8 cLumInc) { R = sal_uInt8(std::clamp(long(R) + cLumInc, 0L, 255L)); |