diff options
author | Tomaž Vajngerl <tomaz.vajngerl@collabora.co.uk> | 2019-02-13 21:26:18 +0100 |
---|---|---|
committer | Tomaž Vajngerl <quikee@gmail.com> | 2019-02-13 22:39:28 +0100 |
commit | b43976324f4f8e003b80ce422eb393010d8a101e (patch) | |
tree | ab71841c1af1cbc3033998855e7da06d3d0408c8 /vcl/qa/cppunit/BitmapProcessorTest.cxx | |
parent | 081b753d4cb4f4a25073ca7de12a7bdaa9fc2be4 (diff) |
Improve the algorithm of disabled image creation
Main change is to not change alpha channel at all. For RGB
channels, calculate the luma value and map the value into 160-224
range. Much simpler and better result.
Change-Id: Ied108c2135f98d78f230a2c0b305bd3396d9ccfd
Reviewed-on: https://gerrit.libreoffice.org/67791
Tested-by: Jenkins
Reviewed-by: Tomaž Vajngerl <quikee@gmail.com>
Diffstat (limited to 'vcl/qa/cppunit/BitmapProcessorTest.cxx')
-rw-r--r-- | vcl/qa/cppunit/BitmapProcessorTest.cxx | 51 |
1 files changed, 41 insertions, 10 deletions
diff --git a/vcl/qa/cppunit/BitmapProcessorTest.cxx b/vcl/qa/cppunit/BitmapProcessorTest.cxx index fe49184c3302..fa0ccc5fc638 100644 --- a/vcl/qa/cppunit/BitmapProcessorTest.cxx +++ b/vcl/qa/cppunit/BitmapProcessorTest.cxx @@ -39,20 +39,51 @@ class BitmapProcessorTest : public CppUnit::TestFixture void BitmapProcessorTest::testDisabledImage() { - Bitmap aBitmap(Size(3, 3), 24); { - BitmapScopedWriteAccess pWriteAccess(aBitmap); - pWriteAccess->Erase(Color(0x00, 0x11, 0x22, 0x33)); + Bitmap aBitmap(Size(3, 3), 24); + { + BitmapScopedWriteAccess pWriteAccess(aBitmap); + pWriteAccess->Erase(Color(0x00, 0x00, 0xFF, 0x00)); + } + BitmapEx aBitmapEx(aBitmap); + BitmapDisabledImageFilter aDisabledImageFilter; + BitmapEx aDisabledBitmapEx(aDisabledImageFilter.execute(aBitmapEx)); + Bitmap aDisabledBitmap(aDisabledBitmapEx.GetBitmap()); + { + Bitmap::ScopedReadAccess pReadAccess(aDisabledBitmap); + Color aColor(pReadAccess->GetPixel(0, 0).GetColor()); + CPPUNIT_ASSERT_EQUAL(Color(0x00C5C5C5), aColor); + } } - BitmapEx aBitmapEx(aBitmap); - BitmapDisabledImageFilter aDisabledImageFilter; - BitmapEx aDisabledBitmapEx(aDisabledImageFilter.execute(aBitmapEx)); - Bitmap aDisabledBitmap(aDisabledBitmapEx.GetBitmap()); { - Bitmap::ScopedReadAccess pReadAccess(aDisabledBitmap); - Color aColor(pReadAccess->GetPixel(0, 0).GetColor()); - CPPUNIT_ASSERT_EQUAL(Color(0x001E1E1E), aColor); + Bitmap aBitmap(Size(3, 3), 24); + { + BitmapScopedWriteAccess pWriteAccess(aBitmap); + pWriteAccess->Erase(Color(0x00, 0x00, 0xFF, 0x00)); + } + AlphaMask aMask(Size(3, 3)); + { + AlphaScopedWriteAccess pWriteAccess(aMask); + pWriteAccess->Erase(Color(0x00, 0xAA, 0xAA, 0xAA)); + } + + BitmapEx aBitmapEx(aBitmap, aMask); + BitmapDisabledImageFilter aDisabledImageFilter; + BitmapEx aDisabledBitmapEx(aDisabledImageFilter.execute(aBitmapEx)); + + Bitmap aDisabledBitmap(aDisabledBitmapEx.GetBitmap()); + { + Bitmap::ScopedReadAccess pReadAccess(aDisabledBitmap); + Color aColor(pReadAccess->GetPixel(0, 0).GetColor()); + CPPUNIT_ASSERT_EQUAL(Color(0x00C5C5C5), aColor); + } + AlphaMask aDisabledAlphaMask(aDisabledBitmapEx.GetAlpha()); + { + AlphaMask::ScopedReadAccess pReadAccess(aDisabledAlphaMask); + Color aColor(pReadAccess->GetPixel(0, 0).GetColor()); + CPPUNIT_ASSERT_EQUAL(Color(0x0000AA), aColor); + } } } |