summaryrefslogtreecommitdiff
path: root/vcl/qa/cppunit/png
diff options
context:
space:
mode:
authorMiklos Vajna <vmiklos@collabora.com>2023-01-11 20:17:58 +0100
committerNoel Grandin <noel.grandin@collabora.co.uk>2023-01-12 06:54:30 +0000
commit53603317af854a352e75fd2c5f0f0eeaacc5293c (patch)
tree7eeadadf0043ad681d19272f042c0d9968eef291 /vcl/qa/cppunit/png
parent244803ee2bcdfd4c4244f0c8a0654dab25fbc34d (diff)
vcl: introduce a BitmapEx::DumpAsPng()
This is mostly useful for ad-hoc debugging, so you don't need to manually create an SvFileStream, a vcl::PngImageWriter & connect them, but you can step through code in the debugger and call DumpAsPng() at random code locations. The filename type is intentionally a 'const char*', so you can call DumpAsPng(0) from gdb; that would not be possible for a 'const OUString&' parameter type. Change-Id: I7e6c9bfe8410892969a1cbd1f827e2d62f409400 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/145361 Tested-by: Jenkins Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
Diffstat (limited to 'vcl/qa/cppunit/png')
-rw-r--r--vcl/qa/cppunit/png/PngFilterTest.cxx16
1 files changed, 16 insertions, 0 deletions
diff --git a/vcl/qa/cppunit/png/PngFilterTest.cxx b/vcl/qa/cppunit/png/PngFilterTest.cxx
index fd5747d8e9c8..dae007eb7898 100644
--- a/vcl/qa/cppunit/png/PngFilterTest.cxx
+++ b/vcl/qa/cppunit/png/PngFilterTest.cxx
@@ -176,6 +176,7 @@ public:
void testPngRoundtrip24_8();
void testPngRoundtrip32();
void testPngWrite8BitRGBPalette();
+ void testDump();
CPPUNIT_TEST_SUITE(PngFilterTest);
CPPUNIT_TEST(testPng);
@@ -186,6 +187,7 @@ public:
CPPUNIT_TEST(testPngRoundtrip24_8);
CPPUNIT_TEST(testPngRoundtrip32);
CPPUNIT_TEST(testPngWrite8BitRGBPalette);
+ CPPUNIT_TEST(testDump);
CPPUNIT_TEST_SUITE_END();
};
@@ -1956,6 +1958,20 @@ void PngFilterTest::testPngWrite8BitRGBPalette()
}
}
+void PngFilterTest::testDump()
+{
+ utl::TempFileNamed aTempFile;
+ Bitmap aBitmap(Size(1, 1), vcl::PixelFormat::N24_BPP);
+ {
+ BitmapScopedWriteAccess pWriteAccessBitmap(aBitmap);
+ pWriteAccessBitmap->SetPixel(0, 0, BitmapColor());
+ }
+ BitmapEx aBitmapEx(aBitmap);
+ aBitmapEx.DumpAsPng(aTempFile.GetURL().toUtf8().getStr());
+ SvStream* pStream = aTempFile.GetStream(StreamMode::READ);
+ CPPUNIT_ASSERT_GREATER(static_cast<sal_uInt64>(0), pStream->remainingSize());
+}
+
CPPUNIT_TEST_SUITE_REGISTRATION(PngFilterTest);
CPPUNIT_PLUGIN_IMPLEMENT();