filter/source/msfilter/mstoolbar.cxx  |    2 
 include/filter/msfilter/mstoolbar.hxx |    4 -
 include/vcl/dibtools.hxx              |    6 ++
 vcl/source/bitmap/dibtools.cxx        |   72 ++++++++++++++++++++++++++++++++++
 4 files changed, 81 insertions(+), 3 deletions(-)

New commits:
commit 3846485ba75c5f73fac4ab3e5bd7de582ced673b
Author:     Noel Grandin <[email protected]>
AuthorDate: Wed Jul 30 15:32:40 2025 +0200
Commit:     Noel Grandin <[email protected]>
CommitDate: Thu Jul 31 14:13:38 2025 +0200

    BitmapEx->Bitmap in TBCBitMap
    
    now that Bitmap can handle transparency
    
    Change-Id: I4d1c68b1930682fb558dde1f46658c4107f00282
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/188615
    Tested-by: Jenkins
    Reviewed-by: Noel Grandin <[email protected]>

diff --git a/filter/source/msfilter/mstoolbar.cxx 
b/filter/source/msfilter/mstoolbar.cxx
index 9db38c4bd030..ac603881a8a1 100644
--- a/filter/source/msfilter/mstoolbar.cxx
+++ b/filter/source/msfilter/mstoolbar.cxx
@@ -296,7 +296,7 @@ void TBCData::ImportToolBarControl( 
CustomToolBarImportHelper& helper, std::vect
                     TBCBitMap* pIconMask = pSpecificInfo->getIconMask();
                     if (pIconMask)
                     {
-                        const Bitmap& 
rMaskBase(pIconMask->getBitMap().GetBitmap());
+                        const Bitmap& rMaskBase(pIconMask->getBitMap());
                         Size aMaskSize = rMaskBase.GetSizePixel();
                         if (aMaskSize.Width() && aMaskSize.Height())
                         {
diff --git a/include/filter/msfilter/mstoolbar.hxx 
b/include/filter/msfilter/mstoolbar.hxx
index 46966d6482a2..5a6bcba0ed07 100644
--- a/include/filter/msfilter/mstoolbar.hxx
+++ b/include/filter/msfilter/mstoolbar.hxx
@@ -161,7 +161,7 @@ class TBCBitMap final : public TBBase
 {
 friend class TBCBSpecific; // #FIXME hacky access, need to fix
     sal_Int32 cbDIB;
-    BitmapEx mBitMap;
+    Bitmap mBitMap;
 public:
     TBCBitMap();
     virtual ~TBCBitMap() override;
@@ -170,7 +170,7 @@ public:
     virtual void Print( FILE* ) override;
 #endif
    // #FIXME Const-ness
-    BitmapEx& getBitMap() { return mBitMap;}
+    Bitmap& getBitMap() { return mBitMap;}
 };
 
 class MSFILTER_DLLPUBLIC TBCMenuSpecific final : public TBBase
diff --git a/include/vcl/dibtools.hxx b/include/vcl/dibtools.hxx
index 6064491f8ec3..4701f358de6b 100644
--- a/include/vcl/dibtools.hxx
+++ b/include/vcl/dibtools.hxx
@@ -49,6 +49,12 @@ bool VCL_DLLPUBLIC ReadDIBBitmapEx(
     bool bFileHeader = true,
     bool bMSOFormat = false);
 
+bool VCL_DLLPUBLIC ReadDIBBitmapEx(
+    Bitmap& rTarget,
+    SvStream& rIStm,
+    bool bFileHeader = true,
+    bool bMSOFormat = false);
+
 bool VCL_DLLPUBLIC ReadDIBV5(
     Bitmap& rTarget,
     AlphaMask& rTargetAlpha,
diff --git a/vcl/source/bitmap/dibtools.cxx b/vcl/source/bitmap/dibtools.cxx
index febcab971b86..de46597b9ebc 100644
--- a/vcl/source/bitmap/dibtools.cxx
+++ b/vcl/source/bitmap/dibtools.cxx
@@ -1681,6 +1681,78 @@ bool ReadDIBBitmapEx(
     return bRetval;
 }
 
+bool ReadDIBBitmapEx(
+    Bitmap& rTarget,
+    SvStream& rIStm,
+    bool bFileHeader,
+    bool bMSOFormat)
+{
+    Bitmap aBmp;
+    if (!ImplReadDIB(aBmp, nullptr, rIStm, bFileHeader, bMSOFormat) && 
!rIStm.GetError())
+        return false;
+
+    // base bitmap was read, set as return value and try to read alpha 
extra-data
+    const sal_uInt64 nStmPos(rIStm.Tell());
+    sal_uInt32 nMagic1(0);
+    sal_uInt32 nMagic2(0);
+
+    rTarget = aBmp;
+    if (rIStm.remainingSize() >= 4)
+        rIStm.ReadUInt32( nMagic1 ).ReadUInt32( nMagic2 );
+    bool bRetval = (0x25091962 == nMagic1) && (0xACB20201 == nMagic2) && 
!rIStm.GetError();
+
+    if(bRetval)
+    {
+        sal_uInt8 tmp = 0;
+        rIStm.ReadUChar( tmp );
+        bRetval = !rIStm.GetError();
+
+        if(bRetval)
+        {
+            switch (tmp)
+            {
+            case 2: // TransparentType::Bitmap
+                {
+                    Bitmap aMask;
+
+                    bRetval = ImplReadDIB(aMask, nullptr, rIStm, true);
+
+                    if(bRetval && !aMask.IsEmpty())
+                        rTarget = Bitmap(BitmapEx(aBmp, aMask));
+
+                    break;
+                }
+            case 1: // backwards compat for old option TransparentType::Color
+                {
+                    Color aTransparentColor;
+
+                    tools::GenericTypeSerializer aSerializer(rIStm);
+                    aSerializer.readColor(aTransparentColor);
+
+                    bRetval = rIStm.good();
+
+                    if(bRetval)
+                    {
+                        rTarget = Bitmap(BitmapEx(aBmp, aTransparentColor));
+                    }
+                    break;
+                }
+            default: break;
+            }
+        }
+    }
+
+    if(!bRetval)
+    {
+        // alpha extra data could not be read; reset, but use base bitmap as 
result
+        rIStm.ResetError();
+        rIStm.Seek(nStmPos);
+        bRetval = true;
+    }
+
+    return bRetval;
+}
+
 bool ReadDIBV5(
     Bitmap& rTarget,
     AlphaMask& rTargetAlpha,

Reply via email to