summaryrefslogtreecommitdiff
path: root/vcl
diff options
context:
space:
mode:
authorMiklos Vajna <vmiklos@collabora.co.uk>2017-03-02 08:58:31 +0100
committerMiklos Vajna <vmiklos@collabora.co.uk>2017-03-02 09:51:20 +0000
commitf1d6f202e2b8ff555cedde6315685342325b16fc (patch)
tree1a78f80a7f2c3b008d2e385c02d376566531416b /vcl
parent1c29456c9c9007b788297aebea58a1a765f77c84 (diff)
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 <vmiklos@collabora.co.uk> Tested-by: Jenkins <ci@libreoffice.org>
Diffstat (limited to 'vcl')
-rw-r--r--vcl/source/filter/ipdf/pdfread.cxx27
1 files changed, 6 insertions, 21 deletions
diff --git a/vcl/source/filter/ipdf/pdfread.cxx b/vcl/source/filter/ipdf/pdfread.cxx
index c8554005574e..f11f55a0b0f7 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);