[gegl] cast-space: new op in workshop
- From: Øyvind "pippin" Kolås <ok src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gegl] cast-space: new op in workshop
- Date: Wed, 11 Jul 2018 07:41:46 +0000 (UTC)
commit 07d96bc9864613912e8e946914fc26047e62b4fb
Author: Øyvind Kolås <pippin gimp org>
Date: Wed Jul 11 09:39:28 2018 +0200
cast-space: new op in workshop
Op for reassigning a new space to the image data entering on input.
operations/workshop/Makefile.am | 1 +
operations/workshop/cast-space.c | 133 +++++++++++++++++++++++++++++++++++++++
po/POTFILES.in | 1 +
3 files changed, 135 insertions(+)
---
diff --git a/operations/workshop/Makefile.am b/operations/workshop/Makefile.am
index 06e7922a3..5b2982c41 100644
--- a/operations/workshop/Makefile.am
+++ b/operations/workshop/Makefile.am
@@ -11,6 +11,7 @@ LIBS = $(op_libs)
opdir = $(ext_dir)
op_LTLIBRARIES = \
bayer-matrix.la \
+ cast-space.la \
bilateral-filter-fast.la \
demosaic-bimedian.la \
demosaic-simple.la \
diff --git a/operations/workshop/cast-space.c b/operations/workshop/cast-space.c
new file mode 100644
index 000000000..6d610c59e
--- /dev/null
+++ b/operations/workshop/cast-space.c
@@ -0,0 +1,133 @@
+/* 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 2014 Michael Natterer <mitch gimp org>
+ *
+ */
+
+#include "config.h"
+#include <glib/gi18n-lib.h>
+
+#ifdef GEGL_PROPERTIES
+
+property_string (space, _("Space"), "sRGB")
+ description (_("space to assign, using babls names"))
+property_format (babl_space, _("Babl space"), NULL)
+ description (_("pointer to a babl space"))
+property_file_path (icc_path, _("ICC path"), "")
+ description (_("Path to ICC matrix profile to load"))
+
+#else
+
+#define GEGL_OP_FILTER
+#define GEGL_OP_NAME cast_space
+#define GEGL_OP_C_SOURCE cast-space.c
+
+#include "gegl-op.h"
+#include <stdio.h>
+
+static void
+prepare (GeglOperation *operation)
+{
+ const Babl *in_format = gegl_operation_get_source_format (operation,
+ "input");
+ GeglProperties *o = GEGL_PROPERTIES (operation);
+ const Babl *space = babl_space (o->space);
+ if (o->babl_space)
+ space = o->babl_space;
+ if (o->icc_path)
+ {
+ gchar *icc_data = NULL;
+ gsize icc_length;
+ g_file_get_contents (o->icc_path, &icc_data, &icc_length, NULL);
+ if (icc_data)
+ {
+ const char *error = NULL;
+ const Babl *s = babl_icc_make_space ((void*)icc_data, icc_length,
+ BABL_ICC_INTENT_RELATIVE_COLORIMETRIC, &error);
+ if (s) space = s;
+ g_free (icc_data);
+ }
+ }
+ if (!space)
+ {
+ fprintf (stderr, "unknown space %s\n", o->space);
+ }
+
+ gegl_operation_set_format (operation, "input",
+ babl_format_with_space ("R'G'B'A float", in_format));
+ gegl_operation_set_format (operation, "output",
+ babl_format_with_space ("R'G'B'A float", space));
+}
+
+static gboolean
+process (GeglOperation *operation,
+ GeglOperationContext *context,
+ const gchar *output_prop,
+ const GeglRectangle *roi,
+ gint level)
+{
+ //GeglProperties *o = GEGL_PROPERTIES (operation);
+ const Babl *in_format = gegl_operation_get_format (operation, "input");
+ const Babl *out_format = gegl_operation_get_format (operation, "output");
+ GeglBuffer *input;
+ GeglBuffer *output;
+
+ if (strcmp (output_prop, "output"))
+ {
+ g_warning ("cast-format: requested processing of %s pad", output_prop);
+ return FALSE;
+ }
+
+ input = (GeglBuffer*) gegl_operation_context_dup_object (context, "input");
+ if (! input)
+ {
+ g_warning ("cast: received NULL input");
+ return FALSE;
+ }
+
+ output = gegl_buffer_new (roi, in_format);
+
+ gegl_buffer_copy (input, roi, GEGL_ABYSS_NONE,
+ output, roi);
+
+
+ gegl_buffer_set_format (output, out_format);
+
+ g_object_unref (input);
+
+ gegl_operation_context_take_object (context, "output", G_OBJECT (output));
+
+ return TRUE;
+}
+
+static void
+gegl_op_class_init (GeglOpClass *klass)
+{
+ GeglOperationClass *operation_class = GEGL_OPERATION_CLASS (klass);
+
+ operation_class->prepare = prepare;
+ operation_class->process = process;
+ operation_class->no_cache = FALSE;
+
+ gegl_operation_class_set_keys (operation_class,
+ "name", "gegl:cast-space",
+ "title", _("Cast space"),
+ "categories", "core:color",
+ "description", _("assign a different babl space"),
+ NULL);
+}
+
+#endif
diff --git a/po/POTFILES.in b/po/POTFILES.in
index 9d5065e21..b9a279dd2 100644
--- a/po/POTFILES.in
+++ b/po/POTFILES.in
@@ -240,6 +240,7 @@ operations/transform/shear.c
operations/transform/transform.c
operations/transform/transform-core.c
operations/transform/translate.c
+operations/workshop/cast-space.c
operations/workshop/bayer-matrix.c
operations/workshop/bilateral-filter-fast.c
operations/workshop/demosaic-bimedian.c
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]