[gegl] operations: add gegl:invert-gamma



commit 069384d6989c573d920a18563993e6f56fdc9e98
Author: Michael Henning <drawoc darkrefraction com>
Date:   Sun Jun 23 13:12:21 2013 -0400

    operations: add gegl:invert-gamma

 operations/common/invert-gamma.c |   86 ++++++++++++++++++++++++++++++++++++++
 po/POTFILES.in                   |    1 +
 2 files changed, 87 insertions(+), 0 deletions(-)
---
diff --git a/operations/common/invert-gamma.c b/operations/common/invert-gamma.c
new file mode 100644
index 0000000..62793f7
--- /dev/null
+++ b/operations/common/invert-gamma.c
@@ -0,0 +1,86 @@
+/* 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 2006 Øyvind Kolås <pippin gimp org>
+ */
+
+#include "config.h"
+#include <glib/gi18n-lib.h>
+
+
+#ifdef GEGL_CHANT_PROPERTIES
+
+   /* no properties */
+
+#else
+
+#define GEGL_CHANT_TYPE_POINT_FILTER
+#define GEGL_CHANT_C_FILE       "invert-gamma.c"
+
+#include "gegl-chant.h"
+
+static void
+prepare (GeglOperation *operation)
+{
+  gegl_operation_set_format (operation, "input", babl_format ("R'G'B'A float"));
+  gegl_operation_set_format (operation, "output", babl_format ("R'G'B'A float"));
+}
+
+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] = 1.0 - in[0];
+      out[1] = 1.0 - in[1];
+      out[2] = 1.0 - in[2];
+      out[3] = in[3];
+
+      in += 4;
+      out+= 4;
+    }
+  return TRUE;
+}
+
+static void
+gegl_chant_class_init (GeglChantClass *klass)
+{
+  GeglOperationClass            *operation_class;
+  GeglOperationPointFilterClass *point_filter_class;
+
+  operation_class    = GEGL_OPERATION_CLASS (klass);
+  point_filter_class = GEGL_OPERATION_POINT_FILTER_CLASS (klass);
+
+  operation_class->prepare     = prepare;
+  point_filter_class->process  = process;
+
+  gegl_operation_class_set_keys (operation_class,
+    "name"       , "gegl:invert-gamma",
+    "categories" , "color",
+    "description",
+       _("Inverts the components (except alpha), the result is the "
+         "corresponding \"negative\" image."),
+    NULL);
+}
+
+#endif
diff --git a/po/POTFILES.in b/po/POTFILES.in
index 5d0a8e3..ddfbdff 100644
--- a/po/POTFILES.in
+++ b/po/POTFILES.in
@@ -39,6 +39,7 @@ operations/common/grid.c
 operations/common/high-pass.c
 operations/common/image-compare.c
 operations/common/introspect.c
+operations/common/invert-gamma.c
 operations/common/invert-linear.c
 operations/common/layer.c
 operations/common/lens-distortion.c


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