desktop/source/lib/init.cxx                                  |    2 -
 drawinglayer/source/primitive2d/graphicprimitivehelper2d.cxx |    4 +-
 forms/source/component/imgprod.cxx                           |    4 +-
 slideshow/source/engine/shapes/gdimtftools.cxx               |    2 -
 vcl/source/bitmap/dibtools.cxx                               |   22 +----------
 vcl/source/filter/egif/egif.cxx                              |    2 -
 vcl/source/filter/eps/eps.cxx                                |    8 ++--
 vcl/source/filter/wmf/emfwr.cxx                              |    6 +--
 vcl/source/filter/wmf/wmfwr.cxx                              |    6 +--
 9 files changed, 20 insertions(+), 36 deletions(-)

New commits:
commit 1c7cbd685633d44eac554629572f3401c450f855
Author:     Noel Grandin <noel.gran...@collabora.co.uk>
AuthorDate: Sun May 7 16:56:21 2023 +0200
Commit:     Noel Grandin <noel.gran...@collabora.co.uk>
CommitDate: Sun May 7 20:17:16 2023 +0200

    use AlphaMask for variables when calling GetAlphaMask
    
    Right now this doesn't make any difference, since Bitmap is the
    superclass of AlphaMask.
    But when I switch to using alpha instead of transparency, passing
    AlphaMask around is going to mean something different to passing plain
    Bitmap around.
    
    Change-Id: Ic1541e5f0a3b97331793cd23e23115faa7f382b0
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/151463
    Tested-by: Jenkins
    Reviewed-by: Noel Grandin <noel.gran...@collabora.co.uk>

