summaryrefslogtreecommitdiff
path: root/vcl/qa/cppunit
diff options
context:
space:
mode:
authorXisco Fauli <xiscofauli@libreoffice.org>2024-04-22 13:06:36 +0200
committerXisco Fauli <xiscofauli@libreoffice.org>2024-04-22 14:55:37 +0200
commitfdf3027a0eb8270d527b3e64c6157917a6718787 (patch)
tree52fcdf523db0ed223cc0e6a43a68a870ba6c95de /vcl/qa/cppunit
parent07137ccd7fbbf3afb1cabfc6ca71375293910a3a (diff)
tdf#159660: Add support for multiply mode in feBlend
Change-Id: I03230e122a10dd6ada6af357c674c278b6b99d9e Reviewed-on: https://gerrit.libreoffice.org/c/core/+/166427 Tested-by: Jenkins Reviewed-by: Xisco Fauli <xiscofauli@libreoffice.org>
Diffstat (limited to 'vcl/qa/cppunit')
-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 902d5934f07d..fb01bfde0018 100644
--- a/vcl/qa/cppunit/BitmapFilterTest.cxx
+++ b/vcl/qa/cppunit/BitmapFilterTest.cxx
@@ -16,6 +16,7 @@
#include <vcl/graphicfilter.hxx>
#include <vcl/BitmapArithmeticBlendFilter.hxx>
+#include <vcl/BitmapMultiplyBlendFilter.hxx>
#include <vcl/BitmapScreenBlendFilter.hxx>
#include <vcl/BitmapBasicMorphologyFilter.hxx>
#include <vcl/BitmapFilterStackBlur.hxx>
@@ -41,6 +42,7 @@ public:
void testBasicMorphology();
void testPerformance();
void testGenerateStripRanges();
+ void testMultiplyBlendFilter();
void testScreenBlendFilter();
void testArithmeticBlendFilter();
@@ -49,6 +51,7 @@ public:
CPPUNIT_TEST(testBasicMorphology);
CPPUNIT_TEST(testPerformance);
CPPUNIT_TEST(testGenerateStripRanges);
+ CPPUNIT_TEST(testMultiplyBlendFilter);
CPPUNIT_TEST(testScreenBlendFilter);
CPPUNIT_TEST(testArithmeticBlendFilter);
CPPUNIT_TEST_SUITE_END();
@@ -282,6 +285,60 @@ void BitmapFilterTest::testGenerateStripRanges()
}
}
+void BitmapFilterTest::testMultiplyBlendFilter()
+{
+ 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
+ {
+ BitmapMultiplyBlendFilter* pArithmeticFilter
+ = new BitmapMultiplyBlendFilter(aRedBitmapEx, aRedBitmapEx);
+ BitmapEx aResBitmapEx = pArithmeticFilter->execute();
+ CPPUNIT_ASSERT_EQUAL(COL_LIGHTRED, aResBitmapEx.GetPixelColor(2, 2));
+ }
+
+ // different color
+ {
+ BitmapMultiplyBlendFilter* pArithmeticFilter
+ = new BitmapMultiplyBlendFilter(aRedBitmapEx, aGreenBitmapEx);
+ BitmapEx aResBitmapEx = pArithmeticFilter->execute();
+ CPPUNIT_ASSERT_EQUAL(Color(ColorAlpha, 0xFF, 0x00, 0x00, 0x00),
+ aResBitmapEx.GetPixelColor(2, 2));
+ }
+
+ // transparent
+ {
+ BitmapMultiplyBlendFilter* pArithmeticFilter
+ = new BitmapMultiplyBlendFilter(aRedBitmapEx, aTransparentBitmapEx);
+ BitmapEx aResBitmapEx = pArithmeticFilter->execute();
+ CPPUNIT_ASSERT_EQUAL(Color(ColorAlpha, 0xFF, 0xFF, 0x00, 0x00),
+ aResBitmapEx.GetPixelColor(2, 2));
+ }
+}
+
void BitmapFilterTest::testScreenBlendFilter()
{
Bitmap aRedBitmap(Size(4, 4), vcl::PixelFormat::N24_BPP);