From 05c01410f3c0fcb791f60b19ce2085beee1dabe0 Mon Sep 17 00:00:00 2001 From: Chris Sherlock Date: Sat, 14 Sep 2024 01:04:55 +1000 Subject: vcl: test BitmapAlphaClampFilter MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Change-Id: Ie44884a3010cd26b057bac593059a4bd0a3aabc8 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/173345 Tested-by: Jenkins Reviewed-by: Tomaž Vajngerl --- vcl/qa/cppunit/BitmapFilterTest.cxx | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) (limited to 'vcl') diff --git a/vcl/qa/cppunit/BitmapFilterTest.cxx b/vcl/qa/cppunit/BitmapFilterTest.cxx index e492b963f48d..099720a1569d 100644 --- a/vcl/qa/cppunit/BitmapFilterTest.cxx +++ b/vcl/qa/cppunit/BitmapFilterTest.cxx @@ -15,6 +15,7 @@ #include #include +#include #include #include #include @@ -41,6 +42,7 @@ public: { } + void testClampAlpha(); void testBlurCorrectness(); void testBasicMorphology(); void testPerformance(); @@ -53,6 +55,7 @@ public: void testArithmeticBlendFilter(); CPPUNIT_TEST_SUITE(BitmapFilterTest); + CPPUNIT_TEST(testClampAlpha); CPPUNIT_TEST(testBlurCorrectness); CPPUNIT_TEST(testBasicMorphology); CPPUNIT_TEST(testPerformance); @@ -91,6 +94,22 @@ private: } }; +void BitmapFilterTest::testClampAlpha() +{ + // Setup test bitmap + Size aSize(1, 1); + Bitmap aBitmap24Bit(aSize, vcl::PixelFormat::N24_BPP); + + { + BitmapScopedWriteAccess aWriteAccess(aBitmap24Bit); + aWriteAccess->Erase(COL_RED); + } + + BitmapEx aBitmapEx24Bit(aBitmap24Bit); + BitmapFilter::Filter(aBitmapEx24Bit, BitmapAlphaClampFilter(0x7F)); + CPPUNIT_ASSERT_EQUAL(static_cast(0xFF), aBitmapEx24Bit.GetAlpha(0, 0)); +} + void BitmapFilterTest::testBlurCorrectness() { // Setup test bitmap -- cgit