vcl/source/gdi/pdfwriter_impl.cxx | 10 ++++++++++ vcl/source/gdi/pdfwriter_impl2.cxx | 30 ++---------------------------- 2 files changed, 12 insertions(+), 28 deletions(-)
New commits: commit 3e20c3e73cbd10e8323f0997e3a6536abd11e2bd Author: Khaled Hosny <kha...@libreoffice.org> AuthorDate: Tue Aug 22 06:13:10 2023 +0000 Commit: خالد حسني <kha...@libreoffice.org> CommitDate: Tue Aug 22 09:55:27 2023 +0200 tdf#156853: Fix PDF export of bitmap color fonts Move the alpha inversion down to createBitmapEmit() so that it gets applied to any bitmap embedded in the PDF, especially since embedded color bitmap glyphs don't go through the higher level code path. Regression from: commit 81994cb2b8b32453a92bcb011830fcb884f22ff3 Date: Fri Apr 16 20:33:10 2021 +0200 Convert internal vcl bitmap formats transparency->alpha (II) Change-Id: I68601a7a0d9ac01f5e8054f074f8e18fcbdea1be Reviewed-on: https://gerrit.libreoffice.org/c/core/+/155930 Reviewed-by: Noel Grandin <noel.gran...@collabora.co.uk> Tested-by: Jenkins Reviewed-by: خالد حسني <kha...@libreoffice.org> diff --git a/vcl/source/gdi/pdfwriter_impl.cxx b/vcl/source/gdi/pdfwriter_impl.cxx index 429efe3aa639..4cda5a09b287 100644 --- a/vcl/source/gdi/pdfwriter_impl.cxx +++ b/vcl/source/gdi/pdfwriter_impl.cxx @@ -9799,6 +9799,16 @@ void PDFWriterImpl::drawBitmap( const Point& rDestPoint, const Size& rDestSize, const BitmapEmit& PDFWriterImpl::createBitmapEmit(const BitmapEx& i_rBitmap, const Graphic& rGraphic, std::list<BitmapEmit>& rBitmaps, ResourceDict& rResourceDict, std::list<StreamRedirect>& rOutputStreams) { BitmapEx aBitmap( i_rBitmap ); + + // When rendering an image with an alpha mask during PDF export, the alpha + // mask needs to be inverted + if (aBitmap.IsAlpha()) + { + AlphaMask aAlpha = aBitmap.GetAlphaMask(); + aAlpha.Invert(); + aBitmap = BitmapEx(aBitmap.GetBitmap(), aAlpha); + } + auto ePixelFormat = aBitmap.GetBitmap().getPixelFormat(); if( m_aContext.ColorMode == PDFWriter::DrawGreyscale ) aBitmap.Convert(BmpConversion::N8BitGreys); diff --git a/vcl/source/gdi/pdfwriter_impl2.cxx b/vcl/source/gdi/pdfwriter_impl2.cxx index 54ff2201ead9..a9b2a1238000 100644 --- a/vcl/source/gdi/pdfwriter_impl2.cxx +++ b/vcl/source/gdi/pdfwriter_impl2.cxx @@ -763,15 +763,7 @@ void PDFWriterImpl::playMetafile( const GDIMetaFile& i_rMtf, vcl::PDFExtOutDevDa { const MetaBmpExAction* pA = static_cast<const MetaBmpExAction*>(pAction); - // When rendering an image with an alpha mask during PDF - // export, the alpha mask needs to be inverted - BitmapEx aBitmapEx( pA->GetBitmapEx() ); - if ( aBitmapEx.IsAlpha()) - { - AlphaMask aAlpha = aBitmapEx.GetAlphaMask(); - aAlpha.Invert(); - aBitmapEx = BitmapEx(aBitmapEx.GetBitmap(), aAlpha); - } + const BitmapEx& aBitmapEx( pA->GetBitmapEx() ); Size aSize( OutputDevice::LogicToLogic( aBitmapEx.GetPrefSize(), aBitmapEx.GetPrefMapMode(), pDummyVDev->GetMapMode() ) ); @@ -784,18 +776,8 @@ void PDFWriterImpl::playMetafile( const GDIMetaFile& i_rMtf, vcl::PDFExtOutDevDa { const MetaBmpExScaleAction* pA = static_cast<const MetaBmpExScaleAction*>(pAction); - // When rendering an image with an alpha mask during PDF - // export, the alpha mask needs to be inverted - BitmapEx aBitmapEx( pA->GetBitmapEx() ); - if ( aBitmapEx.IsAlpha()) - { - AlphaMask aAlpha = aBitmapEx.GetAlphaMask(); - aAlpha.Invert(); - aBitmapEx = BitmapEx(aBitmapEx.GetBitmap(), aAlpha); - } - Graphic aGraphic = i_pOutDevData ? i_pOutDevData->GetCurrentGraphic() : Graphic(); - implWriteBitmapEx( pA->GetPoint(), pA->GetSize(), aBitmapEx, aGraphic, pDummyVDev, i_rContext ); + implWriteBitmapEx( pA->GetPoint(), pA->GetSize(), pA->GetBitmapEx(), aGraphic, pDummyVDev, i_rContext ); } break; @@ -803,15 +785,7 @@ void PDFWriterImpl::playMetafile( const GDIMetaFile& i_rMtf, vcl::PDFExtOutDevDa { const MetaBmpExScalePartAction* pA = static_cast<const MetaBmpExScalePartAction*>(pAction); - // When rendering an image with an alpha mask during PDF - // export, the alpha mask needs to be inverted BitmapEx aBitmapEx( pA->GetBitmapEx() ); - if ( aBitmapEx.IsAlpha()) - { - AlphaMask aAlpha = aBitmapEx.GetAlphaMask(); - aAlpha.Invert(); - aBitmapEx = BitmapEx(aBitmapEx.GetBitmap(), aAlpha); - } aBitmapEx.Crop( tools::Rectangle( pA->GetSrcPoint(), pA->GetSrcSize() ) ); Graphic aGraphic = i_pOutDevData ? i_pOutDevData->GetCurrentGraphic() : Graphic();