vcl/source/gdi/pdfwriter_impl.cxx  |   10 ----------
 vcl/source/gdi/pdfwriter_impl2.cxx |   30 ++++++++++++++++++++++++++++--
 2 files changed, 28 insertions(+), 12 deletions(-)

New commits:
commit 8dc8413b4f8037b9c89f08a5b0b939bb61052585
Author:     Patrick Luby <plub...@neooffice.org>
AuthorDate: Tue Aug 22 14:03:54 2023 +0200
Commit:     Patrick Luby <plub...@neooffice.org>
CommitDate: Tue Aug 22 14:36:44 2023 +0200

    Revert "tdf#156853: Fix PDF export of bitmap color fonts"
    
    This reverts commit 3e20c3e73cbd10e8323f0997e3a6536abd11e2bd.
    
    Reason for revert: This breaks every single fix that I have made for 
exporting alpha masks to PDF. A different solution is needed as the invert 
needs to be where it was to snapshot the AlphaMask.
    
    Change-Id: I5f743b67067dff43a2324d6ca9bc1f444e245a12
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/155917
    Reviewed-by: Patrick Luby <plub...@neooffice.org>
    Tested-by: Patrick Luby <plub...@neooffice.org>

diff --git a/vcl/source/gdi/pdfwriter_impl.cxx 
b/vcl/source/gdi/pdfwriter_impl.cxx
index fe93cabe0897..2f74cfa474e2 100644
--- a/vcl/source/gdi/pdfwriter_impl.cxx
+++ b/vcl/source/gdi/pdfwriter_impl.cxx
@@ -9804,16 +9804,6 @@ 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 a9b2a1238000..54ff2201ead9 100644
--- a/vcl/source/gdi/pdfwriter_impl2.cxx
+++ b/vcl/source/gdi/pdfwriter_impl2.cxx
@@ -763,7 +763,15 @@ void PDFWriterImpl::playMetafile( const GDIMetaFile& 
i_rMtf, vcl::PDFExtOutDevDa
                 {
                     const MetaBmpExAction*  pA = static_cast<const 
MetaBmpExAction*>(pAction);
 
-                    const BitmapEx& aBitmapEx( pA->GetBitmapEx() );
+                    // 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);
+                    }
 
                     Size aSize( OutputDevice::LogicToLogic( 
aBitmapEx.GetPrefSize(),
                             aBitmapEx.GetPrefMapMode(), 
pDummyVDev->GetMapMode() ) );
@@ -776,8 +784,18 @@ 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(), 
pA->GetBitmapEx(), aGraphic, pDummyVDev, i_rContext );
+                    implWriteBitmapEx( pA->GetPoint(), pA->GetSize(), 
aBitmapEx, aGraphic, pDummyVDev, i_rContext );
                 }
                 break;
 
@@ -785,7 +803,15 @@ 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();

Reply via email to