diff --git a/desktop/source/lib/init.cxx b/desktop/source/lib/init.cxx
index d6ce62b38be4..7cd3304a2185 100644
--- a/desktop/source/lib/init.cxx
+++ b/desktop/source/lib/init.cxx
@@ -3944,7 +3944,7 @@ static void doc_paintTile(LibreOfficeKitDocument* pThis,
     pDevice->EnableMapMode(false);
     BitmapEx aBmpEx = pDevice->GetBitmapEx({ 0, 0 }, { nCanvasWidth, 
nCanvasHeight });
     Bitmap aBmp = aBmpEx.GetBitmap();
-    Bitmap aAlpha = aBmpEx.GetAlphaMask();
+    AlphaMask aAlpha = aBmpEx.GetAlphaMask();
     Bitmap::ScopedReadAccess sraBmp(aBmp);
     Bitmap::ScopedReadAccess sraAlpha(aAlpha);
 
diff --git a/drawinglayer/source/primitive2d/graphicprimitivehelper2d.cxx 
b/drawinglayer/source/primitive2d/graphicprimitivehelper2d.cxx
index 8e0c8a980f33..a95df2474744 100644
--- a/drawinglayer/source/primitive2d/graphicprimitivehelper2d.cxx
+++ b/drawinglayer/source/primitive2d/graphicprimitivehelper2d.cxx
@@ -257,7 +257,7 @@ namespace drawinglayer::primitive2d
                         case Disposal::Not:
                         {
                             
maVirtualDevice->DrawBitmapEx(rAnimationFrame.maPositionPixel, 
rAnimationFrame.maBitmapEx);
-                            Bitmap aAlphaMask = 
rAnimationFrame.maBitmapEx.GetAlphaMask();
+                            AlphaMask aAlphaMask = 
rAnimationFrame.maBitmapEx.GetAlphaMask();
 
                             if (aAlphaMask.IsEmpty())
                             {
@@ -277,7 +277,7 @@ namespace drawinglayer::primitive2d
                         case Disposal::Back:
                         {
                             // #i70772# react on no mask, for primitives, too.
-                            const Bitmap & 
rMask(rAnimationFrame.maBitmapEx.GetAlphaMask());
+                            const AlphaMask & 
rMask(rAnimationFrame.maBitmapEx.GetAlphaMask());
                             const Bitmap & 
rContent(rAnimationFrame.maBitmapEx.GetBitmap());
 
                             maVirtualDeviceMask->Erase();
diff --git a/forms/source/component/imgprod.cxx 
b/forms/source/component/imgprod.cxx
index faa8663a2461..46439682519f 100644
--- a/forms/source/component/imgprod.cxx
+++ b/forms/source/component/imgprod.cxx
@@ -366,7 +366,7 @@ void ImageProducer::ImplUpdateConsumer( const Graphic& 
rGraphic )
     if( !pBmpAcc )
         return;
 
-    Bitmap              aMask( aBmpEx.GetAlphaMask() );
+    AlphaMask              aMask( aBmpEx.GetAlphaMask() );
     BitmapReadAccess*   pMskAcc = !aMask.IsEmpty() ? aMask.AcquireReadAccess() 
: nullptr;
     const tools::Long          nWidth = pBmpAcc->Width();
     const tools::Long          nHeight = pBmpAcc->Height();
@@ -380,7 +380,7 @@ void ImageProducer::ImplUpdateConsumer( const Graphic& 
rGraphic )
     if( !pMskAcc )
     {
         aMask = Bitmap(aBmp.GetSizePixel(), vcl::PixelFormat::N8_BPP, 
&Bitmap::GetGreyPalette(256));
-        aMask.Erase( COL_BLACK );
+        aMask.Erase( 0 );
         pMskAcc = aMask.AcquireReadAccess();
     }
 
diff --git a/slideshow/source/engine/shapes/gdimtftools.cxx 
b/slideshow/source/engine/shapes/gdimtftools.cxx
index 0c9e432850c6..990d9d26caac 100644
--- a/slideshow/source/engine/shapes/gdimtftools.cxx
+++ b/slideshow/source/engine/shapes/gdimtftools.cxx
@@ -283,7 +283,7 @@ bool getAnimationFromGraphic( VectorOfMtfAnimationFrames&   
o_rFrames,
             {
                 pVDev->DrawBitmapEx(rAnimationFrame.maPositionPixel,
                                     rAnimationFrame.maBitmapEx);
-                Bitmap aMask = rAnimationFrame.maBitmapEx.GetAlphaMask();
+                AlphaMask aMask = rAnimationFrame.maBitmapEx.GetAlphaMask();
 
                 if( aMask.IsEmpty() )
                 {
diff --git a/vcl/source/filter/egif/egif.cxx b/vcl/source/filter/egif/egif.cxx
index f908b6235133..8da427a86c19 100644
--- a/vcl/source/filter/egif/egif.cxx
+++ b/vcl/source/filter/egif/egif.cxx
@@ -242,7 +242,7 @@ bool GIFWriter::CreateAccess( const BitmapEx& rBmpEx )
 {
     if( bStatus )
     {
-        Bitmap aMask( rBmpEx.GetAlphaMask() );
+        AlphaMask aMask( rBmpEx.GetAlphaMask() );
 
         aAccBmp = rBmpEx.GetBitmap();
         bTransparent = false;
diff --git a/vcl/source/filter/eps/eps.cxx b/vcl/source/filter/eps/eps.cxx
index 8a4c140ee82d..455e89cc543a 100644
--- a/vcl/source/filter/eps/eps.cxx
+++ b/vcl/source/filter/eps/eps.cxx
@@ -819,7 +819,7 @@ void PSWriter::ImplWriteActions( const GDIMetaFile& rMtf, 
VirtualDevice& rVDev )
                 Bitmap aBitmap( aBitmapEx.GetBitmap() );
                 if ( mbGrayScale )
                     aBitmap.Convert( BmpConversion::N8BitGreys );
-                Bitmap aMask( aBitmapEx.GetAlphaMask() );
+                AlphaMask aMask( aBitmapEx.GetAlphaMask() );
                 Point aPoint( static_cast<const 
MetaBmpExAction*>(pMA)->GetPoint() );
                 Size aSize( rVDev.PixelToLogic( aBitmap.GetSizePixel() ) );
                 ImplBmp( &aBitmap, &aMask, aPoint, aSize.Width(), 
aSize.Height() );
@@ -832,7 +832,7 @@ void PSWriter::ImplWriteActions( const GDIMetaFile& rMtf, 
VirtualDevice& rVDev )
                 Bitmap aBitmap( aBitmapEx.GetBitmap() );
                 if ( mbGrayScale )
                     aBitmap.Convert( BmpConversion::N8BitGreys );
-                Bitmap aMask( aBitmapEx.GetAlphaMask() );
+                AlphaMask aMask( aBitmapEx.GetAlphaMask() );
                 Point aPoint = static_cast<const 
MetaBmpExScaleAction*>(pMA)->GetPoint();
                 Size aSize( static_cast<const 
MetaBmpExScaleAction*>(pMA)->GetSize() );
                 ImplBmp( &aBitmap, &aMask, aPoint, aSize.Width(), 
aSize.Height() );
@@ -847,7 +847,7 @@ void PSWriter::ImplWriteActions( const GDIMetaFile& rMtf, 
VirtualDevice& rVDev )
                 Bitmap      aBitmap( aBitmapEx.GetBitmap() );
                 if ( mbGrayScale )
                     aBitmap.Convert( BmpConversion::N8BitGreys );
-                Bitmap      aMask( aBitmapEx.GetAlphaMask() );
+                AlphaMask   aMask( aBitmapEx.GetAlphaMask() );
                 Point aPoint = static_cast<const 
MetaBmpExScalePartAction*>(pMA)->GetDestPoint();
                 Size aSize = static_cast<const 
MetaBmpExScalePartAction*>(pMA)->GetDestSize();
                 ImplBmp( &aBitmap, &aMask, aPoint, aSize.Width(), 
aSize.Height() );
@@ -907,7 +907,7 @@ void PSWriter::ImplWriteActions( const GDIMetaFile& rMtf, 
VirtualDevice& rVDev )
                         // gradient action
 
                         }
-                        Bitmap aMask( aBitmapEx.GetAlphaMask() );
+                        AlphaMask aMask( aBitmapEx.GetAlphaMask() );
                         ImplBmp( &aBitmap, &aMask, Point( aRect.Left(), 
aRect.Top() ), aRect.GetWidth(), aRect.GetHeight() );
                     }
                     else
diff --git a/vcl/source/filter/wmf/emfwr.cxx b/vcl/source/filter/wmf/emfwr.cxx
index cb717559fe84..74ee7462bb6a 100644
--- a/vcl/source/filter/wmf/emfwr.cxx
+++ b/vcl/source/filter/wmf/emfwr.cxx
@@ -1294,7 +1294,7 @@ void EMFWriter::ImplWrite( const GDIMetaFile& rMtf )
             {
                 const MetaBmpExAction*  pA = static_cast<const MetaBmpExAction 
*>(pAction);
                 Bitmap                  aBmp( pA->GetBitmapEx().GetBitmap() );
-                Bitmap                  aMsk( pA->GetBitmapEx().GetAlphaMask() 
);
+                AlphaMask               aMsk( pA->GetBitmapEx().GetAlphaMask() 
);
 
                 if( !aMsk.IsEmpty() )
                 {
@@ -1312,7 +1312,7 @@ void EMFWriter::ImplWrite( const GDIMetaFile& rMtf )
             {
                 const MetaBmpExScaleAction* pA = static_cast<const 
MetaBmpExScaleAction*>(pAction);
                 Bitmap                      aBmp( 
pA->GetBitmapEx().GetBitmap() );
-                Bitmap                      aMsk( 
pA->GetBitmapEx().GetAlphaMask() );
+                AlphaMask                   aMsk( 
pA->GetBitmapEx().GetAlphaMask() );
 
                 if( !aMsk.IsEmpty() )
                 {
@@ -1332,7 +1332,7 @@ void EMFWriter::ImplWrite( const GDIMetaFile& rMtf )
                 BitmapEx                        aBmpEx( pA->GetBitmapEx() );
                 aBmpEx.Crop( tools::Rectangle( pA->GetSrcPoint(), 
pA->GetSrcSize() ) );
                 Bitmap                          aBmp( aBmpEx.GetBitmap() );
-                Bitmap                          aMsk( aBmpEx.GetAlphaMask() );
+                AlphaMask                       aMsk( aBmpEx.GetAlphaMask() );
 
                 if( !aMsk.IsEmpty() )
                 {
diff --git a/vcl/source/filter/wmf/wmfwr.cxx b/vcl/source/filter/wmf/wmfwr.cxx
index 124ea571dc3d..7afc3a62fa73 100644
--- a/vcl/source/filter/wmf/wmfwr.cxx
+++ b/vcl/source/filter/wmf/wmfwr.cxx
@@ -1245,7 +1245,7 @@ void WMFWriter::WriteRecords( const GDIMetaFile & rMTF )
             {
                 const MetaBmpExAction*  pA = static_cast<const MetaBmpExAction 
*>(pMA);
                 Bitmap                  aBmp( pA->GetBitmapEx().GetBitmap() );
-                Bitmap                  aMsk( pA->GetBitmapEx().GetAlphaMask() 
);
+                AlphaMask               aMsk( pA->GetBitmapEx().GetAlphaMask() 
);
 
                 if( !aMsk.IsEmpty() )
                 {
@@ -1263,7 +1263,7 @@ void WMFWriter::WriteRecords( const GDIMetaFile & rMTF )
             {
                 const MetaBmpExScaleAction* pA = static_cast<const 
MetaBmpExScaleAction*>(pMA);
                 Bitmap                      aBmp( 
pA->GetBitmapEx().GetBitmap() );
-                Bitmap                      aMsk( 
pA->GetBitmapEx().GetAlphaMask() );
+                AlphaMask                   aMsk( 
pA->GetBitmapEx().GetAlphaMask() );
 
                 if( !aMsk.IsEmpty() )
                 {
@@ -1283,7 +1283,7 @@ void WMFWriter::WriteRecords( const GDIMetaFile & rMTF )
                 BitmapEx                        aBmpEx( pA->GetBitmapEx() );
                 aBmpEx.Crop( tools::Rectangle( pA->GetSrcPoint(), 
pA->GetSrcSize() ) );
                 Bitmap                          aBmp( aBmpEx.GetBitmap() );
-                Bitmap                          aMsk( aBmpEx.GetAlphaMask() );
+                AlphaMask                       aMsk( aBmpEx.GetAlphaMask() );
 
                 if( !aMsk.IsEmpty() )
                 {
commit 918012d94cf9419318e66aaa489a75e56f81074f
Author:     Noel Grandin <noel.gran...@collabora.co.uk>
AuthorDate: Sun May 7 16:08:40 2023 +0200
Commit:     Noel Grandin <noel.gran...@collabora.co.uk>
CommitDate: Sun May 7 20:17:06 2023 +0200

    simplify code
    
    The BitmapEx constructor already does this check, no need to do it here
    
    Change-Id: Iacd0e1b1d4aa3dfae120e0d4a60a6924ecd9f778
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/151460
    Tested-by: Jenkins
    Reviewed-by: Noel Grandin <noel.gran...@collabora.co.uk>

diff --git a/vcl/source/bitmap/dibtools.cxx b/vcl/source/bitmap/dibtools.cxx
index 78732a43f17a..c95c21704dd9 100644
--- a/vcl/source/bitmap/dibtools.cxx
+++ b/vcl/source/bitmap/dibtools.cxx
@@ -1670,25 +1670,9 @@ bool ReadDIBBitmapEx(
 
                         bRetval = ImplReadDIB(aMask, nullptr, rIStm, true);
 
-                        if(bRetval)
-                        {
-                            if(!aMask.IsEmpty())
-                            {
-                                // do we have an alpha mask?
-                                if (aMask.getPixelFormat() == 
vcl::PixelFormat::N8_BPP && aMask.HasGreyPalette8Bit())
-                                {
-                                    AlphaMask aAlpha;
-
-                                    // create alpha mask quickly (without 
greyscale conversion)
-                                    aAlpha.ImplSetBitmap(aMask);
-                                    rTarget = BitmapEx(aBmp, aAlpha);
-                                }
-                                else
-                                {
-                                    rTarget = BitmapEx(aBmp, aMask);
-                                }
-                            }
-                        }
+                        if(bRetval && !aMask.IsEmpty())
+                            rTarget = BitmapEx(aBmp, aMask);
+
                         break;
                     }
                 case 1: // backwards compat for old option 
TransparentType::Color

Reply via email to