diff options
author | Noel Grandin <noel.grandin@collabora.co.uk> | 2019-07-03 14:50:53 +0200 |
---|---|---|
committer | Noel Grandin <noel.grandin@collabora.co.uk> | 2019-07-04 09:18:09 +0200 |
commit | 0ba0cfa9a0173a5cca9e230f980b9f4efde7a794 (patch) | |
tree | 511f9ebb4caffce15b383179bc147c6fecc7ac18 | |
parent | 405c4e37b2ddf3afeda5e4bf9f57a3c9dd5eab85 (diff) |
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@collabora.co.uk>
-rw-r--r-- | include/svx/bmpmask.hxx | 2 | ||||
-rw-r--r-- | include/vcl/bitmapex.hxx | 7 | ||||
-rw-r--r-- | svx/source/dialog/_bmpmask.cxx | 26 | ||||
-rw-r--r-- | vcl/source/gdi/bitmapex.cxx | 13 |
4 files changed, 21 insertions, 27 deletions
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()); |