diff options
-rw-r--r-- | cui/source/dialogs/cuigrfflt.cxx | 36 | ||||
-rw-r--r-- | include/vcl/BitmapFilter.hxx | 6 | ||||
-rw-r--r-- | include/vcl/BitmapSepiaFilter.hxx | 6 | ||||
-rw-r--r-- | include/vcl/animate.hxx | 5 | ||||
-rw-r--r-- | include/vcl/bitmap.hxx | 102 | ||||
-rw-r--r-- | include/vcl/bitmapex.hxx | 14 | ||||
-rw-r--r-- | svx/source/dialog/grfflt.cxx | 21 | ||||
-rw-r--r-- | vcl/Library_vcl.mk | 1 | ||||
-rw-r--r-- | vcl/source/bitmap/bitmapfilter.cxx | 35 | ||||
-rw-r--r-- | vcl/source/gdi/animate.cxx | 21 | ||||
-rw-r--r-- | vcl/source/gdi/bitmap4.cxx | 137 | ||||
-rw-r--r-- | vcl/source/gdi/bitmapex.cxx | 5 | ||||
-rw-r--r-- | vcl/source/graphic/UnoGraphicTransformer.cxx | 9 | ||||
-rw-r--r-- | vcl/workben/outdevgrind.cxx | 7 | ||||
-rw-r--r-- | vcl/workben/vcldemo.cxx | 6 |
15 files changed, 89 insertions, 322 deletions
diff --git a/cui/source/dialogs/cuigrfflt.cxx b/cui/source/dialogs/cuigrfflt.cxx index 406e2b6a7f7f..f4959cd3af6c 100644 --- a/cui/source/dialogs/cuigrfflt.cxx +++ b/cui/source/dialogs/cuigrfflt.cxx @@ -17,6 +17,12 @@ * the License at http://www.apache.org/licenses/LICENSE-2.0 . */ +#include <vcl/BitmapMosaicFilter.hxx> +#include <vcl/BitmapSharpenFilter.hxx> +#include <vcl/BitmapEmbossGreyFilter.hxx> +#include <vcl/BitmapSepiaFilter.hxx> +#include <vcl/BitmapSmoothenFilter.hxx> +#include <vcl/BitmapSolarizeFilter.hxx> #include <vcl/BitmapColorQuantizationFilter.hxx> #include <vcl/builderfactory.hxx> #include <sfx2/viewfrm.hxx> @@ -234,16 +240,15 @@ Graphic GraphicFilterMosaic::GetFilteredGraphic( const Graphic& rGraphic, long nTileHeight = static_cast<long>(mpMtrHeight->GetValue()); const Size aSize( std::max( FRound( nTileWidth * fScaleX ), 1L ), std::max( FRound( nTileHeight * fScaleY ), 1L ) ); - BmpFilterParam aParam( aSize ); if( rGraphic.IsAnimated() ) { Animation aAnim( rGraphic.GetAnimation() ); - if( aAnim.Filter( BmpFilter::Mosaic, &aParam ) ) + if (BitmapFilter::Filter(aAnim, BitmapMosaicFilter(aSize.getWidth(), aSize.getHeight()))) { if( IsEnhanceEdges() ) - aAnim.Filter( BmpFilter::Sharpen ); + BitmapFilter::Filter(aAnim, BitmapSharpenFilter()); aRet = aAnim; } @@ -252,10 +257,10 @@ Graphic GraphicFilterMosaic::GetFilteredGraphic( const Graphic& rGraphic, { BitmapEx aBmpEx( rGraphic.GetBitmapEx() ); - if( aBmpEx.Filter( BmpFilter::Mosaic, &aParam ) ) + if (BitmapFilter::Filter(aBmpEx, BitmapMosaicFilter(aSize.getWidth(), aSize.getHeight()))) { if( IsEnhanceEdges() ) - (void)aBmpEx.Filter( BmpFilter::Sharpen ); + BitmapFilter::Filter(aBmpEx, BitmapSharpenFilter()); aRet = aBmpEx; } @@ -300,13 +305,12 @@ Graphic GraphicFilterSmooth::GetFilteredGraphic( const Graphic& rGraphic, double { Graphic aRet; double nRadius = mpMtrRadius->GetValue() / 10.0; - BmpFilterParam aParam( nRadius ); if( rGraphic.IsAnimated() ) { Animation aAnim( rGraphic.GetAnimation() ); - if( aAnim.Filter( BmpFilter::Smooth, &aParam ) ) + if (BitmapFilter::Filter(aAnim, BitmapSmoothenFilter(nRadius))) { aRet = aAnim; } @@ -315,7 +319,7 @@ Graphic GraphicFilterSmooth::GetFilteredGraphic( const Graphic& rGraphic, double { BitmapEx aBmpEx( rGraphic.GetBitmapEx() ); - if( aBmpEx.Filter( BmpFilter::Smooth, &aParam ) ) + if (BitmapFilter::Filter(aBmpEx, BitmapSmoothenFilter(nRadius))) { aRet = aBmpEx; } @@ -371,13 +375,12 @@ Graphic GraphicFilterSolarize::GetFilteredGraphic( const Graphic& rGraphic, doub { Graphic aRet; sal_uInt8 nGreyThreshold = static_cast<sal_uInt8>(FRound( mpMtrThreshold->GetValue() * 2.55 )); - BmpFilterParam aParam( nGreyThreshold ); if( rGraphic.IsAnimated() ) { Animation aAnim( rGraphic.GetAnimation() ); - if( aAnim.Filter( BmpFilter::Solarize, &aParam ) ) + if (BitmapFilter::Filter(aAnim, BitmapSolarizeFilter(nGreyThreshold))) { if( IsInvert() ) aAnim.Invert(); @@ -389,7 +392,7 @@ Graphic GraphicFilterSolarize::GetFilteredGraphic( const Graphic& rGraphic, doub { BitmapEx aBmpEx( rGraphic.GetBitmapEx() ); - if( aBmpEx.Filter( BmpFilter::Solarize, &aParam ) ) + if (BitmapFilter::Filter(aBmpEx, BitmapSolarizeFilter(nGreyThreshold))) { if( IsInvert() ) aBmpEx.Invert(); @@ -433,20 +436,19 @@ Graphic GraphicFilterSepia::GetFilteredGraphic( const Graphic& rGraphic, double, { Graphic aRet; sal_uInt16 nSepiaPct = sal::static_int_cast< sal_uInt16 >(mpMtrSepia->GetValue()); - BmpFilterParam aParam( nSepiaPct ); if( rGraphic.IsAnimated() ) { Animation aAnim( rGraphic.GetAnimation() ); - if( aAnim.Filter( BmpFilter::Sepia, &aParam ) ) + if (BitmapFilter::Filter(aAnim, BitmapSepiaFilter(nSepiaPct))) aRet = aAnim; } else { BitmapEx aBmpEx( rGraphic.GetBitmapEx() ); - if( aBmpEx.Filter( BmpFilter::Sepia, &aParam ) ) + if (BitmapFilter::Filter(aBmpEx, BitmapSepiaFilter(nSepiaPct))) aRet = aBmpEx; } @@ -576,20 +578,18 @@ Graphic GraphicFilterEmboss::GetFilteredGraphic( const Graphic& rGraphic, double case RectPoint::RB: nAzim = 22500; nElev = 4500; break; } - BmpFilterParam aParam( nAzim, nElev ); - if( rGraphic.IsAnimated() ) { Animation aAnim( rGraphic.GetAnimation() ); - if( aAnim.Filter( BmpFilter::EmbossGrey, &aParam ) ) + if (BitmapFilter::Filter(aAnim, BitmapEmbossGreyFilter(nAzim, nElev))) aRet = aAnim; } else { BitmapEx aBmpEx( rGraphic.GetBitmapEx() ); - if( aBmpEx.Filter( BmpFilter::EmbossGrey, &aParam ) ) + if (BitmapFilter::Filter(aBmpEx, BitmapEmbossGreyFilter(nAzim, nElev))) aRet = aBmpEx; } diff --git a/include/vcl/BitmapFilter.hxx b/include/vcl/BitmapFilter.hxx index f8759a1302c2..f1a7e0b6cfff 100644 --- a/include/vcl/BitmapFilter.hxx +++ b/include/vcl/BitmapFilter.hxx @@ -8,10 +8,11 @@ * */ -#ifndef INCLUDED_VCL_INC_BITMAPFILTER_HXX -#define INCLUDED_VCL_INC_BITMAPFILTER_HXX +#ifndef INCLUDED_VCL_BITMAPFILTER_HXX +#define INCLUDED_VCL_BITMAPFILTER_HXX #include <vcl/bitmapex.hxx> +#include <vcl/animate.hxx> class VCL_DLLPUBLIC BitmapFilter { @@ -22,6 +23,7 @@ public: virtual BitmapEx execute(BitmapEx const& rBitmapEx) = 0; static bool Filter(BitmapEx& rBmpEx, BitmapFilter&& rFilter); + static bool Filter(Animation& rBmpEx, BitmapFilter&& rFilter); }; #endif diff --git a/include/vcl/BitmapSepiaFilter.hxx b/include/vcl/BitmapSepiaFilter.hxx index 717f10d1466b..d636ebe6fea6 100644 --- a/include/vcl/BitmapSepiaFilter.hxx +++ b/include/vcl/BitmapSepiaFilter.hxx @@ -19,8 +19,12 @@ class VCL_DLLPUBLIC BitmapSepiaFilter : public BitmapFilter { public: BitmapSepiaFilter(double nSepiaPercent) - : mnSepiaPercent(nSepiaPercent) { + // clamp value to 100% + if (nSepiaPercent <= 100) + mnSepiaPercent = nSepiaPercent; + else + mnSepiaPercent = 100; } virtual BitmapEx execute(BitmapEx const& rBitmapEx) override; diff --git a/include/vcl/animate.hxx b/include/vcl/animate.hxx index 23d7e1e05a44..5cc0cdf0a621 100644 --- a/include/vcl/animate.hxx +++ b/include/vcl/animate.hxx @@ -125,6 +125,7 @@ public: void SetNotifyHdl( const Link<Animation*,void>& rLink ) { maNotifyLink = rLink; } const Link<Animation*,void>& GetNotifyHdl() const { return maNotifyLink; } + std::vector< std::unique_ptr<AnimationBitmap> >& GetAnimationFrames() { return maList; } size_t Count() const { return maList.size(); } bool Insert( const AnimationBitmap& rAnimationBitmap ); const AnimationBitmap& @@ -150,10 +151,6 @@ public: double fGamma = 1.0, bool bInvert = false ); - bool Filter( - BmpFilter eFilter, - const BmpFilterParam* pFilterParam = nullptr ); - friend VCL_DLLPUBLIC SvStream& ReadAnimation( SvStream& rIStream, Animation& rAnimation ); friend VCL_DLLPUBLIC SvStream& WriteAnimation( SvStream& rOStream, const Animation& rAnimation ); diff --git a/include/vcl/bitmap.hxx b/include/vcl/bitmap.hxx index d0fa1a28ea34..9dfca1de0af1 100644 --- a/include/vcl/bitmap.hxx +++ b/include/vcl/bitmap.hxx @@ -89,94 +89,6 @@ enum class BmpCombine Or, And }; -enum class BmpFilter -{ - Smooth = 0, - Sharpen = 1, - RemoveNoise = 2, - SobelGrey = 3, - EmbossGrey = 4, - Solarize = 5, - Sepia = 6, - Mosaic = 7, - PopArt = 8, - DuoTone = 9, - - Unknown = 65535 -}; - -class VCL_DLLPUBLIC BmpFilterParam -{ -public: - - BmpFilterParam( sal_uLong nProgressStart = 0, sal_uLong nProgressEnd = 0 ) : - meFilter( BmpFilter::Unknown ), mnProgressStart( nProgressStart ), mnProgressEnd( nProgressEnd ) {} - - BmpFilterParam( sal_uInt8 cSolarGreyThreshold, sal_uLong nProgressStart = 0, sal_uLong nProgressEnd = 0 ) : - meFilter( BmpFilter::Solarize ), mnProgressStart( nProgressStart ), mnProgressEnd( nProgressEnd ), - mcSolarGreyThreshold( cSolarGreyThreshold ) {} - - BmpFilterParam( double nRadius, sal_uLong nProgressStart = 0, sal_uLong nProgressEnd = 0 ) : - meFilter( BmpFilter::Smooth ), mnProgressStart( nProgressStart ), mnProgressEnd( nProgressEnd ), - mnRadius( nRadius ) {} - - BmpFilterParam( sal_uInt16 nSepiaPercent, sal_uLong nProgressStart = 0, sal_uLong nProgressEnd = 0 ) : - meFilter( BmpFilter::Sepia ), mnProgressStart( nProgressStart ), mnProgressEnd( nProgressEnd ), - mnSepiaPercent( nSepiaPercent ) - { - assert(nSepiaPercent<=100); - } - - BmpFilterParam( const Size& rMosaicTileSize, sal_uLong nProgressStart = 0, sal_uLong nProgressEnd = 0 ) : - meFilter( BmpFilter::Mosaic ), mnProgressStart( nProgressStart ), mnProgressEnd( nProgressEnd ) - { - maMosaicTileSize.mnTileWidth = rMosaicTileSize.Width(); - maMosaicTileSize.mnTileHeight= rMosaicTileSize.Height(); - } - BmpFilterParam( sal_uInt16 nEmbossAzimuthAngle100, sal_uInt16 nEmbossElevationAngle100, - sal_uLong nProgressStart = 0, sal_uLong nProgressEnd = 0 ) : - meFilter( BmpFilter::EmbossGrey ), mnProgressStart( nProgressStart ), mnProgressEnd( nProgressEnd ) - { - maEmbossAngles.mnAzimuthAngle100 = nEmbossAzimuthAngle100; - maEmbossAngles.mnElevationAngle100 = nEmbossElevationAngle100; - } - -private: - friend class ::Bitmap; - friend class BitmapEx; - friend class Animation; - -private: - BmpFilter meFilter; - sal_uLong mnProgressStart; - sal_uLong mnProgressEnd; - -public: - struct MosaicTileSize - { - sal_uLong mnTileWidth; - sal_uLong mnTileHeight; - }; - - struct EmbossAngles - { - sal_uInt16 mnAzimuthAngle100; - sal_uInt16 mnElevationAngle100; - }; - -private: - union - { - sal_uInt16 mnSepiaPercent; - sal_uInt8 mcSolarGreyThreshold; - double mnRadius; - - MosaicTileSize maMosaicTileSize; - EmbossAngles maEmbossAngles; - }; - -}; - class BitmapInfoAccess; class BitmapReadAccess; class BitmapWriteAccess; @@ -626,20 +538,6 @@ public: bool bInvert = false, bool msoBrightness = false ); - /** Apply specified filter to the bitmap - - @param eFilter - The filter algorithm to apply - - @param pFilterParam - Various parameter for the different bitmap filter algorithms - - @return true, if the operation was completed successfully. - */ - bool Filter( - BmpFilter eFilter, - const BmpFilterParam* pFilterParam = nullptr ); - public: /** ReassignWithSize and recalculate bitmap. diff --git a/include/vcl/bitmapex.hxx b/include/vcl/bitmapex.hxx index d7c2560485c4..f52a8dba5fb0 100644 --- a/include/vcl/bitmapex.hxx +++ b/include/vcl/bitmapex.hxx @@ -332,20 +332,6 @@ public: bool bInvert = false, bool msoBrightness = false ); - /** Apply specified filter to the bitmap - - @param eFilter - The filter algorithm to apply - - @param pFilterParam - Various parameter for the different bitmap filter algorithms - - @return true, if the operation was completed successfully. - */ - bool Filter( - BmpFilter eFilter, - const BmpFilterParam* pFilterParam = nullptr ); - /** Get transparency at given position @param nX diff --git a/svx/source/dialog/grfflt.cxx b/svx/source/dialog/grfflt.cxx index fffcaaecdbf5..ccc8e2148e99 100644 --- a/svx/source/dialog/grfflt.cxx +++ b/svx/source/dialog/grfflt.cxx @@ -17,6 +17,11 @@ * the License at http://www.apache.org/licenses/LICENSE-2.0 . */ +#include <vcl/BitmapSharpenFilter.hxx> +#include <vcl/BitmapMedianFilter.hxx> +#include <vcl/BitmapSobelGreyFilter.hxx> +#include <vcl/BitmapPopArtFilter.hxx> + #include <sfx2/viewfrm.hxx> #include <sfx2/viewsh.hxx> #include <sfx2/objsh.hxx> @@ -89,14 +94,14 @@ SvxGraphicFilterResult SvxGraphicFilter::ExecuteGrfFilterSlot( SfxRequest const { Animation aAnimation( rGraphic.GetAnimation() ); - if( aAnimation.Filter( BmpFilter::Sharpen ) ) + if (BitmapFilter::Filter(aAnimation, BitmapSharpenFilter())) aGraphic = aAnimation; } else { BitmapEx aBmpEx( rGraphic.GetBitmapEx() ); - if( aBmpEx.Filter( BmpFilter::Sharpen ) ) + if (BitmapFilter::Filter(aBmpEx, BitmapSharpenFilter())) aGraphic = aBmpEx; } @@ -114,14 +119,14 @@ SvxGraphicFilterResult SvxGraphicFilter::ExecuteGrfFilterSlot( SfxRequest const { Animation aAnimation( rGraphic.GetAnimation() ); - if( aAnimation.Filter( BmpFilter::RemoveNoise ) ) + if (BitmapFilter::Filter(aAnimation, BitmapMedianFilter())) aGraphic = aAnimation; } else { BitmapEx aBmpEx( rGraphic.GetBitmapEx() ); - if( aBmpEx.Filter( BmpFilter::RemoveNoise ) ) + if (BitmapFilter::Filter(aBmpEx, BitmapMedianFilter())) aGraphic = aBmpEx; } @@ -139,14 +144,14 @@ SvxGraphicFilterResult SvxGraphicFilter::ExecuteGrfFilterSlot( SfxRequest const { Animation aAnimation( rGraphic.GetAnimation() ); - if( aAnimation.Filter( BmpFilter::SobelGrey ) ) + if (BitmapFilter::Filter(aAnimation, BitmapSobelGreyFilter())) aGraphic = aAnimation; } else { BitmapEx aBmpEx( rGraphic.GetBitmapEx() ); - if( aBmpEx.Filter( BmpFilter::SobelGrey ) ) + if (BitmapFilter::Filter(aBmpEx, BitmapSobelGreyFilter())) aGraphic = aBmpEx; } @@ -203,14 +208,14 @@ SvxGraphicFilterResult SvxGraphicFilter::ExecuteGrfFilterSlot( SfxRequest const { Animation aAnimation( rGraphic.GetAnimation() ); - if( aAnimation.Filter( BmpFilter::PopArt ) ) + if (BitmapFilter::Filter(aAnimation, BitmapPopArtFilter())) aGraphic = aAnimation; } else { BitmapEx aBmpEx( rGraphic.GetBitmapEx() ); - if( aBmpEx.Filter( BmpFilter::PopArt ) ) + if (BitmapFilter::Filter(aBmpEx, BitmapPopArtFilter())) aGraphic = aBmpEx; } diff --git a/vcl/Library_vcl.mk b/vcl/Library_vcl.mk index 3da03f8acfbb..123d8e80fd7d 100644 --- a/vcl/Library_vcl.mk +++ b/vcl/Library_vcl.mk @@ -248,7 +248,6 @@ $(eval $(call gb_Library_add_exception_objects,vcl,\ vcl/source/gdi/animate \ vcl/source/gdi/base14 \ vcl/source/gdi/bitmap3 \ - vcl/source/gdi/bitmap4 \ vcl/source/gdi/bitmapex \ vcl/source/gdi/bmpacc2 \ vcl/source/gdi/bmpacc3 \ diff --git a/vcl/source/bitmap/bitmapfilter.cxx b/vcl/source/bitmap/bitmapfilter.cxx index 4f4ae5ae0961..4c20a83f0d40 100644 --- a/vcl/source/bitmap/bitmapfilter.cxx +++ b/vcl/source/bitmap/bitmapfilter.cxx @@ -9,14 +9,15 @@ */ #include <vcl/BitmapFilter.hxx> +#include <vcl/animate.hxx> -BitmapFilter::BitmapFilter() -{} +#include <algorithm> -BitmapFilter::~BitmapFilter() -{} +BitmapFilter::BitmapFilter() {} -bool BitmapFilter::Filter(BitmapEx &rBmpEx, BitmapFilter &&rFilter) +BitmapFilter::~BitmapFilter() {} + +bool BitmapFilter::Filter(BitmapEx& rBmpEx, BitmapFilter&& rFilter) { BitmapEx aTmpBmpEx(rFilter.execute(rBmpEx)); @@ -30,4 +31,28 @@ bool BitmapFilter::Filter(BitmapEx &rBmpEx, BitmapFilter &&rFilter) return true; } +bool BitmapFilter::Filter(Animation& rAnimation, BitmapFilter&& rFilter) +{ + SAL_WARN_IF(rAnimation.IsInAnimation(), "vcl", "Animation modified while it is animated"); + + bool bRet = false; + + if (!rAnimation.IsInAnimation() && !rAnimation.Count()) + { + bRet = true; + + std::vector<std::unique_ptr<AnimationBitmap>>& aList = rAnimation.GetAnimationFrames(); + for (size_t i = 0, n = aList.size(); (i < n) && bRet; ++i) + { + bRet = BitmapFilter::Filter(aList[i]->aBmpEx, std::move(rFilter)); + } + + BitmapEx aBmpEx(rAnimation.GetBitmapEx()); + BitmapFilter::Filter(aBmpEx, std::move(rFilter)); + rAnimation.SetBitmapEx(aBmpEx); + } + + return bRet; +} + /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/vcl/source/gdi/animate.cxx b/vcl/source/gdi/animate.cxx index 5adfc6ca5736..71028e5b41c5 100644 --- a/vcl/source/gdi/animate.cxx +++ b/vcl/source/gdi/animate.cxx @@ -625,27 +625,6 @@ void Animation::Adjust( short nLuminancePercent, short nContrastPercent, } } -bool Animation::Filter( BmpFilter eFilter, const BmpFilterParam* pFilterParam ) -{ - SAL_WARN_IF( IsInAnimation(), "vcl", "Animation modified while it is animated" ); - - bool bRet; - - if( !IsInAnimation() && !maList.empty() ) - { - bRet = true; - - for( size_t i = 0, n = maList.size(); ( i < n ) && bRet; ++i ) - bRet = maList[ i ]->aBmpEx.Filter( eFilter, pFilterParam ); - - (void)maBitmapEx.Filter(eFilter, pFilterParam); - } - else - bRet = false; - - return bRet; -} - SvStream& WriteAnimation( SvStream& rOStm, const Animation& rAnimation ) { const sal_uInt16 nCount = rAnimation.Count(); diff --git a/vcl/source/gdi/bitmap4.cxx b/vcl/source/gdi/bitmap4.cxx deleted file mode 100644 index df1c39613dc9..000000000000 --- a/vcl/source/gdi/bitmap4.cxx +++ /dev/null @@ -1,137 +0,0 @@ -/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ -/* - * This file is part of the LibreOffice project. - * - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. - * - * This file incorporates work covered by the following license notice: - * - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed - * with this work for additional information regarding copyright - * ownership. The ASF licenses this file to you under the Apache - * License, Version 2.0 (the "License"); you may not use this file - * except in compliance with the License. You may obtain a copy of - * the License at http://www.apache.org/licenses/LICENSE-2.0 . - */ - -#include <osl/diagnose.h> -#include <vcl/bitmapaccess.hxx> -#include <vcl/bitmap.hxx> -#include <vcl/BitmapSmoothenFilter.hxx> -#include <vcl/BitmapSharpenFilter.hxx> -#include <vcl/BitmapMedianFilter.hxx> -#include <vcl/BitmapSobelGreyFilter.hxx> -#include <vcl/BitmapSolarizeFilter.hxx> -#include <vcl/BitmapSepiaFilter.hxx> -#include <vcl/BitmapMosaicFilter.hxx> -#include <vcl/BitmapEmbossGreyFilter.hxx> -#include <vcl/BitmapPopArtFilter.hxx> -#include <vcl/BitmapDuoToneFilter.hxx> - -#include <bitmapwriteaccess.hxx> - -#include <memory> -#include <stdlib.h> - -bool Bitmap::Filter( BmpFilter eFilter, const BmpFilterParam* pFilterParam ) -{ - bool bRet = false; - - switch( eFilter ) - { - case BmpFilter::Smooth: - { - BitmapEx aBmpEx(*this); - bRet = BitmapFilter::Filter(aBmpEx, BitmapSmoothenFilter(pFilterParam->mnRadius)); - *this = aBmpEx.GetBitmap(); - } - break; - - case BmpFilter::Sharpen: - { - BitmapEx aBmpEx(*this); - bRet = BitmapFilter::Filter(aBmpEx, BitmapSharpenFilter()); - *this = aBmpEx.GetBitmap(); - } - break; - - case BmpFilter::RemoveNoise: - { - BitmapEx aBmpEx(*this); - bRet = BitmapFilter::Filter(aBmpEx, BitmapMedianFilter()); - *this = aBmpEx.GetBitmap(); - } - break; - - case BmpFilter::SobelGrey: - { - BitmapEx aBmpEx(*this); - bRet = BitmapFilter::Filter(aBmpEx, BitmapSobelGreyFilter()); - *this = aBmpEx.GetBitmap(); - } - break; - - case BmpFilter::Solarize: - { - BitmapEx aBmpEx(*this); - bRet = BitmapFilter::Filter(aBmpEx, BitmapSolarizeFilter(pFilterParam->mcSolarGreyThreshold)); - *this = aBmpEx.GetBitmap(); - } - break; - - case BmpFilter::Sepia: - { - BitmapEx aBmpEx(*this); - bRet = BitmapFilter::Filter(aBmpEx, BitmapSepiaFilter(pFilterParam->mnSepiaPercent)); - *this = aBmpEx.GetBitmap(); - } - break; - - case BmpFilter::Mosaic: - { - BitmapEx aBmpEx(*this); - bRet = BitmapFilter::Filter(aBmpEx, BitmapMosaicFilter(pFilterParam->maMosaicTileSize.mnTileWidth, - pFilterParam->maMosaicTileSize.mnTileHeight)); - *this = aBmpEx.GetBitmap(); - } - - break; - - case BmpFilter::EmbossGrey: - { - BitmapEx aBmpEx(*this); - bRet = BitmapFilter::Filter(aBmpEx, BitmapEmbossGreyFilter(pFilterParam->maEmbossAngles.mnAzimuthAngle100, - pFilterParam->maEmbossAngles.mnElevationAngle100)); - *this = aBmpEx.GetBitmap(); - } - break; - - case BmpFilter::PopArt: - { - BitmapEx aBmpEx(*this); - bRet = BitmapFilter::Filter(aBmpEx, BitmapPopArtFilter()); - *this = aBmpEx.GetBitmap(); - } - break; - - case BmpFilter::DuoTone: - { - BitmapEx aBmpEx(*this); - bRet = BitmapFilter::Filter(aBmpEx, BitmapDuoToneFilter(pFilterParam->mnProgressStart, - pFilterParam->mnProgressEnd)); - *this = aBmpEx.GetBitmap(); - } - break; - - default: - OSL_FAIL( "Bitmap::Convert(): Unsupported filter" ); - break; - } - - return bRet; -} - -/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/vcl/source/gdi/bitmapex.cxx b/vcl/source/gdi/bitmapex.cxx index 35ae111aa955..2301646974a6 100644 --- a/vcl/source/gdi/bitmapex.cxx +++ b/vcl/source/gdi/bitmapex.cxx @@ -604,11 +604,6 @@ bool BitmapEx::Adjust( short nLuminancePercent, short nContrastPercent, fGamma, bInvert, msoBrightness ); } -bool BitmapEx::Filter( BmpFilter eFilter, const BmpFilterParam* pFilterParam ) -{ - return !!maBitmap && maBitmap.Filter( eFilter, pFilterParam ); -} - void BitmapEx::Draw( OutputDevice* pOutDev, const Point& rDestPt ) const { pOutDev->DrawBitmapEx( rDestPt, *this ); diff --git a/vcl/source/graphic/UnoGraphicTransformer.cxx b/vcl/source/graphic/UnoGraphicTransformer.cxx index 05a1f436247b..2fba69d01c93 100644 --- a/vcl/source/graphic/UnoGraphicTransformer.cxx +++ b/vcl/source/graphic/UnoGraphicTransformer.cxx @@ -27,6 +27,8 @@ #include <vcl/salbtype.hxx> #include <vcl/virdev.hxx> #include <vcl/bitmapaccess.hxx> +#include <vcl/BitmapDuoToneFilter.hxx> + #include <com/sun/star/text/GraphicCrop.hpp> using namespace com::sun::star; @@ -118,8 +120,11 @@ uno::Reference< graphic::XGraphic > SAL_CALL GraphicTransformer::applyDuotone( BitmapEx aBitmapEx( aGraphic.GetBitmapEx() ); AlphaMask aMask( aBitmapEx.GetAlpha() ); Bitmap aBitmap( aBitmapEx.GetBitmap() ); - BmpFilterParam aFilter( static_cast<sal_uLong>(nColorOne), static_cast<sal_uLong>(nColorTwo) ); - aBitmap.Filter( BmpFilter::DuoTone, &aFilter ); + + BitmapEx aTmpBmpEx(aBitmap); + BitmapFilter::Filter(aTmpBmpEx, BitmapDuoToneFilter(static_cast<sal_uLong>(nColorOne), static_cast<sal_uLong>(nColorTwo))); + aBitmap = aTmpBmpEx.GetBitmap(); + aReturnGraphic = ::Graphic( BitmapEx( aBitmap, aMask ) ); aReturnGraphic.setOriginURL(aGraphic.getOriginURL()); return aReturnGraphic.GetXGraphic(); diff --git a/vcl/workben/outdevgrind.cxx b/vcl/workben/outdevgrind.cxx index 341b509905ba..04889307c8ce 100644 --- a/vcl/workben/outdevgrind.cxx +++ b/vcl/workben/outdevgrind.cxx @@ -32,6 +32,7 @@ #include <vcl/virdev.hxx> #include <vcl/hatch.hxx> #include <vcl/bitmap.hxx> +#include <vcl/BitmapEmbossGreyFilter.hxx> #include <vcl/wall.hxx> #include <vcl/image.hxx> #include <vcl/gdimtf.hxx> @@ -127,7 +128,11 @@ void setupMethodStubs( functor_vector_type& res ) const Bitmap aBitmap( aIntro.GetBitmap() ); Bitmap aBitmapBW( aBitmap ); - aBitmapBW.Filter( BmpFilter::EmbossGrey ); + + BitmapEx aTmpBmpEx(aBitmapBW); + BitmapFilter::Filter(aTmpBmpEx, BitmapEmbossGreyFilter(0, 0)); + aBitmapBW = aTmpBmpEx.GetBitmap(); + Bitmap aBitmapAlien( Size( 100, 100 ), 8 ); aBitmapAlien.Erase( COL_RED ); #endif diff --git a/vcl/workben/vcldemo.cxx b/vcl/workben/vcldemo.cxx index 841cc2103cd8..d2349ed33cfe 100644 --- a/vcl/workben/vcldemo.cxx +++ b/vcl/workben/vcldemo.cxx @@ -45,6 +45,7 @@ #include <vcl/help.hxx> #include <vcl/menu.hxx> #include <vcl/ImageTree.hxx> +#include <vcl/BitmapEmbossGreyFilter.hxx> #include <bitmapwriteaccess.hxx> #include <basegfx/numeric/ftools.hxx> @@ -144,7 +145,10 @@ public: Application::Abort("Failed to load intro image"); maIntroBW = maIntro.GetBitmap(); - maIntroBW.Filter(BmpFilter::EmbossGrey); + + BitmapEx aTmpBmpEx(maIntroBW); + BitmapFilter::Filter(aTmpBmpEx, BitmapEmbossGreyFilter(0, 0)); + maIntroBW = aTmpBmpEx.GetBitmap(); InitRenderers(); mnSegmentsY = rtl::math::round(std::sqrt(maRenderers.size()), 0, |