[Libreoffice-commits] core.git: 2 commits - include/svx include/vcl svx/source vcl/source

Noel Grandin (via logerrit) logerrit at kemper.freedesktop.org
Thu Jul 4 07:18:50 UTC 2019


 include/svx/bmpmask.hxx        |    4 ---
 include/vcl/bitmapex.hxx       |   31 ++++++++++++++++++++++++++--
 svx/source/dialog/_bmpmask.cxx |   44 ++++++++---------------------------------
 vcl/source/gdi/bitmapex.cxx    |   21 +++++++++++++++++++
 4 files changed, 59 insertions(+), 41 deletions(-)

New commits:
commit e27be9dfbcf8636a7440f828435b1860dfa38977
Author:     Noel Grandin <noel.grandin at collabora.co.uk>
AuthorDate: Wed Jul 3 15:07:44 2019 +0200
Commit:     Noel Grandin <noel.grandin at collabora.co.uk>
CommitDate: Thu Jul 4 09:18:22 2019 +0200

    move some Bitmap replace logic inside vcl
    
    i.e. behind BitmapEx
    
    Change-Id: Ibe5a20ffe127acf7fb5bcf6341dcd046371aa761
    Reviewed-on: https://gerrit.libreoffice.org/75044
    Tested-by: Jenkins
    Reviewed-by: Noel Grandin <noel.grandin at collabora.co.uk>

diff --git a/include/svx/bmpmask.hxx b/include/svx/bmpmask.hxx
index 05420369ca35..1d75ccf094bd 100644
--- a/include/svx/bmpmask.hxx
+++ b/include/svx/bmpmask.hxx
@@ -132,7 +132,7 @@ class SAL_WARN_UNUSED SVX_DLLPUBLIC SvxBmpMask : public SfxDockingWindow
     sal_uInt16          InitColorArrays( Color* pSrcCols, Color* pDstCols,
                                          sal_uInt8* pTols );
 
-    Bitmap              ImpMask( const Bitmap& rBitmap );
+    void                ImpMask( BitmapEx& rBitmap );
     GDIMetaFile         ImpMask( const GDIMetaFile& rMtf );
     Animation           ImpMask( const Animation& rAnimation );
     BitmapEx            ImpMaskTransparent( const BitmapEx& rBitmapEx,
diff --git a/include/vcl/bitmapex.hxx b/include/vcl/bitmapex.hxx
index 5f8a41f1ed20..2abbddd2e3c7 100644
--- a/include/vcl/bitmapex.hxx
+++ b/include/vcl/bitmapex.hxx
@@ -291,6 +291,30 @@ public:
                             const Color* pReplaceColors,
                             sal_uLong nColorCount );
 
+    /** Replace all pixel having one the search colors with the corresponding replace color
+
+        @param pSearchColors
+        Array of colors specifying which pixel should be replaced
+
+        @param rReplaceColors
+        Array of colors to be placed in all changed pixel
+
+        @param nColorCount
+        Size of the aforementioned color arrays
+
+        @param pTols
+        Tolerance value. Specifies the maximal difference between
+        pSearchColor colors and the individual pixel values, such that
+        the corresponding pixel is still regarded a match.
+
+        @return true, if the operation was completed successfully.
+     */
+    void                Replace(
+                            const Color* pSearchColors,
+                            const Color* pReplaceColors,
+                            sal_uLong nColorCount,
+                            sal_uInt8 const * pTols );
+
     /** Replace transparency with given color.
      */
     void                ReplaceTransparency( const Color& rColor );
diff --git a/svx/source/dialog/_bmpmask.cxx b/svx/source/dialog/_bmpmask.cxx
index 1eb212f9f636..a37e3e8c4693 100644
--- a/svx/source/dialog/_bmpmask.cxx
+++ b/svx/source/dialog/_bmpmask.cxx
@@ -608,19 +608,16 @@ sal_uInt16 SvxBmpMask::InitColorArrays( Color* pSrcCols, Color* pDstCols, sal_uI
     return nCount;
 }
 
