[Libreoffice-commits] core.git: include/vcl vcl/Library_vcl.mk vcl/source

Chris Sherlock chris.sherlock79 at gmail.com
Sun Apr 22 03:30:39 UTC 2018


 include/vcl/BitmapSmoothenFilter.hxx       |   34 +++++++++++++++++++++++++++
 vcl/Library_vcl.mk                         |    3 +-
 vcl/source/bitmap/BitmapSmoothenFilter.cxx |   36 +++++++++++++++++++++++++++++
 vcl/source/gdi/bitmap4.cxx                 |   24 +++----------------
 4 files changed, 76 insertions(+), 21 deletions(-)

New commits:
commit 57faa86592ddfc60be206b70ee16671585b7ca60
Author: Chris Sherlock <chris.sherlock79 at gmail.com>
Date:   Wed Apr 18 21:19:58 2018 +1000

    vcl: create BitmapSmoothenFilter
    
    Change-Id: I5259035e18daada3cd8963f045731a0a65150718
    Reviewed-on: https://gerrit.libreoffice.org/53099
    Tested-by: Jenkins <ci at libreoffice.org>
    Reviewed-by: Tomaž Vajngerl <quikee at gmail.com>

diff --git a/include/vcl/BitmapSmoothenFilter.hxx b/include/vcl/BitmapSmoothenFilter.hxx
new file mode 100644
index 000000000000..131809700680
--- /dev/null
+++ b/include/vcl/BitmapSmoothenFilter.hxx
@@ -0,0 +1,34 @@
+/* -*- 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/.
+ *
+ */
+
+#ifndef INCLUDED_VCL_BITMAPSMOOTHENFILTER_HXX
+#define INCLUDED_VCL_BITMAPSMOOTHENFILTER_HXX
+
+#include <vcl/BitmapFilter.hxx>
+
+class BitmapEx;
+
+class VCL_DLLPUBLIC BitmapSmoothenFilter : public BitmapFilter
+{
+public:
+    BitmapSmoothenFilter(double fRadius)
+        : mfRadius(fRadius)
+    {
+    }
+
+    virtual BitmapEx execute(BitmapEx const& rBitmapEx) override;
+
+private:
+    double mfRadius;
+};
+
+#endif
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
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;
 


More information about the Libreoffice-commits mailing list