include/vcl/bitmapex.hxx                 |    1 +
 vcl/source/bitmap/BitmapEx.cxx           |    5 +++++
 vcl/source/filter/png/PngImageWriter.cxx |    8 ++++++--
 3 files changed, 12 insertions(+), 2 deletions(-)

New commits:
commit 21fa75ced1f82b5dd87874a789a13153c09cd283
Author:     Paris Oplopoios <paris.oplopo...@collabora.com>
AuthorDate: Sat Jun 10 21:33:39 2023 +0300
Commit:     Paris Oplopoios <parisop...@gmail.com>
CommitDate: Thu Jun 15 15:01:54 2023 +0200

    tdf#154168 Export no transparency PNGs correctly
    
    When bTranslucent was false the function would simply return, causing a
    0 byte png. Now we just remove the alpha channel.
    
    Change-Id: Ie2578185ac12fb38b6f1b674758e564721e3973f
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/152840
    Tested-by: Jenkins
    Reviewed-by: Paris Oplopoios <parisop...@gmail.com>
    (cherry picked from commit 7588c1f33cdaab58a6b84f4f4e75922c5d4a8a7f)
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/152886
    Reviewed-by: Xisco Fauli <xiscofa...@libreoffice.org>
    (cherry picked from commit e691869486cd4ee4ee1dfb8f7a41440f7f6500fd)
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/153081

diff --git a/include/vcl/bitmapex.hxx b/include/vcl/bitmapex.hxx
index f847c9f6dcb2..9dcedc7ffb81 100644
--- a/include/vcl/bitmapex.hxx
+++ b/include/vcl/bitmapex.hxx
@@ -56,6 +56,7 @@ public:
     bool                IsEmpty() const;
     void                SetEmpty();
     void                Clear();
+    void                ClearAlpha();
 
     void                Draw( OutputDevice* pOutDev,
                               const Point& rDestPt ) const;
diff --git a/vcl/source/bitmap/BitmapEx.cxx b/vcl/source/bitmap/BitmapEx.cxx
index 6ff2280cdb06..c19ed0f02c3a 100644
--- a/vcl/source/bitmap/BitmapEx.cxx
+++ b/vcl/source/bitmap/BitmapEx.cxx
@@ -190,6 +190,11 @@ void BitmapEx::Clear()
     SetEmpty();
 }
 
+void BitmapEx::ClearAlpha()
+{
+    maAlphaMask.SetEmpty();
+}
+
 bool BitmapEx::IsAlpha() const
 {
     return !maAlphaMask.IsEmpty();
diff --git a/vcl/source/filter/png/PngImageWriter.cxx 
b/vcl/source/filter/png/PngImageWriter.cxx
index f550d9951e64..29d79740009e 100644
--- a/vcl/source/filter/png/PngImageWriter.cxx
+++ b/vcl/source/filter/png/PngImageWriter.cxx
@@ -50,8 +50,6 @@ static bool pngWrite(SvStream& rStream, const BitmapEx& 
rBitmapEx, int nCompress
                      bool bInterlaced, bool bTranslucent,
                      const std::vector<PngChunk>& aAdditionalChunks)
 {
-    if (rBitmapEx.IsAlpha() && !bTranslucent)
-        return false;
     if (rBitmapEx.IsEmpty())
         return false;
 
@@ -78,6 +76,12 @@ static bool pngWrite(SvStream& rStream, const BitmapEx& 
rBitmapEx, int nCompress
         aBitmapEx = rBitmapEx;
     }
 
+    if (!bTranslucent)
+    {
+        // Clear alpha channel
+        aBitmapEx.ClearAlpha();
+    }
+
     Bitmap aBitmap;
     AlphaMask aAlphaMask;
     Bitmap::ScopedReadAccess pAccess;

Reply via email to