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

New commits:
commit 98dfcfc9a9a93b10d0b97b84872540732e5adaa9
Author:     Tomaž Vajngerl <[email protected]>
AuthorDate: Mon Jun 17 14:43:16 2024 +0900
Commit:     Miklos Vajna <[email protected]>
CommitDate: Fri Jun 21 11:16:00 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/+/168982
    Tested-by: Jenkins CollaboraOffice <[email protected]>
    Reviewed-by: Miklos Vajna <[email protected]>

diff --git a/vcl/source/filter/ipdf/pdfread.cxx 
b/vcl/source/filter/ipdf/pdfread.cxx
index 9145bdce3657..20b4e036467f 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