summaryrefslogtreecommitdiff
path: root/vcl/qa
diff options
context:
space:
mode:
authorXisco Fauli <xiscofauli@libreoffice.org>2024-04-22 16:38:35 +0200
committerXisco Fauli <xiscofauli@libreoffice.org>2024-04-22 18:43:08 +0200
commit851f60697d32849454528e5f14ed80446b330e0c (patch)
treefbd47f29a305ea632b2e281676c78a74d956a524 /vcl/qa
parentfcc5770dd1e33dcb4f4f0c28683569af5d1d8368 (diff)
tdf#159660: also add normal blend filter
Change-Id: I3edc7495975618357f002536857a11dcc72cc0b9 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/166460 Tested-by: Jenkins Reviewed-by: Xisco Fauli <xiscofauli@libreoffice.org>
Diffstat (limited to 'vcl/qa')
-rw-r--r--vcl/qa/cppunit/BitmapFilterTest.cxx57
1 files changed, 57 insertions, 0 deletions
diff --git a/vcl/qa/cppunit/BitmapFilterTest.cxx b/vcl/qa/cppunit/BitmapFilterTest.cxx
index ca04956312a4..d59cd331d467 100644
--- a/vcl/qa/cppunit/BitmapFilterTest.cxx
+++ b/vcl/qa/cppunit/BitmapFilterTest.cxx
@@ -19,6 +19,7 @@
#include <vcl/BitmapDarkenBlendFilter.hxx>
#include <vcl/BitmapLightenBlendFilter.hxx>
#include <vcl/BitmapMultiplyBlendFilter.hxx>
+#include <vcl/BitmapNormalBlendFilter.hxx>
#include <vcl/BitmapScreenBlendFilter.hxx>
#include <vcl/BitmapBasicMorphologyFilter.hxx>
#include <vcl/BitmapFilterStackBlur.hxx>
@@ -45,6 +46,7 @@ public:
void testPerformance();
void testGenerateStripRanges();
void testMultiplyBlendFilter();
+ void testNormalBlendFilter();
void testDarkenBlendFilter();
void testLightenBlendFilter();
void testScreenBlendFilter();
@@ -56,6 +58,7 @@ public:
CPPUNIT_TEST(testPerformance);
CPPUNIT_TEST(testGenerateStripRanges);
CPPUNIT_TEST(testMultiplyBlendFilter);
+ CPPUNIT_TEST(testNormalBlendFilter);
CPPUNIT_TEST(testDarkenBlendFilter);
CPPUNIT_TEST(testLightenBlendFilter);
CPPUNIT_TEST(testScreenBlendFilter);
@@ -345,6 +348,60 @@ void BitmapFilterTest::testMultiplyBlendFilter()
}
}
+void BitmapFilterTest::testNormalBlendFilter()
+{
+ Bitmap aRedBitmap(Size(4, 4), vcl::PixelFormat::N24_BPP);
+ CPPUNIT_ASSERT_EQUAL(vcl::PixelFormat::N24_BPP, aRedBitmap.getPixelFormat());
+ {
+ BitmapScopedWriteAccess aWriteAccess(aRedBitmap);
+ aWriteAccess->Erase(COL_LIGHTRED);
+ }
+
+ Bitmap aGreenBitmap(Size(4, 4), vcl::PixelFormat::N24_BPP);
+ CPPUNIT_ASSERT_EQUAL(vcl::PixelFormat::N24_BPP, aGreenBitmap.getPixelFormat());
+ {
+ BitmapScopedWriteAccess aWriteAccess(aGreenBitmap);
+ aWriteAccess->Erase(COL_GREEN);
+ }
+
+ Bitmap aTransparentBitmap(Size(4, 4), vcl::PixelFormat::N24_BPP);
+ CPPUNIT_ASSERT_EQUAL(vcl::PixelFormat::N24_BPP, aTransparentBitmap.getPixelFormat());
+ {
+ BitmapScopedWriteAccess aWriteAccess(aTransparentBitmap);
+ aWriteAccess->Erase(COL_AUTO);
+ }
+
+ BitmapEx aRedBitmapEx(aRedBitmap);
+ BitmapEx aGreenBitmapEx(aGreenBitmap);
+ BitmapEx aTransparentBitmapEx(aTransparentBitmap);
+
+ // same color
+ {
+ BitmapNormalBlendFilter* pArithmeticFilter
+ = new BitmapNormalBlendFilter(aRedBitmapEx, aRedBitmapEx);
+ BitmapEx aResBitmapEx = pArithmeticFilter->execute();
+ CPPUNIT_ASSERT_EQUAL(COL_LIGHTRED, aResBitmapEx.GetPixelColor(2, 2));
+ }
+
+ // different color
+ {
+ BitmapNormalBlendFilter* pArithmeticFilter
+ = new BitmapNormalBlendFilter(aRedBitmapEx, aGreenBitmapEx);
+ BitmapEx aResBitmapEx = pArithmeticFilter->execute();
+ CPPUNIT_ASSERT_EQUAL(Color(ColorAlpha, 0xFF, 0xFF, 0x00, 0x00),
+ aResBitmapEx.GetPixelColor(2, 2));
+ }
+
+ // transparent
+ {
+ BitmapNormalBlendFilter* pArithmeticFilter
+ = new BitmapNormalBlendFilter(aRedBitmapEx, aTransparentBitmapEx);
+ BitmapEx aResBitmapEx = pArithmeticFilter->execute();
+ CPPUNIT_ASSERT_EQUAL(Color(ColorAlpha, 0xFF, 0xFF, 0x00, 0x00),
+ aResBitmapEx.GetPixelColor(2, 2));
+ }
+}
+
void BitmapFilterTest::testDarkenBlendFilter()
{
Bitmap aRedBitmap(Size(4, 4), vcl::PixelFormat::N24_BPP);