vcl/source/filter/ipdf/pdfread.cxx |   29 +++--------------------------
 1 file changed, 3 insertions(+), 26 deletions(-)

New commits:
commit 4bca6e024fc7bf3be5db1dd8cfde44d7304d6ff6
Author:     Tomaž Vajngerl <tomaz.vajng...@collabora.co.uk>
AuthorDate: Mon Jun 17 14:43:16 2024 +0900
Commit:     Tomaž Vajngerl <qui...@gmail.com>
CommitDate: Mon Jun 17 10:24:31 2024 +0200

    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 <qui...@gmail.com>

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());
         }
     }
 

Reply via email to