summaryrefslogtreecommitdiffstats
path: root/chalk/plugins/filters/convolutionfilters/convolutionfilters.cpp
diff options
context:
space:
mode:
authorMichele Calgaro <michele.calgaro@yahoo.it>2021-05-23 20:48:35 +0900
committerMichele Calgaro <michele.calgaro@yahoo.it>2021-05-29 15:16:28 +0900
commit8b78a8791bc539bcffe7159f9d9714d577cb3d7d (patch)
tree1328291f966f19a22d7b13657d3f01a588eb1083 /chalk/plugins/filters/convolutionfilters/convolutionfilters.cpp
parent95834e2bdc5e01ae1bd21ac0dfa4fa1d2417fae9 (diff)
downloadkoffice-8b78a8791bc539bcffe7159f9d9714d577cb3d7d.tar.gz
koffice-8b78a8791bc539bcffe7159f9d9714d577cb3d7d.zip
Renaming of files in preparation for code style tools.
Signed-off-by: Michele Calgaro <michele.calgaro@yahoo.it>
Diffstat (limited to 'chalk/plugins/filters/convolutionfilters/convolutionfilters.cpp')
-rw-r--r--chalk/plugins/filters/convolutionfilters/convolutionfilters.cpp176
1 files changed, 176 insertions, 0 deletions
diff --git a/chalk/plugins/filters/convolutionfilters/convolutionfilters.cpp b/chalk/plugins/filters/convolutionfilters/convolutionfilters.cpp
new file mode 100644
index 000000000..8f1085654
--- /dev/null
+++ b/chalk/plugins/filters/convolutionfilters/convolutionfilters.cpp
@@ -0,0 +1,176 @@
+/*
+ * This file is part of the KDE project
+ *
+ * Copyright (c) 2004 Cyrille Berger <cberger@cberger.net>
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ */
+
+#include <stdlib.h>
+
+#include <tdelocale.h>
+#include <kinstance.h>
+#include <kgenericfactory.h>
+
+#include <kis_convolution_painter.h>
+#include "convolutionfilters.h"
+
+#include "kis_custom_convolution_filter.h"
+
+KisKernelSP createKernel( TQ_INT32 i0, TQ_INT32 i1, TQ_INT32 i2,
+ TQ_INT32 i3, TQ_INT32 i4, TQ_INT32 i5,
+ TQ_INT32 i6, TQ_INT32 i7, TQ_INT32 i8,
+ TQ_INT32 factor, TQ_INT32 offset )
+{
+ KisKernelSP kernel = new KisKernel();
+ kernel->width = 3;
+ kernel->height = 3;
+
+ kernel->factor = factor;
+ kernel->offset = offset;
+
+ kernel->data = new TQ_INT32[9];
+ kernel->data[0] = i0;
+ kernel->data[1] = i1;
+ kernel->data[2] = i2;
+ kernel->data[3] = i3;
+ kernel->data[4] = i4;
+ kernel->data[5] = i5;
+ kernel->data[6] = i6;
+ kernel->data[7] = i7;
+ kernel->data[8] = i8;
+
+ return kernel;
+}
+
+
+
+typedef KGenericFactory<ChalkConvolutionFilters> ChalkConvolutionFiltersFactory;
+K_EXPORT_COMPONENT_FACTORY( chalkconvolutionfilters, ChalkConvolutionFiltersFactory( "chalk" ) )
+
+ChalkConvolutionFilters::ChalkConvolutionFilters(TQObject *parent, const char *name, const TQStringList &)
+ : KParts::Plugin(parent, name)
+{
+ setInstance(ChalkConvolutionFiltersFactory::instance());
+
+ if (parent->inherits("KisFilterRegistry")) {
+ KisFilterRegistry * manager = dynamic_cast<KisFilterRegistry *>(parent);
+ manager->add(new KisGaussianBlurFilter());
+ manager->add(new KisSharpenFilter());
+ manager->add(new KisMeanRemovalFilter());
+ manager->add(new KisEmbossLaplascianFilter());
+ manager->add(new KisEmbossInAllDirectionsFilter());
+ manager->add(new KisEmbossHorizontalVerticalFilter());
+ manager->add(new KisEmbossVerticalFilter());
+ manager->add(new KisEmbossHorizontalFilter());
+ manager->add(new KisTopEdgeDetectionFilter());
+ manager->add(new KisRightEdgeDetectionFilter());
+ manager->add(new KisBottomEdgeDetectionFilter());
+ manager->add(new KisLeftEdgeDetectionFilter());
+ manager->add(new KisCustomConvolutionFilter());
+ }
+}
+
+ChalkConvolutionFilters::~ChalkConvolutionFilters()
+{
+}
+
+KisGaussianBlurFilter::KisGaussianBlurFilter()
+ : KisConvolutionConstFilter(id(), "blur", i18n("&Gaussian Blur"))
+{
+ m_matrix = createKernel( 1, 2, 1, 2, 4, 2, 1, 2, 1, 16, 0);
+}
+
+
+KisSharpenFilter::KisSharpenFilter()
+ : KisConvolutionConstFilter(id(), "enhance", i18n("&Sharpen"))
+{
+ m_matrix = createKernel( 0, -2, 0, -2, 11, -2, 0, -2, 0, 3, 0);
+}
+
+KisMeanRemovalFilter::KisMeanRemovalFilter()
+ : KisConvolutionConstFilter(id(), "enhance", i18n("&Mean Removal"))
+{
+ m_matrix = createKernel( -1, -1, -1, -1, 9, -1, -1, -1, -1, 1, 0);
+}
+
+KisEmbossLaplascianFilter::KisEmbossLaplascianFilter()
+ : KisConvolutionConstFilter(id(), "emboss", i18n("Emboss Laplascian"))
+{
+ m_matrix = createKernel( -1, 0, -1 , 0, 4, 0 , -1, 0, -1, 1, 127);
+ m_channelFlags = KisChannelInfo::FLAG_COLOR;
+}
+
+KisEmbossInAllDirectionsFilter::KisEmbossInAllDirectionsFilter()
+ : KisConvolutionConstFilter(id(), "emboss", i18n("Emboss in All Directions"))
+{
+ m_matrix = createKernel( -1, -1, -1 , -1, 8, -1 , -1, -1, -1, 1, 127);
+ m_channelFlags = KisChannelInfo::FLAG_COLOR;
+}
+
+KisEmbossHorizontalVerticalFilter::KisEmbossHorizontalVerticalFilter()
+ : KisConvolutionConstFilter(id(), "emboss", i18n("Emboss Horizontal &&Qt::Vertical"))
+{
+ m_matrix = createKernel( 0, -1, 0 , -1, 4, -1 , 0, -1, 0, 1, 127);
+ m_channelFlags = KisChannelInfo::FLAG_COLOR;
+}
+
+KisEmbossVerticalFilter::KisEmbossVerticalFilter()
+ : KisConvolutionConstFilter(id(), "emboss", i18n("Emboss Vertical Only"))
+{
+ m_matrix = createKernel( 0, -1, 0 , 0, 2, 0 , 0, -1, 0, 1, 127);
+}
+
+KisEmbossHorizontalFilter::KisEmbossHorizontalFilter() :
+ KisConvolutionConstFilter(id(), "emboss", i18n("Emboss Horizontal Only"))
+{
+ m_matrix = createKernel( 0, 0, 0 , -1, 4, -1 , 0, 0, 0, 1, 127);
+
+}
+
+KisEmbossDiagonalFilter::KisEmbossDiagonalFilter()
+ : KisConvolutionConstFilter(id(), "edge", i18n("Top Edge Detection"))
+{
+ m_matrix = createKernel( -1, 0, -1 , 0, 4, 0 , -1, 0, -1, 1, 127);
+ m_channelFlags = KisChannelInfo::FLAG_COLOR;
+}
+
+
+KisTopEdgeDetectionFilter::KisTopEdgeDetectionFilter()
+ : KisConvolutionConstFilter(id(), "edge", i18n("Top Edge Detection"))
+{
+ m_matrix = createKernel( 1, 1, 1 , 0, 0, 0 , -1, -1, -1, 1, 127);
+ m_channelFlags = KisChannelInfo::FLAG_COLOR;
+
+}
+
+KisRightEdgeDetectionFilter::KisRightEdgeDetectionFilter()
+ : KisConvolutionConstFilter(id(), "edge", i18n("Right Edge Detection"))
+{
+ m_matrix = createKernel( -1, 0, 1 , -1, 0, 1 , -1, 0, 1, 1, 127);
+ m_channelFlags = KisChannelInfo::FLAG_COLOR;
+}
+
+KisBottomEdgeDetectionFilter::KisBottomEdgeDetectionFilter() : KisConvolutionConstFilter(id(), "edge", i18n("Bottom Edge Detection"))
+{
+ m_matrix = createKernel( -1, -1, -1 , 0, 0, 0 , 1, 1, 1, 1, 127);
+ m_channelFlags = KisChannelInfo::FLAG_COLOR;
+}
+
+KisLeftEdgeDetectionFilter::KisLeftEdgeDetectionFilter() : KisConvolutionConstFilter(id(), "edge", i18n("Left Edge Detection"))
+{
+ m_matrix = createKernel( 1, 0, -1 , 1, 0, -1 , 1, 0, -1, 1, 127);
+ m_channelFlags = KisChannelInfo::FLAG_COLOR;
+}