forms/source/component/imgprod.cxx |   40 +++----------------------------
 include/vcl/bitmap.hxx             |    8 ++++++
 vcl/source/bitmap/bitmap.cxx       |   47 +++++++++++++++++++++++++++++++++++++
 3 files changed, 60 insertions(+), 35 deletions(-)

New commits:
commit 3e43f0ed2713c0730fa3f4a0e6813ff80b6d8a48
Author:     Noel Grandin <noel.gran...@collabora.co.uk>
AuthorDate: Wed Aug 27 11:43:27 2025 +0200
Commit:     Noel Grandin <noel.gran...@collabora.co.uk>
CommitDate: Wed Aug 27 14:47:20 2025 +0200

    BitmapEx->Bitmap in forms
    
    since Bitmap can handle transparency now.
    
    Drop some code - we no longer have images with palettes and transparency
    
    Change-Id: I480765e0e402e67485a53c660e1179a9d7c5b153
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/190282
    Tested-by: Jenkins
    Reviewed-by: Noel Grandin <noel.gran...@collabora.co.uk>

diff --git a/forms/source/component/imgprod.cxx 
b/forms/source/component/imgprod.cxx
index 7ea05d743ac1..5e0378d0e0c1 100644
--- a/forms/source/component/imgprod.cxx
+++ b/forms/source/component/imgprod.cxx
@@ -222,7 +222,7 @@ void ImageProducer::ImplInitConsumer( const Graphic& 
rGraphic )
     sal_uInt32 nHeight = 0;
     sal_uInt8 nBitCount = 0;
     css::uno::Sequence< sal_Int32 > aRGBPal;
-    rGraphic.GetBitmapEx().GetColorModel(aRGBPal, nRMask, nGMask, nBMask, 
nAMask, mnTransIndex, nWidth, nHeight, nBitCount);
+    rGraphic.GetBitmap().GetColorModel(aRGBPal, nRMask, nGMask, nBMask, 
nAMask, mnTransIndex, nWidth, nHeight, nBitCount);
 
     // create temporary list to hold interfaces
     ConsumerList_t aTmp = maConsList;
@@ -240,17 +240,11 @@ void ImageProducer::ImplInitConsumer( const Graphic& 
rGraphic )
 
 void ImageProducer::ImplUpdateConsumer( const Graphic& rGraphic )
 {
-    BitmapEx            aBmpEx( rGraphic.GetBitmapEx() );
-    const Bitmap&       aBmp( aBmpEx.GetBitmap() );
+    Bitmap            aBmp( rGraphic.GetBitmap() );
     BitmapScopedReadAccess pBmpAcc(aBmp);
-
     if( !pBmpAcc )
         return;
 
-    AlphaMask              aMask( aBmpEx.GetAlphaMask() );
-    BitmapScopedReadAccess pMskAcc;
-    if (!aMask.IsEmpty())
-        pMskAcc = aMask;
     const tools::Long          nWidth = pBmpAcc->Width();
     const tools::Long          nHeight = pBmpAcc->Height();
     const tools::Long          nStartX = 0;
@@ -260,20 +254,11 @@ void ImageProducer::ImplUpdateConsumer( const Graphic& 
rGraphic )
     const tools::Long          nPartWidth = nEndX - nStartX + 1;
     const tools::Long          nPartHeight = nEndY - nStartY + 1;
 
-    if( !pMskAcc )
-    {
-        aMask = AlphaMask(aBmp.GetSizePixel());
-        aMask.Erase( 0 );
-        pMskAcc = aMask;
-    }
-
     // create temporary list to hold interfaces
     ConsumerList_t aTmp = maConsList;
 
     if( pBmpAcc->HasPalette() )
     {
-        const BitmapColor aWhite( pMskAcc->GetBestMatchingColor( 
COL_ALPHA_TRANSPARENT ) );
-
         if( mnTransIndex < 256 )
         {
             css::uno::Sequence<sal_Int8>   aData( nPartWidth * nPartHeight );
@@ -281,16 +266,9 @@ void ImageProducer::ImplUpdateConsumer( const Graphic& 
rGraphic )
 
             for( tools::Long nY = nStartY; nY <= nEndY; nY++ )
             {
-                Scanline pScanlineMask = pMskAcc->GetScanline( nY );
                 Scanline pScanline = pBmpAcc->GetScanline( nY );
                 for( tools::Long nX = nStartX; nX <= nEndX; nX++ )
-                {
-                    if( pMskAcc->GetPixelFromData( pScanlineMask, nX ) == 
aWhite )
-                        *pTmp++ = sal::static_int_cast< sal_Int8 >(
-                            mnTransIndex );
-                    else
-                        *pTmp++ = pBmpAcc->GetPixelFromData( pScanline, nX 
).GetIndex();
-                }
+                    *pTmp++ = pBmpAcc->GetPixelFromData( pScanline, nX 
).GetIndex();
             }
 
             // iterate through interfaces
@@ -304,15 +282,9 @@ void ImageProducer::ImplUpdateConsumer( const Graphic& 
rGraphic )
 
             for( tools::Long nY = nStartY; nY <= nEndY; nY++ )
             {
-                Scanline pScanlineMask = pMskAcc->GetScanline( nY );
                 Scanline pScanline = pBmpAcc->GetScanline( nY );
                 for( tools::Long nX = nStartX; nX <= nEndX; nX++ )
-                {
-                    if( pMskAcc->GetPixelFromData( pScanlineMask, nX ) == 
aWhite )
-                        *pTmp++ = mnTransIndex;
-                    else
-                        *pTmp++ = pBmpAcc->GetPixelFromData( pScanline, nX 
).GetIndex();
-                }
+                    *pTmp++ = pBmpAcc->GetPixelFromData( pScanline, nX 
).GetIndex();
             }
 
             // iterate through interfaces
@@ -323,12 +295,10 @@ void ImageProducer::ImplUpdateConsumer( const Graphic& 
rGraphic )
     else
     {
         css::uno::Sequence<sal_Int32>  aData( nPartWidth * nPartHeight );
-        const BitmapColor                           aWhite( 
pMskAcc->GetBestMatchingColor( COL_WHITE ) );
         sal_Int32*                                  pTmp = aData.getArray();
 
         for( tools::Long nY = nStartY; nY <= nEndY; nY++ )
         {
-            Scanline pScanlineMask = pMskAcc->GetScanline( nY );
             Scanline pScanline = pBmpAcc->GetScanline( nY );
             for( tools::Long nX = nStartX; nX <= nEndX; nX++, pTmp++ )
             {
@@ -338,7 +308,7 @@ void ImageProducer::ImplUpdateConsumer( const Graphic& 
rGraphic )
                 *pTmp |= static_cast<sal_Int32>(aCol.GetGreen()) << 16;
                 *pTmp |= static_cast<sal_Int32>(aCol.GetBlue()) << 8;
 
-                if( pMskAcc->GetPixelFromData( pScanlineMask, nX ) != aWhite )
+                if( aCol.GetAlpha() != 0 )
                     *pTmp |= 0x000000ffUL;
             }
         }
diff --git a/include/vcl/bitmap.hxx b/include/vcl/bitmap.hxx
index 8788a718f001..d46c9538e4d0 100644
--- a/include/vcl/bitmap.hxx
+++ b/include/vcl/bitmap.hxx
@@ -32,6 +32,7 @@
 #include <vcl/bitmap/BitmapTypes.hxx>
 
 #include <o3tl/typed_flags_set.hxx>
+#include <com/sun/star/uno/Sequence.hxx>
 
 #include <algorithm>
 #include <memory>
@@ -598,6 +599,13 @@ public:
 
     void CombineMaskOr(Color maskColor, sal_uInt8 nTol);
 
+    /**
+     * Retrieves the color model data we need for the XImageConsumer stuff.
+     */
+    void                GetColorModel(css::uno::Sequence< sal_Int32 >& 
rRGBPalette,
+                            sal_uInt32& rnRedMask, sal_uInt32& rnGreenMask, 
sal_uInt32& rnBlueMask, sal_uInt32& rnAlphaMask, sal_uInt32& 
rnTransparencyIndex,
+                            sal_uInt32& rnWidth, sal_uInt32& rnHeight, 
sal_uInt8& rnBitCount);
+
     /** Remove existing blending against COL_WHITE based on given AlphaMask
 
         Inside convertToBitmapEx the content gets rendered to RGB target (no 
'A'),
diff --git a/vcl/source/bitmap/bitmap.cxx b/vcl/source/bitmap/bitmap.cxx
index e5d8f81a8102..0a0d201826b8 100644
--- a/vcl/source/bitmap/bitmap.cxx
+++ b/vcl/source/bitmap/bitmap.cxx
@@ -2397,4 +2397,51 @@ void Bitmap::CombineMaskOr(Color rTransColor, sal_uInt8 
nTol)
     maPrefSize = aSize;
 }
 
+/**
+ * Retrieves the color model data we need for the XImageConsumer stuff.
+ */
+void  Bitmap::GetColorModel(css::uno::Sequence< sal_Int32 >& rRGBPalette,
+        sal_uInt32& rnRedMask, sal_uInt32& rnGreenMask, sal_uInt32& 
rnBlueMask, sal_uInt32& rnAlphaMask, sal_uInt32& rnTransparencyIndex,
+        sal_uInt32& rnWidth, sal_uInt32& rnHeight, sal_uInt8& rnBitCount)
+{
+    BitmapScopedReadAccess pReadAccess( *this );
+    assert( pReadAccess );
+
+    if( pReadAccess->HasPalette() )
+    {
+        sal_uInt16 nPalCount = pReadAccess->GetPaletteEntryCount();
+
+        if( nPalCount )
+        {
+            rRGBPalette = css::uno::Sequence< sal_Int32 >( nPalCount + 1 );
+
+            sal_Int32* pTmp = rRGBPalette.getArray();
+
+            for( sal_uInt32 i = 0; i < nPalCount; i++, pTmp++ )
+            {
+                const BitmapColor& rCol = pReadAccess->GetPaletteColor( 
static_cast<sal_uInt16>(i) );
+
+                *pTmp = static_cast<sal_Int32>(rCol.GetRed()) << sal_Int32(24);
+                *pTmp |= static_cast<sal_Int32>(rCol.GetGreen()) << 
sal_Int32(16);
+                *pTmp |= static_cast<sal_Int32>(rCol.GetBlue()) << 
sal_Int32(8);
+                *pTmp |= sal_Int32(0x000000ffL);
+            }
+
+            rnTransparencyIndex = 0;
+        }
+    }
+    else
+    {
+        rnRedMask = 0xff000000UL;
+        rnGreenMask = 0x00ff0000UL;
+        rnBlueMask = 0x0000ff00UL;
+        rnAlphaMask = 0x000000ffUL;
+        rnTransparencyIndex = 0;
+    }
+
+    rnWidth = pReadAccess->Width();
+    rnHeight = pReadAccess->Height();
+    rnBitCount = pReadAccess->GetBitCount();
+}
+
 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Reply via email to