vcl/source/filter/png/pngwrite.cxx |   10 +++++++++-
 1 file changed, 9 insertions(+), 1 deletion(-)

New commits:
commit 61c5101a95308fe20e684fa72457c867bd115216
Author:     Julien Nabet <serval2...@yahoo.fr>
AuthorDate: Sat Mar 5 12:37:40 2022 +0100
Commit:     Xisco Fauli <xiscofa...@libreoffice.org>
CommitDate: Thu Mar 10 10:33:46 2022 +0100

    tdf#136632: Use 'Save transparency' when exporting selected objects for PNG
    
    To avoid some regression, consider that transparency should be enabled by 
default.
    So only remove transparency if it's required explicitely.
    
    + change QA test since "Translucent" property isn't a bool but a sal_Int32
    In officecfg/registry/schema/org/openoffice/Office/Common.xcs:
    <prop oor:name="Translucent" oor:type="xs:int" oor:nillable="false">
    
    Change-Id: I9bfb6aae8e2e8a31dee82f73a9165989129f222a
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/131057
    Tested-by: Jenkins
    Reviewed-by: Julien Nabet <serval2...@yahoo.fr>
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/131061
    Reviewed-by: Xisco Fauli <xiscofa...@libreoffice.org>
    (cherry picked from commit 43356e4d9fe022f24265747cb4b0ae2fc3cd3236)
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/131133

diff --git a/vcl/source/filter/png/pngwrite.cxx 
b/vcl/source/filter/png/pngwrite.cxx
index 0554a314e83c..e89cbba69a85 100644
--- a/vcl/source/filter/png/pngwrite.cxx
+++ b/vcl/source/filter/png/pngwrite.cxx
@@ -123,6 +123,7 @@ PNGWriterImpl::PNGWriterImpl(const BitmapEx& rBitmapEx,
     Bitmap aBmp(aBitmapEx.GetBitmap());
 
     mnMaxChunkSize = std::numeric_limits<sal_uInt32>::max();
+    bool bTranslucent = true;
 
     if (pFilterData)
     {
@@ -132,6 +133,13 @@ PNGWriterImpl::PNGWriterImpl(const BitmapEx& rBitmapEx,
                 rPropVal.Value >>= mnCompLevel;
             else if (rPropVal.Name == "Interlaced")
                 rPropVal.Value >>= mnInterlaced;
+            else if (rPropVal.Name == "Translucent")
+            {
+                tools::Long nTmp = 0;
+                rPropVal.Value >>= nTmp;
+                if (!nTmp)
+                    bTranslucent = false;
+            }
             else if (rPropVal.Name == "MaxChunkSize")
             {
                 sal_Int32 nVal = 0;
@@ -142,7 +150,7 @@ PNGWriterImpl::PNGWriterImpl(const BitmapEx& rBitmapEx,
     }
     mnBitsPerPixel = 
sal_uInt8(vcl::pixelFormatBitCount(aBmp.getPixelFormat()));
 
-    if (aBitmapEx.IsAlpha())
+    if (aBitmapEx.IsAlpha() && bTranslucent)
     {
         if (mnBitsPerPixel <= 8)
         {

Reply via email to