summaryrefslogtreecommitdiff
path: root/vcl/source/bitmap/BitmapEx.cxx
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/source/bitmap/BitmapEx.cxx
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/source/bitmap/BitmapEx.cxx')
-rw-r--r--vcl/source/bitmap/BitmapEx.cxx12
1 files changed, 12 insertions, 0 deletions
diff --git a/vcl/source/bitmap/BitmapEx.cxx b/vcl/source/bitmap/BitmapEx.cxx
index b8f96acbcfbd..cc3988abf333 100644
--- a/vcl/source/bitmap/BitmapEx.cxx
+++ b/vcl/source/bitmap/BitmapEx.cxx
@@ -41,6 +41,8 @@
#include <bitmap/BitmapMaskToAlphaFilter.hxx>
#include <o3tl/any.hxx>
+#include <tools/stream.hxx>
+#include <vcl/filter/PngImageWriter.hxx>
#include <com/sun/star/beans/XFastPropertySet.hpp>
@@ -1482,4 +1484,14 @@ void BitmapEx::GetColorModel(css::uno::Sequence< sal_Int32 >& rRGBPalette,
rnBitCount = pReadAccess->GetBitCount();
}
+void BitmapEx::DumpAsPng(const char* pFileName) const
+{
+ SvFileStream aStream(pFileName ? OUString::fromUtf8(pFileName)
+ : OUString("file:///tmp/bitmap.png"),
+ StreamMode::STD_READWRITE | StreamMode::TRUNC);
+ assert(aStream.good());
+ vcl::PngImageWriter aWriter(aStream);
+ aWriter.write(*this);
+}
+
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */