diff options
author | Chris Sherlock <chris.sherlock79@gmail.com> | 2018-04-18 21:19:58 +1000 |
---|---|---|
committer | Tomaž Vajngerl <quikee@gmail.com> | 2018-04-22 05:29:25 +0200 |
commit | 57faa86592ddfc60be206b70ee16671585b7ca60 (patch) | |
tree | d416015c59f267348b2857c28ea87e3007ee58b5 /vcl | |
parent | 7b06fcddf8d9a0b51bf396d29487f1fd715b82d3 (diff) |
vcl: create BitmapSmoothenFilter
Change-Id: I5259035e18daada3cd8963f045731a0a65150718
Reviewed-on: https://gerrit.libreoffice.org/53099
Tested-by: Jenkins <ci@libreoffice.org>
Reviewed-by: Tomaž Vajngerl <quikee@gmail.com>
Diffstat (limited to 'vcl')
-rw-r--r-- | vcl/Library_vcl.mk | 3 | ||||
-rw-r--r-- | vcl/source/bitmap/BitmapSmoothenFilter.cxx | 36 | ||||
-rw-r--r-- | vcl/source/gdi/bitmap4.cxx | 24 |
3 files changed, 42 insertions, 21 deletions
diff --git a/vcl/Library_vcl.mk b/vcl/Library_vcl.mk index 644620981c94..57cd8d3962c7 100644 --- a/vcl/Library_vcl.mk +++ b/vcl/Library_vcl.mk @@ -320,7 +320,8 @@ $(eval $(call gb_Library_add_exception_objects,vcl,\ vcl/source/bitmap/bitmappaint \ vcl/source/bitmap/BitmapGaussianSeparableBlurFilter \ vcl/source/bitmap/BitmapSeparableUnsharpenFilter \ - vcl/source/bitmap/BitmapFastScaleFilter \ + vcl/source/bitmap/BitmapSmoothenFilter \ + vcl/source/bitmap/BitmapFastScaleFilter \ vcl/source/bitmap/BitmapScaleSuperFilter \ vcl/source/bitmap/BitmapScaleConvolutionFilter \ vcl/source/bitmap/BitmapSymmetryCheck \ diff --git a/vcl/source/bitmap/BitmapSmoothenFilter.cxx b/vcl/source/bitmap/BitmapSmoothenFilter.cxx new file mode 100644 index 000000000000..4c3b3f53c368 --- /dev/null +++ b/vcl/source/bitmap/BitmapSmoothenFilter.cxx @@ -0,0 +1,36 @@ +/* -*- 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/. + * + */ + +#include <vcl/bitmap.hxx> +#include <vcl/bitmapex.hxx> +#include <vcl/bitmapaccess.hxx> +#include <vcl/BitmapGaussianSeparableBlurFilter.hxx> +#include <vcl/BitmapSeparableUnsharpenFilter.hxx> +#include <vcl/BitmapSmoothenFilter.hxx> + +#include <bitmapwriteaccess.hxx> + +BitmapEx BitmapSmoothenFilter::execute(BitmapEx const& rBitmapEx) +{ + BitmapEx aBitmapEx(rBitmapEx); + bool bRet = false; + + if (mfRadius > 0.0) // Blur for positive values of mnRadius + bRet = BitmapFilter::Filter(aBitmapEx, BitmapGaussianSeparableBlurFilter(mfRadius)); + else if (mfRadius < 0.0) // Unsharpen mask for negative values of mnRadius + bRet = BitmapFilter::Filter(aBitmapEx, BitmapSeparableUnsharpenFilter(mfRadius)); + + if (bRet) + return BitmapEx(rBitmapEx); + + return BitmapEx(); +} + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/vcl/source/gdi/bitmap4.cxx b/vcl/source/gdi/bitmap4.cxx index 8e4d7a7d2f36..e7c18f01718d 100644 --- a/vcl/source/gdi/bitmap4.cxx +++ b/vcl/source/gdi/bitmap4.cxx @@ -20,8 +20,7 @@ #include <osl/diagnose.h> #include <vcl/bitmapaccess.hxx> #include <vcl/bitmap.hxx> -#include <vcl/BitmapGaussianSeparableBlurFilter.hxx> -#include <vcl/BitmapSeparableUnsharpenFilter.hxx> +#include <vcl/BitmapSmoothenFilter.hxx> #include <vcl/BitmapConvolutionMatrixFilter.hxx> #include <bitmapwriteaccess.hxx> @@ -53,24 +52,9 @@ bool Bitmap::Filter( BmpFilter eFilter, const BmpFilterParam* pFilterParam ) { case BmpFilter::Smooth: { - // Blur for positive values of mnRadius - if (pFilterParam->mnRadius > 0.0) - { - BitmapEx aBmpEx(*this); - bRet = BitmapFilter::Filter(aBmpEx, BitmapGaussianSeparableBlurFilter(pFilterParam->mnRadius)); - *this = aBmpEx.GetBitmap(); - } - // Unsharpen Mask for negative values of mnRadius - else if (pFilterParam->mnRadius < 0.0) - { - BitmapEx aBmpEx(*this); - bRet = BitmapFilter::Filter(aBmpEx, BitmapSeparableUnsharpenFilter(pFilterParam->mnRadius)); - *this = aBmpEx.GetBitmap(); - } - else - { - bRet = false; - } + BitmapEx aBmpEx(*this); + bRet = BitmapFilter::Filter(aBmpEx, BitmapSmoothenFilter(pFilterParam->mnRadius)); + *this = aBmpEx.GetBitmap(); } break; |