summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMike Kaganski <mike.kaganski@collabora.com>2020-05-14 14:42:24 +0300
committerMike Kaganski <mike.kaganski@collabora.com>2020-05-29 11:25:12 +0200
commit4f6b3e3089f070e7bf4b061c549ab3c6614dd542 (patch)
tree324bb23852ddae9ed354965a39dd8292460e03d3
parent415fac828c4bb45fa23f7d81e93992b711f37810 (diff)
Allow dumping Bitmap in its dtor in dbgutil builds
Change-Id: I81ec9d1c16a07c6c56e51e7e334fb692b963e1e1 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/95054 Tested-by: Jenkins Reviewed-by: Mike Kaganski <mike.kaganski@collabora.com>
-rw-r--r--vcl/source/bitmap/bitmap.cxx30
1 files changed, 30 insertions, 0 deletions
diff --git a/vcl/source/bitmap/bitmap.cxx b/vcl/source/bitmap/bitmap.cxx
index 20045fc78f5e..fd37da07e9ef 100644
--- a/vcl/source/bitmap/bitmap.cxx
+++ b/vcl/source/bitmap/bitmap.cxx
@@ -31,6 +31,12 @@
#include <algorithm>
#include <memory>
+#ifdef DBG_UTIL
+#include <cstdlib>
+#include <tools/stream.hxx>
+#include <vcl/graphicfilter.hxx>
+#endif
+
Bitmap::Bitmap()
{
}
@@ -110,8 +116,32 @@ Bitmap::Bitmap( const Size& rSizePixel, sal_uInt16 nBitCount, const BitmapPalett
}
}
+#ifdef DBG_UTIL
+
+namespace
+{
+void savePNG(const OUString& sWhere, const Bitmap& rBmp)
+{
+ SvFileStream aStream(sWhere, StreamMode::WRITE | StreamMode::TRUNC);
+ GraphicFilter& rFilter = GraphicFilter::GetGraphicFilter();
+ rFilter.compressAsPNG(rBmp, aStream);
+}
+}
+
+#endif
+
Bitmap::~Bitmap()
{
+#ifdef DBG_UTIL
+ // VCL_DUMP_BMP_PATH should be like C:/bmpDump.png or ~/bmpDump.png
+ static const OUString sDumpPath(OUString::createFromAscii(std::getenv("VCL_DUMP_BMP_PATH")));
+ static volatile bool save(false);
+ if (!sDumpPath.isEmpty() && save)
+ {
+ save = false;
+ savePNG(sDumpPath, *this);
+ }
+#endif
}
const BitmapPalette& Bitmap::GetGreyPalette( int nEntries )