[Libreoffice-commits] core.git: vcl/source

Libreoffice Gerrit user logerrit at kemper.freedesktop.org
Wed Feb 13 13:43:00 UTC 2019


 vcl/source/filter/png/PngImageReader.cxx |    9 +++++++--
 1 file changed, 7 insertions(+), 2 deletions(-)

New commits:
commit 0ac4425e1c0c6b5c55933307929fc8d37a927b2c
Author:     Tomaž Vajngerl <tomaz.vajngerl at collabora.co.uk>
AuthorDate: Wed Feb 13 11:40:45 2019 +0100
Commit:     Tomaž Vajngerl <quikee at gmail.com>
CommitDate: Wed Feb 13 14:42:35 2019 +0100

    tdf#123420 Fix RGB/BGR issue with PNG reader
    
    Change-Id: I4c6ffc89a21f46dea8775d4ec9aacc4f7ca71d94
    Reviewed-on: https://gerrit.libreoffice.org/67764
    Tested-by: Jenkins
    Reviewed-by: Tomaž Vajngerl <quikee at gmail.com>

diff --git a/vcl/source/filter/png/PngImageReader.cxx b/vcl/source/filter/png/PngImageReader.cxx
index 790336654714..b4778fe5df63 100644
--- a/vcl/source/filter/png/PngImageReader.cxx
+++ b/vcl/source/filter/png/PngImageReader.cxx
@@ -88,8 +88,6 @@ bool reader(SvStream& rStream, BitmapEx& rBitmapEx)
     Bitmap aBitmap(Size(width, height), 24);
     AlphaMask aBitmapAlpha(Size(width, height), nullptr);
 
-    png_set_bgr(pPng);
-
     if (colorType == PNG_COLOR_TYPE_PALETTE)
         png_set_palette_to_rgb(pPng);
 
@@ -138,6 +136,9 @@ bool reader(SvStream& rStream, BitmapEx& rBitmapEx)
             size_t aRowSizeBytes = png_get_rowbytes(pPng, pInfo);
 
             BitmapScopedWriteAccess pWriteAccess(aBitmap);
+            ScanlineFormat eFromat = pWriteAccess->GetScanlineFormat();
+            if (eFromat == ScanlineFormat::N24BitTcBgr)
+                png_set_bgr(pPng);
 
             std::vector<png_byte> aRow(aRowSizeBytes, 0);
 
@@ -165,6 +166,10 @@ bool reader(SvStream& rStream, BitmapEx& rBitmapEx)
             BitmapScopedWriteAccess pWriteAccess(aBitmap);
             AlphaScopedWriteAccess pWriteAccessAlpha(aBitmapAlpha);
 
+            ScanlineFormat eFromat = pWriteAccess->GetScanlineFormat();
+            if (eFromat == ScanlineFormat::N24BitTcBgr)
+                png_set_bgr(pPng);
+
             std::vector<png_byte> aRow(aRowSizeBytes, 0);
 
             for (int pass = 0; pass < nNumberOfPasses; pass++)


More information about the Libreoffice-commits mailing list