-Bitmap SvxBmpMask::ImpMask( const Bitmap& rBitmap )
+void SvxBmpMask::ImpMask( BitmapEx& rBitmap )
 {
-    Bitmap          aBitmap( rBitmap );
     Color           pSrcCols[4];
     Color           pDstCols[4];
     sal_uInt8       pTols[4];
     const sal_uInt16 nCount = InitColorArrays( pSrcCols, pDstCols, pTols );
 
     EnterWait();
-    aBitmap.Replace( pSrcCols, pDstCols, nCount, pTols );
+    rBitmap.Replace( pSrcCols, pDstCols, nCount, pTols );
     LeaveWait();
-
-    return aBitmap;
 }
 
 BitmapEx SvxBmpMask::ImpMaskTransparent( const BitmapEx& rBitmapEx, const Color& rColor, const sal_uInt8 nTol )
@@ -1006,15 +1003,10 @@ Graphic SvxBmpMask::Mask( const Graphic& rGraphic )
                         }
 
                         // now replace it again with the normal colors
-                        Bitmap  aBitmap( ImpMask( aGraphic.GetBitmapEx().GetBitmap() ) );
-                        Size    aSize( aBitmap.GetSizePixel() );
-
-                        if ( aSize.Width() && aSize.Height() )
+                        BitmapEx  aBitmapEx( aGraphic.GetBitmapEx() );
+                        if ( aBitmapEx.GetSizePixel().Width() && aBitmapEx.GetSizePixel().Height() )
                         {
-                            if ( aGraphic.IsTransparent() )
-                                aGraphic = Graphic( BitmapEx( aBitmap, aGraphic.GetBitmapEx().GetMask() ) );
-                            else
-                                aGraphic = aBitmap;
+                            ImpMask( aBitmapEx );
                         }
                     }
                 }
diff --git a/vcl/source/gdi/bitmapex.cxx b/vcl/source/gdi/bitmapex.cxx
index 06fe72f8cd25..3681e585ac84 100644
--- a/vcl/source/gdi/bitmapex.cxx
+++ b/vcl/source/gdi/bitmapex.cxx
@@ -1294,6 +1294,14 @@ void BitmapEx::Replace(const Color& rSearchColor,
     maBitmap.Replace(rSearchColor, rReplaceColor, nTolerance);
 }
 
+void BitmapEx::Replace( const Color* pSearchColors,
+                        const Color* pReplaceColors,
+                        sal_uLong nColorCount,
+                        sal_uInt8 const * pTols )
+{
+    maBitmap.Replace( pSearchColors, pReplaceColors, nColorCount, pTols );
+}
+
 void BitmapEx::ReplaceTransparency(const Color& rColor)
 {
     if( IsTransparent() )
commit 0ba0cfa9a0173a5cca9e230f980b9f4efde7a794
Author:     Noel Grandin <noel.grandin at collabora.co.uk>
AuthorDate: Wed Jul 3 14:50:53 2019 +0200
Commit:     Noel Grandin <noel.grandin at collabora.co.uk>
CommitDate: Thu Jul 4 09:18:09 2019 +0200

    move "replace transparency" logic inside vcl
    
    Change-Id: I7e6994ec6bf7f0c7380df36c49d0b05a9d27c673
    Reviewed-on: https://gerrit.libreoffice.org/75041
    Tested-by: Jenkins
    Reviewed-by: Noel Grandin <noel.grandin at collabora.co.uk>

diff --git a/include/svx/bmpmask.hxx b/include/svx/bmpmask.hxx
index 6020133cd1e7..05420369ca35 100644
--- a/include/svx/bmpmask.hxx
+++ b/include/svx/bmpmask.hxx
@@ -141,8 +141,6 @@ class SAL_WARN_UNUSED SVX_DLLPUBLIC SvxBmpMask : public SfxDockingWindow
 
     GDIMetaFile         GetMetaFile(const Graphic& rGraphic);
 
-    static BitmapEx     ImpReplaceTransparency( const BitmapEx& rBmpEx,
-                                                const Color& rColor );
     static Animation    ImpReplaceTransparency( const Animation& rAnim,
                                                 const Color& rColor );
     static GDIMetaFile  ImpReplaceTransparency( const GDIMetaFile& rMtf,
diff --git a/include/vcl/bitmapex.hxx b/include/vcl/bitmapex.hxx
index c6eb9cfca85a..5f8a41f1ed20 100644
--- a/include/vcl/bitmapex.hxx
+++ b/include/vcl/bitmapex.hxx
@@ -94,8 +94,6 @@ public:
     sal_uLong           GetSizeBytes() const;
     BitmapChecksum      GetChecksum() const;
 
-public:
-
     /**
      * @brief extract the bitmap and alpha data separately. Used by the SWF filter.
      */
@@ -293,6 +291,10 @@ public:
                             const Color* pReplaceColors,
                             sal_uLong nColorCount );
 
+    /** Replace transparency with given color.
+     */
+    void                ReplaceTransparency( const Color& rColor );
+
     /** Change various global color characteristics
 
         @param nLuminancePercent
@@ -430,7 +432,6 @@ public:
     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);
-public:
 
     SAL_DLLPRIVATE std::shared_ptr<SalBitmap> const & ImplGetBitmapSalBitmap() const { return maBitmap.ImplGetSalBitmap(); }
     SAL_DLLPRIVATE std::shared_ptr<SalBitmap> const & ImplGetMaskSalBitmap() const { return maMask.ImplGetSalBitmap(); }
diff --git a/svx/source/dialog/_bmpmask.cxx b/svx/source/dialog/_bmpmask.cxx
index b0a7b7de8458..1eb212f9f636 100644
--- a/svx/source/dialog/_bmpmask.cxx
+++ b/svx/source/dialog/_bmpmask.cxx
@@ -901,19 +901,6 @@ GDIMetaFile SvxBmpMask::ImpMask( const GDIMetaFile& rMtf )
 }
 
 
-BitmapEx SvxBmpMask::ImpReplaceTransparency( const BitmapEx& rBmpEx, const Color& rColor )
-{
-    if( rBmpEx.IsTransparent() )
-    {
-        Bitmap aBmp( rBmpEx.GetBitmap() );
-        aBmp.Replace( rBmpEx.GetMask(), rColor );
-        return BitmapEx(aBmp);
-    }
-    else
-        return rBmpEx;
-}
-
-
 Animation SvxBmpMask::ImpReplaceTransparency( const Animation& rAnim, const Color& rColor )
 {
     Animation   aAnimation( rAnim );
@@ -922,7 +909,7 @@ Animation SvxBmpMask::ImpReplaceTransparency( const Animation& rAnim, const Colo
     for( sal_uInt16 i = 0; i < nAnimationCount; i++ )
     {
         AnimationBitmap aAnimationBitmap(aAnimation.Get(i));
-        aAnimationBitmap.maBitmapEx = ImpReplaceTransparency(aAnimationBitmap.maBitmapEx, rColor);
+        aAnimationBitmap.maBitmapEx.ReplaceTransparency(rColor);
         aAnimation.Replace(aAnimationBitmap, i);
     }
 
@@ -990,14 +977,9 @@ Graphic SvxBmpMask::Mask( const Graphic& rGraphic )
                 // Replace transparency?
                 if( m_pCbxTrans->IsChecked() )
                 {
-                    if( aGraphic.IsTransparent() )
-                    {
-                        BitmapEx    aBmpEx( ImpReplaceTransparency( aGraphic.GetBitmapEx(), aReplColor ) );
-                        const Size  aSize( aBmpEx.GetSizePixel() );
-
-                        if( aSize.Width() && aSize.Height() )
-                            aGraphic = aBmpEx;
-                    }
+                    BitmapEx aBmpEx = aGraphic.GetBitmapEx();
+                    aBmpEx.ReplaceTransparency(aReplColor);
+                    aGraphic = aBmpEx;
                 }
                 else
                 {
diff --git a/vcl/source/gdi/bitmapex.cxx b/vcl/source/gdi/bitmapex.cxx
index e0c8596abe83..06fe72f8cd25 100644
--- a/vcl/source/gdi/bitmapex.cxx
+++ b/vcl/source/gdi/bitmapex.cxx
@@ -1294,6 +1294,19 @@ void BitmapEx::Replace(const Color& rSearchColor,
     maBitmap.Replace(rSearchColor, rReplaceColor, nTolerance);
 }
 
+void BitmapEx::ReplaceTransparency(const Color& rColor)
+{
+    if( IsTransparent() )
+    {
+        maBitmap.Replace( GetMask(), rColor );
+        maMask = Bitmap();
+        maBitmapSize = maBitmap.GetSizePixel();
+        maTransparentColor = Color();
+        meTransparent = TransparentType::NONE;
+        mbAlpha = false;
+    }
+}
+
 void BitmapEx::setAlphaFrom( sal_uInt8 cIndexFrom, sal_Int8 nAlphaTo )
 {
     AlphaMask aAlphaMask(GetAlpha());


More information about the Libreoffice-commits mailing list