[Libreoffice-commits] core.git: vcl/source
Stephan Bergmann (via logerrit)
logerrit at kemper.freedesktop.org
Wed Sep 23 14:13:38 UTC 2020
vcl/source/filter/png/PngImageReader.cxx | 11 ++++++++++-
1 file changed, 10 insertions(+), 1 deletion(-)
New commits:
commit 0387077e6647d7a30fd36d4ec41dfc559afe45c3
Author: Stephan Bergmann <sbergman at redhat.com>
AuthorDate: Wed Sep 23 12:01:35 2020 +0200
Commit: Stephan Bergmann <sbergman at redhat.com>
CommitDate: Wed Sep 23 16:13:00 2020 +0200
Correctly read PNG into bitmaps N32BitTcA... formats (where alpha comes first)
This appears to be a regression introduced with
86ea64f216819696cd86d1926aff0a138ace2baf "Support for native 32bit Bitmap in VCL
and SVP (cairo) backend". It caused CppunitTest_vcl_png_test to fail on
(big-endian) Linux s390x with
> vcl/qa/cppunit/png/PngFilterTest.cxx:176:PngFilterTest::testPng
> equality assertion failed
> - Expected: c[ff000040]
> - Actual : c[0000ff40]
where eFormat happens to be ScanlineFormat::N32BitTcArgb, vs.
ScanlineFormat::N32BitTcBgra on e.g. Linux x86-64 (and which thus didn't notice
the lack of support for N32BitTcA... formats where alpha goes first instead of
last).
Change-Id: Id6030468718f6ef831b42f2b5ad7ba2c4c46a805
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/103240
Tested-by: Jenkins
Reviewed-by: Stephan Bergmann <sbergman at redhat.com>
diff --git a/vcl/source/filter/png/PngImageReader.cxx b/vcl/source/filter/png/PngImageReader.cxx
index fae4b29a339a..ab5097bfce2c 100644
--- a/vcl/source/filter/png/PngImageReader.cxx
+++ b/vcl/source/filter/png/PngImageReader.cxx
@@ -187,6 +187,8 @@ bool reader(SvStream& rStream, BitmapEx& rBitmapEx, bool bUseBitmap32)
for (auto& rRow : aRows)
rRow.resize(aRowSizeBytes, 0);
+ auto const alphaFirst = (eFormat == ScanlineFormat::N32BitTcAbgr
+ || eFormat == ScanlineFormat::N32BitTcArgb);
for (int pass = 0; pass < nNumberOfPasses; pass++)
{
for (png_uint_32 y = 0; y < height; y++)
@@ -198,10 +200,17 @@ bool reader(SvStream& rStream, BitmapEx& rBitmapEx, bool bUseBitmap32)
for (size_t i = 0; i < aRowSizeBytes; i += 4)
{
sal_Int8 alpha = pRow[i + 3];
+ if (alphaFirst)
+ {
+ pScanline[iColor++] = alpha;
+ }
pScanline[iColor++] = vcl::bitmap::premultiply(pRow[i + 0], alpha);
pScanline[iColor++] = vcl::bitmap::premultiply(pRow[i + 1], alpha);
pScanline[iColor++] = vcl::bitmap::premultiply(pRow[i + 2], alpha);
- pScanline[iColor++] = alpha;
+ if (!alphaFirst)
+ {
+ pScanline[iColor++] = alpha;
+ }
}
}
}
More information about the Libreoffice-commits
mailing list