From 4bca6e024fc7bf3be5db1dd8cfde44d7304d6ff6 Mon Sep 17 00:00:00 2001 From: Tomaž Vajngerl Date: Mon, 17 Jun 2024 14:43:16 +0900 Subject: annot: use createBitmapFromBuffer also when rendering the PDF MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This removes the duplicated code. Change-Id: I54ada6875f7897b7eb480f10b8e1c8be887ca5ea Reviewed-on: https://gerrit.libreoffice.org/c/core/+/168978 Tested-by: Jenkins Reviewed-by: Tomaž Vajngerl --- vcl/source/filter/ipdf/pdfread.cxx | 29 +++-------------------------- 1 file changed, 3 insertions(+), 26 deletions(-) (limited to 'vcl') 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& 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 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()); } } -- cgit