diff options
author | Tomaž Vajngerl <tomaz.vajngerl@collabora.co.uk> | 2024-06-17 14:43:16 +0900 |
---|---|---|
committer | Tomaž Vajngerl <quikee@gmail.com> | 2024-06-17 10:24:31 +0200 |
commit | 4bca6e024fc7bf3be5db1dd8cfde44d7304d6ff6 (patch) | |
tree | 8c4f25ac1937475505c30ff4c9642bbf7df5d4fe /vcl | |
parent | 4fbb4242d924c0a7a43a10c4ecd4a33f8b339310 (diff) |
annot: use createBitmapFromBuffer also when rendering the PDF
This removes the duplicated code.
Change-Id: I54ada6875f7897b7eb480f10b8e1c8be887ca5ea
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/168978
Tested-by: Jenkins
Reviewed-by: Tomaž Vajngerl <quikee@gmail.com>
Diffstat (limited to 'vcl')
-rw-r--r-- | vcl/source/filter/ipdf/pdfread.cxx | 29 |
1 files changed, 3 insertions, 26 deletions
diff --git a/vcl/source/filter/ipdf/pdfread.cxx b/vcl/source/filter/ipdf/pdfread.cxx index c60e8bb4a792..cd345b9ed1c3 100644 --- a/vcl/source/filter/ipdf/pdfread.cxx +++ b/vcl/source/filter/ipdf/pdfread.cxx @@ -86,38 +86,15 @@ size_t RenderPDFBitmaps(const void* pBuffer, int nSize, std::vector<BitmapEx>& r pPdfBitmap->fillRect(0, 0, nPageWidth, nPageHeight, nColor); pPdfBitmap->renderPageBitmap(pPdfDocument.get(), pPdfPage.get(), /*nStartX=*/0, /*nStartY=*/0, nPageWidth, nPageHeight); - - // Save the buffer as a bitmap. - Bitmap aBitmap(Size(nPageWidth, nPageHeight), vcl::PixelFormat::N24_BPP); - AlphaMask aMask(Size(nPageWidth, nPageHeight)); - { - BitmapScopedWriteAccess pWriteAccess(aBitmap); - BitmapScopedWriteAccess pMaskAccess(aMask); - ConstScanline pPdfBuffer = pPdfBitmap->getBuffer(); - const int nStride = pPdfBitmap->getStride(); - std::vector<sal_uInt8> aScanlineAlpha(nPageWidth); - for (int nRow = 0; nRow < nPageHeight; ++nRow) - { - ConstScanline pPdfLine = pPdfBuffer + (nStride * nRow); - // pdfium byte order is BGRA. - pWriteAccess->CopyScanline(nRow, pPdfLine, ScanlineFormat::N32BitTcBgra, nStride); - for (int nCol = 0; nCol < nPageWidth; ++nCol) - { - aScanlineAlpha[nCol] = pPdfLine[3]; - pPdfLine += 4; - } - pMaskAccess->CopyScanline(nRow, aScanlineAlpha.data(), ScanlineFormat::N8BitPal, - nPageWidth); - } - } + BitmapEx aBitmapEx = pPdfBitmap->createBitmapFromBuffer(); if (bTransparent) { - rBitmaps.emplace_back(aBitmap, aMask); + rBitmaps.emplace_back(std::move(aBitmapEx)); } else { - rBitmaps.emplace_back(std::move(aBitmap)); + rBitmaps.emplace_back(aBitmapEx.GetBitmap()); } } |