vcl/source/filter/ipdf/pdfread.cxx | 27 ++++++--------------------- 1 file changed, 6 insertions(+), 21 deletions(-)
New commits: commit f1d6f202e2b8ff555cedde6315685342325b16fc Author: Miklos Vajna <vmik...@collabora.co.uk> Date: Thu Mar 2 08:58:31 2017 +0100 tdf#106270 vcl PDF import: use BitmapWriteAccess::CopyScanline() This requires one function call / row only, cross-platform and works with OpenGL enabled as well. Change-Id: I12fd0f52a1a7e8e683b50071ded95f63fecc4d40 Reviewed-on: https://gerrit.libreoffice.org/34774 Reviewed-by: Miklos Vajna <vmik...@collabora.co.uk> Tested-by: Jenkins <c...@libreoffice.org> diff --git a/vcl/source/filter/ipdf/pdfread.cxx b/vcl/source/filter/ipdf/pdfread.cxx index c855400..f11f55a 100644 --- a/vcl/source/filter/ipdf/pdfread.cxx +++ b/vcl/source/filter/ipdf/pdfread.cxx @@ -73,34 +73,19 @@ bool generatePreview(SvStream& rStream, Graphic& rGraphic) FPDF_RenderPageBitmap(pPdfBitmap, pPdfPage, /*start_x=*/0, /*start_y=*/0, nPageWidth, nPageHeight, /*rotate=*/0, /*flags=*/0); // Save the buffer as a bitmap. - Bitmap aBitmap(Size(nPageWidth, nPageHeight), 32); + Bitmap aBitmap(Size(nPageWidth, nPageHeight), 24); { Bitmap::ScopedWriteAccess pWriteAccess(aBitmap); - auto pPdfBuffer = static_cast<const char*>(FPDFBitmap_GetBuffer(pPdfBitmap)); -#ifndef MACOSX - std::memcpy(pWriteAccess->GetBuffer(), pPdfBuffer, nPageWidth * nPageHeight * 4); -#else - // ARGB -> BGRA + auto pPdfBuffer = static_cast<ConstScanline>(FPDFBitmap_GetBuffer(pPdfBitmap)); for (size_t nRow = 0; nRow < nPageHeight; ++nRow) { int nStride = FPDFBitmap_GetStride(pPdfBitmap); - const char* pPdfLine = pPdfBuffer + (nStride * nRow); - Scanline pRow = pWriteAccess->GetBuffer() + (nPageWidth * nRow * 4); - for (size_t nCol = 0; nCol < nPageWidth; ++nCol) - { - pRow[nCol * 4] = pPdfLine[(nCol * 4) + 3]; - pRow[(nCol * 4) + 1] = pPdfLine[(nCol * 4) + 2]; - pRow[(nCol * 4) + 2] = pPdfLine[(nCol * 4) + 1]; - pRow[(nCol * 4) + 3] = pPdfLine[nCol * 4]; - } + ConstScanline pPdfLine = pPdfBuffer + (nStride * nRow); + // pdfium byte order is BGRA. + pWriteAccess->CopyScanline(nRow, pPdfLine, ScanlineFormat::N32BitTcBgra, nStride); } -#endif } - BitmapEx aBitmapEx(aBitmap); -#if defined(WNT) || defined(MACOSX) - aBitmapEx.Mirror(BmpMirrorFlags::Vertical); -#endif - rGraphic = aBitmapEx; + rGraphic = aBitmap; FPDFBitmap_Destroy(pPdfBitmap); FPDF_ClosePage(pPdfPage); _______________________________________________ Libreoffice-commits mailing list libreoffice-comm...@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits