diff options
author | Noel Grandin <noel.grandin@collabora.co.uk> | 2019-07-03 15:07:44 +0200 |
---|---|---|
committer | Noel Grandin <noel.grandin@collabora.co.uk> | 2019-07-04 09:18:22 +0200 |
commit | e27be9dfbcf8636a7440f828435b1860dfa38977 (patch) | |
tree | 62a572bc8ad911b011574152c8575f25980c2f45 | |
parent | 0ba0cfa9a0173a5cca9e230f980b9f4efde7a794 (diff) |
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@collabora.co.uk>
-rw-r--r-- | include/svx/bmpmask.hxx | 2 | ||||
-rw-r--r-- | include/vcl/bitmapex.hxx | 24 | ||||
-rw-r--r-- | svx/source/dialog/_bmpmask.cxx | 18 | ||||
-rw-r--r-- | vcl/source/gdi/bitmapex.cxx | 8 |
4 files changed, 38 insertions, 14 deletions
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() ) |