summaryrefslogtreecommitdiff
path: root/include
diff options
context:
space:
mode:
authorMike Kaganski <mike.kaganski@collabora.com>2020-05-06 11:08:22 +0300
committerMike Kaganski <mike.kaganski@collabora.com>2020-05-07 21:56:23 +0200
commit84808eed2405ed6ee586e87bb664a816f7b91b70 (patch)
tree38bfad43c2fff3e4185f7e9720f88e84090e1dfe /include
parent547b2891d9fe97dee9df14106e91dc4df659d4d5 (diff)
Add basic morphology (erode/dilate) bitmap filter
Needed for glow effect (tdf#101181) Change-Id: Id41daa1dc17e3749a30ce75fa3127878b9e0cfd1 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/93552 Tested-by: Jenkins Reviewed-by: Tomaž Vajngerl <quikee@gmail.com>
Diffstat (limited to 'include')
-rw-r--r--include/vcl/BitmapBasicMorphologyFilter.hxx60
1 files changed, 60 insertions, 0 deletions
diff --git a/include/vcl/BitmapBasicMorphologyFilter.hxx b/include/vcl/BitmapBasicMorphologyFilter.hxx
new file mode 100644
index 000000000000..ade82adaa957
--- /dev/null
+++ b/include/vcl/BitmapBasicMorphologyFilter.hxx
@@ -0,0 +1,60 @@
+/* -*- 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_BITMAPBASICMORPHOLOGYFILTER_HXX
+#define INCLUDED_VCL_BITMAPBASICMORPHOLOGYFILTER_HXX
+
+#include <vcl/bitmap.hxx>
+#include <vcl/bitmapex.hxx>
+#include <vcl/BitmapFilter.hxx>
+
+enum class BasicMorphologyOp
+{
+ erode,
+ dilate
+};
+
+/* Black is foreground, white is background */
+class VCL_DLLPUBLIC BitmapBasicMorphologyFilter : public BitmapFilter
+{
+public:
+ BitmapBasicMorphologyFilter(BasicMorphologyOp op, sal_Int32 nRadius);
+ virtual ~BitmapBasicMorphologyFilter();
+
+ virtual BitmapEx execute(BitmapEx const& rBitmap) const override;
+
+private:
+ Bitmap filter(Bitmap const& rBitmap) const;
+
+ BasicMorphologyOp m_eOp;
+ sal_Int32 m_nRadius;
+};
+
+class BitmapErodeFilter : public BitmapBasicMorphologyFilter
+{
+public:
+ BitmapErodeFilter(sal_Int32 nRadius)
+ : BitmapBasicMorphologyFilter(BasicMorphologyOp::erode, nRadius)
+ {
+ }
+};
+
+class BitmapDilateFilter : public BitmapBasicMorphologyFilter
+{
+public:
+ BitmapDilateFilter(sal_Int32 nRadius)
+ : BitmapBasicMorphologyFilter(BasicMorphologyOp::dilate, nRadius)
+ {
+ }
+};
+
+#endif // INCLUDED_VCL_BITMAPBASICMORPHOLOGYFILTER_HXX
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */