vcl/source/filter/png/PngImageReader.cxx | 19 +++++++++---------- 1 file changed, 9 insertions(+), 10 deletions(-)
New commits: commit 31913141d2bcc3b3a8bfb6d018fbf142bd81bf58 Author: Caolán McNamara <caol...@redhat.com> AuthorDate: Mon Mar 22 20:31:01 2021 +0000 Commit: Caolán McNamara <caol...@redhat.com> CommitDate: Wed Mar 24 16:22:00 2021 +0100 Related: ofz#32152 use scanline as buffer and postprocess to premultiply (optionally relocating alpha) Change-Id: Ib279429873392b97901294191688b24867dcf450 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/112942 Tested-by: Jenkins Reviewed-by: Caolán McNamara <caol...@redhat.com> diff --git a/vcl/source/filter/png/PngImageReader.cxx b/vcl/source/filter/png/PngImageReader.cxx index ce168ef13c9e..cdb90d93940a 100644 --- a/vcl/source/filter/png/PngImageReader.cxx +++ b/vcl/source/filter/png/PngImageReader.cxx @@ -230,10 +230,6 @@ bool reader(SvStream& rStream, BitmapEx& rBitmapEx, bool bUseBitmap32) png_set_bgr(pPng); } - aRows = std::vector<std::vector<png_byte>>(height); - for (auto& rRow : aRows) - rRow.resize(aRowSizeBytes, 0); - auto const alphaFirst = (eFormat == ScanlineFormat::N32BitTcAbgr || eFormat == ScanlineFormat::N32BitTcArgb); for (int pass = 0; pass < nNumberOfPasses; pass++) @@ -241,19 +237,22 @@ bool reader(SvStream& rStream, BitmapEx& rBitmapEx, bool bUseBitmap32) for (png_uint_32 y = 0; y < height; y++) { Scanline pScanline = pWriteAccess->GetScanline(y); - png_bytep pRow = aRows[y].data(); - png_read_row(pPng, pRow, nullptr); + png_read_row(pPng, pScanline, nullptr); size_t iColor = 0; for (size_t i = 0; i < aRowSizeBytes; i += 4) { - sal_Int8 alpha = pRow[i + 3]; + sal_uInt8 alpha = pScanline[i + 3]; + sal_uInt8 byte1 = vcl::bitmap::premultiply(pScanline[i + 0], alpha); + sal_uInt8 byte2 = vcl::bitmap::premultiply(pScanline[i + 1], alpha); + sal_uInt8 byte3 = vcl::bitmap::premultiply(pScanline[i + 2], alpha); + 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++] = byte1; + pScanline[iColor++] = byte2; + pScanline[iColor++] = byte3; if (!alphaFirst) { pScanline[iColor++] = alpha; _______________________________________________ Libreoffice-commits mailing list libreoffice-comm...@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits