[gegl] absolute: add new op gegl:abs



commit 98ed1d61cb6f59298765d9ff80e8f1a9ec353169
Author: Øyvind Kolås <pippin gimp org>
Date:   Sun Jul 1 17:51:54 2018 +0200

    absolute: add new op gegl:abs

 operations/common/Makefile.am |  1 +
 operations/common/absolute.c  | 87 +++++++++++++++++++++++++++++++++++++++++++
 2 files changed, 88 insertions(+)
---
diff --git a/operations/common/Makefile.am b/operations/common/Makefile.am
index 04717c6dc..788e2ae9b 100644
--- a/operations/common/Makefile.am
+++ b/operations/common/Makefile.am
@@ -15,6 +15,7 @@ op_LTLIBRARIES = \
 
 gegl_common_la_SOURCES =\
        module.c \
+       absolute.c \
        alien-map.c \
        bilateral-filter.c \
        box-blur.c \
diff --git a/operations/common/absolute.c b/operations/common/absolute.c
new file mode 100644
index 000000000..615112f65
--- /dev/null
+++ b/operations/common/absolute.c
@@ -0,0 +1,87 @@
+/* This file is an image processing operation for GEGL
+ *
+ * GEGL is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 3 of the License, or (at your option) any later version.
+ *
+ * GEGL 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
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with GEGL; if not, see <http://www.gnu.org/licenses/>.
+ *
+ * Copyright 2018 Øyvind Kolås <pippin gimp org>
+ */
+
+#include "config.h"
+#include <glib/gi18n-lib.h>
+
+
+#ifdef GEGL_PROPERTIES
+
+   /* no properties */
+
+#else
+
+#define GEGL_OP_POINT_FILTER
+#define GEGL_OP_NAME     absolute
+#define GEGL_OP_C_SOURCE absolute.c
+
+#include "gegl-op.h"
+
+static inline float own_fabs (float val)
+{
+  if (val < 0.0f)
+    return -val;
+  return val;
+}
+
+static gboolean
+process (GeglOperation       *op,
+         void                *in_buf,
+         void                *out_buf,
+         glong                samples,
+         const GeglRectangle *roi,
+         gint                 level)
+{
+  gfloat *in  = in_buf;
+  gfloat *out = out_buf;
+
+  while (samples--)
+    {
+      out[0] = own_fabs (in[0]);
+      out[1] = own_fabs (in[1]);
+      out[2] = own_fabs (in[2]);
+      out[3] = in[3];
+
+      in += 4;
+      out+= 4;
+    }
+  return TRUE;
+}
+
+static void
+gegl_op_class_init (GeglOpClass *klass)
+{
+  GeglOperationClass            *operation_class;
+  GeglOperationPointFilterClass *point_filter_class;
+
+  operation_class    = GEGL_OPERATION_CLASS (klass);
+  point_filter_class = GEGL_OPERATION_POINT_FILTER_CLASS (klass);
+
+  point_filter_class->process  = process;
+
+  gegl_operation_class_set_keys (operation_class,
+    "name",        "gegl:absolute",
+    "title",       _("Absolute"),
+    "compat-name", "gegl:abs",
+    "categories" , "color",
+    "description",
+       _("makes each linear RGB component be the absolute of its value, fabs(input_value)"),
+    NULL);
+}
+
+#endif


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]