From 29b27aecb44c00094a6c6d0f8141af969afd9630 Mon Sep 17 00:00:00 2001 From: Tomaž Vajngerl Date: Thu, 14 Feb 2019 10:07:48 +0100 Subject: vcl: test rendering of bitmaps with alpha MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Change-Id: I6fde9581793fe85fc30d0660de3d62f0ddbfe9fd Reviewed-on: https://gerrit.libreoffice.org/67807 Tested-by: Jenkins Reviewed-by: Tomaž Vajngerl --- vcl/qa/cppunit/bitmaprender/BitmapRenderTest.cxx | 27 +++++++++++++++++++++++ vcl/qa/cppunit/bitmaprender/data/ImageRGBA.png | Bin 0 -> 106 bytes 2 files changed, 27 insertions(+) create mode 100644 vcl/qa/cppunit/bitmaprender/data/ImageRGBA.png (limited to 'vcl') diff --git a/vcl/qa/cppunit/bitmaprender/BitmapRenderTest.cxx b/vcl/qa/cppunit/bitmaprender/BitmapRenderTest.cxx index b6f2dbbd3d99..e770f1a4cc86 100644 --- a/vcl/qa/cppunit/bitmaprender/BitmapRenderTest.cxx +++ b/vcl/qa/cppunit/bitmaprender/BitmapRenderTest.cxx @@ -19,6 +19,7 @@ #include #include +#include static OUString const gaDataUrl = "/vcl/qa/cppunit/bitmaprender/data/"; @@ -37,10 +38,13 @@ public: void testTdf104141(); void testTdf113918(); + void testDrawBitmap32(); CPPUNIT_TEST_SUITE(BitmapRenderTest); CPPUNIT_TEST(testTdf104141); CPPUNIT_TEST(testTdf113918); + CPPUNIT_TEST(testDrawBitmap32); + CPPUNIT_TEST_SUITE_END(); }; @@ -95,6 +99,29 @@ void BitmapRenderTest::testTdf113918() CPPUNIT_ASSERT(aColor.GetGreen() > 100); } +void BitmapRenderTest::testDrawBitmap32() +{ + ScopedVclPtrInstance pVDev; + pVDev->SetOutputSizePixel(Size(8, 8)); + pVDev->SetBackground(Wallpaper(COL_WHITE)); + pVDev->Erase(); + + CPPUNIT_ASSERT_EQUAL(COL_WHITE, pVDev->GetPixel(Point(0, 0))); + CPPUNIT_ASSERT_EQUAL(COL_WHITE, pVDev->GetPixel(Point(1, 1))); + CPPUNIT_ASSERT_EQUAL(COL_WHITE, pVDev->GetPixel(Point(2, 2))); + + SvFileStream aFileStream(getFullUrl("ImageRGBA.png"), StreamMode::READ); + + vcl::PngImageReader aPngReader(aFileStream); + BitmapEx aBitmapEx; + aPngReader.read(aBitmapEx); + pVDev->DrawBitmapEx(Point(), aBitmapEx); + + CPPUNIT_ASSERT_EQUAL(COL_WHITE, pVDev->GetPixel(Point(0, 0))); + CPPUNIT_ASSERT_EQUAL(COL_YELLOW, pVDev->GetPixel(Point(1, 1))); + CPPUNIT_ASSERT_EQUAL(Color(0x00, 0x7F, 0xFF, 0x7F), pVDev->GetPixel(Point(2, 2))); +} + CPPUNIT_TEST_SUITE_REGISTRATION(BitmapRenderTest); CPPUNIT_PLUGIN_IMPLEMENT(); diff --git a/vcl/qa/cppunit/bitmaprender/data/ImageRGBA.png b/vcl/qa/cppunit/bitmaprender/data/ImageRGBA.png new file mode 100644 index 000000000000..7a8399293c94 Binary files /dev/null and b/vcl/qa/cppunit/bitmaprender/data/ImageRGBA.png differ -- cgit