svx/source/svdraw/svdpdf.cxx | 35 +---------------------------------- vcl/source/pdf/PDFiumLibrary.cxx | 8 ++++++++ 2 files changed, 9 insertions(+), 34 deletions(-)
New commits: commit 8af1286a79ede9cbbbe3ceed34c177278b2cef11 Author: Caolán McNamara <[email protected]> AuthorDate: Fri Oct 17 17:08:05 2025 +0100 Commit: Miklos Vajna <[email protected]> CommitDate: Mon Oct 20 09:25:13 2025 +0200 use createBitmapFromBuffer to get transparency merge the relatively new 8bit grayscale support to that. And drop the thing that doesn't honour 32bit transparency. Change-Id: I61f4544be9573a4d8d4bae056b7866f1310b8ee0 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/192584 Reviewed-by: Miklos Vajna <[email protected]> Tested-by: Jenkins CollaboraOffice <[email protected]> diff --git a/svx/source/svdraw/svdpdf.cxx b/svx/source/svdraw/svdpdf.cxx index bfbfc31a2c5f..629f770c1d3a 100644 --- a/svx/source/svdraw/svdpdf.cxx +++ b/svx/source/svdraw/svdpdf.cxx @@ -1941,13 +1941,6 @@ void ImpSdrPdfImport::MapScaling() mnMapScalingOfs = nCount; } -static BitmapEx createBitmap(const Size& rSize, bool bGrayScale) -{ - if (bGrayScale) - return BitmapEx(Bitmap(rSize, vcl::PixelFormat::N8_BPP, &Bitmap::GetGreyPalette(256))); - return BitmapEx(rSize, vcl::PixelFormat::N24_BPP); -} - void ImpSdrPdfImport::ImportImage(std::unique_ptr<vcl::pdf::PDFiumPageObject> const& pPageObject, int /*nPageObjectIndex*/) { @@ -1965,33 +1958,6 @@ void ImpSdrPdfImport::ImportImage(std::unique_ptr<vcl::pdf::PDFiumPageObject> co return; } - const unsigned char* pBuf = bitmap->getBuffer(); - const int nWidth = bitmap->getWidth(); - const int nHeight = bitmap->getHeight(); - const int nStride = bitmap->getStride(); - BitmapEx aBitmap(createBitmap(Size(nWidth, nHeight), format == vcl::pdf::PDFBitmapType::Gray)); - - switch (format) - { - case vcl::pdf::PDFBitmapType::Gray: - ReadRawDIB(aBitmap, pBuf, ScanlineFormat::N8BitPal, nHeight, nStride); - break; - case vcl::pdf::PDFBitmapType::BGR: - ReadRawDIB(aBitmap, pBuf, ScanlineFormat::N24BitTcBgr, nHeight, nStride); - break; - case vcl::pdf::PDFBitmapType::BGRx: - ReadRawDIB(aBitmap, pBuf, ScanlineFormat::N32BitTcBgra, nHeight, nStride); - break; - case vcl::pdf::PDFBitmapType::BGRA: - ReadRawDIB(aBitmap, pBuf, ScanlineFormat::N32BitTcBgra, nHeight, nStride); - break; - default: - SAL_WARN("sd.filter", "Got IMAGE width: " << nWidth << ", height: " << nHeight - << ", stride: " << nStride - << ", format: " << static_cast<int>(format)); - break; - } - basegfx::B2DRectangle aBounds = pPageObject->getBounds(); float left = aBounds.getMinX(); // Upside down. @@ -2003,6 +1969,7 @@ void ImpSdrPdfImport::ImportImage(std::unique_ptr<vcl::pdf::PDFiumPageObject> co aRect.AdjustRight(1); aRect.AdjustBottom(1); + BitmapEx aBitmap = bitmap->createBitmapFromBuffer(); rtl::Reference<SdrGrafObj> pGraf = new SdrGrafObj(*mpModel, Graphic(aBitmap), aRect); // This action is not creating line and fill, set directly, do not use SetAttributes(..) diff --git a/vcl/source/pdf/PDFiumLibrary.cxx b/vcl/source/pdf/PDFiumLibrary.cxx index 381080b583d9..1307cf12795c 100644 --- a/vcl/source/pdf/PDFiumLibrary.cxx +++ b/vcl/source/pdf/PDFiumLibrary.cxx @@ -1504,6 +1504,14 @@ BitmapEx PDFiumBitmapImpl::createBitmapFromBuffer() switch (eFormat) { + case vcl::pdf::PDFBitmapType::Gray: + { + aBitmapEx = Bitmap(Size(nWidth, nHeight), vcl::PixelFormat::N8_BPP, + &Bitmap::GetGreyPalette(256)); + ReadRawDIB(aBitmapEx, getBuffer(), ScanlineFormat::N8BitPal, nHeight, nStride); + } + break; + case vcl::pdf::PDFBitmapType::BGR: { aBitmapEx = BitmapEx(Size(nWidth, nHeight), vcl::PixelFormat::N24_BPP);
