vcl/source/bitmap/BitmapEx.cxx |   17 ++++++++++++++---
 1 file changed, 14 insertions(+), 3 deletions(-)

New commits:
commit b3a15589915e8b60eae5878e53f90d706c79c106
Author:     Miklos Vajna <vmik...@collabora.com>
AuthorDate: Thu Jan 12 13:33:20 2023 +0100
Commit:     Miklos Vajna <vmik...@collabora.com>
CommitDate: Thu Jan 12 17:27:08 2023 +0000

    vcl: handle VCL_DUMP_BMP_PATH in BitmapEx::DumpAsPng()
    
    As requested at
    
<https://gerrit.libreoffice.org/c/core/+/145361/2#message-e00b755a1a0cdc5cec9b8e2213226e56ec87c038>.
    
    Change-Id: I8868969a2061f0447b101d978acc5027d1bdd545
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/145400
    Tested-by: Jenkins
    Reviewed-by: Miklos Vajna <vmik...@collabora.com>

diff --git a/vcl/source/bitmap/BitmapEx.cxx b/vcl/source/bitmap/BitmapEx.cxx
index cc3988abf333..f83f44d5007a 100644
--- a/vcl/source/bitmap/BitmapEx.cxx
+++ b/vcl/source/bitmap/BitmapEx.cxx
@@ -1486,9 +1486,20 @@ void  BitmapEx::GetColorModel(css::uno::Sequence< 
sal_Int32 >& rRGBPalette,
 
 void BitmapEx::DumpAsPng(const char* pFileName) const
 {
-    SvFileStream aStream(pFileName ? OUString::fromUtf8(pFileName)
-                                   : OUString("file:///tmp/bitmap.png"),
-                         StreamMode::STD_READWRITE | StreamMode::TRUNC);
+    OUString sPath;
+    if (pFileName)
+    {
+        sPath = OUString::fromUtf8(pFileName);
+    }
+    else if (const char* pEnv = std::getenv("VCL_DUMP_BMP_PATH"))
+    {
+        sPath = OUString::fromUtf8(pEnv);
+    }
+    else
+    {
+        sPath = "file:///tmp/bitmap.png";
+    }
+    SvFileStream aStream(sPath, StreamMode::STD_READWRITE | StreamMode::TRUNC);
     assert(aStream.good());
     vcl::PngImageWriter aWriter(aStream);
     aWriter.write(*this);

Reply via email to