[gegl/soc-2010-cage] add a gegl op to display the 3 first component of a babl_format_n buffer, thanks to pippin.



commit fce3cb7bc64c4826573cfdabfbaa6a6f6d20d394
Author: Michael Muré <batolettre gmail com>
Date:   Wed Aug 11 20:40:16 2010 +0200

    add a gegl op to display the 3 first component of a babl_format_n buffer, thanks to pippin.

 operations/common/debugit.c |   98 +++++++++++++++++++++++++++++++++++++++++++
 1 files changed, 98 insertions(+), 0 deletions(-)
---
diff --git a/operations/common/debugit.c b/operations/common/debugit.c
new file mode 100644
index 0000000..ee15984
--- /dev/null
+++ b/operations/common/debugit.c
@@ -0,0 +1,98 @@
+/* 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 2010 Michael Muré <batolettre gmail com>
+ *
+ */
+
+#include "config.h"
+#include <glib/gi18n-lib.h>
+
+#include <gegl.h>
+#include <gegl-plugin.h>
+#include <gegl-utils.h>
+
+
+#ifdef GEGL_CHANT_PROPERTIES
+
+#else
+
+#define GEGL_CHANT_TYPE_COMPOSER
+#define GEGL_CHANT_C_FILE       "debugit.c"
+
+#include "gegl-chant.h"
+
+
+static void prepare (GeglOperation *operation)
+{
+  gegl_operation_set_format (operation, "output", babl_format ("RGB float"));
+}
+
+static gboolean
+process (GeglOperation       *operation,
+         GeglBuffer          *input,
+         GeglBuffer          *aux,
+         GeglBuffer          *output,
+         const GeglRectangle *result)
+{
+  const Babl           *format_in, *format_out;
+  gfloat               *in;
+  gfloat               *out;
+  gint                  pixels = result->width * result->height;
+  gint                  i;
+  gint                  components;
+  
+  format_in    = gegl_buffer_get_format (input);
+  format_out   = babl_format ("RGB float");
+  components = babl_format_get_n_components (format_in);
+
+  format_in = babl_format_n (babl_type ("float"), components);
+
+  in = g_malloc (pixels * sizeof (float) * babl_format_get_n_components (format_in));
+  out = g_malloc0 (pixels * babl_format_get_bytes_per_pixel (format_out));
+
+  gegl_buffer_get (input, 1.0, result, format_in, in, GEGL_AUTO_ROWSTRIDE);
+  for (i = 0; i < pixels; i++)
+    {
+      int c;
+      for (c = 0; c < components && c < 3; c++)
+        out[i*3+c] = in[i*components+c];
+    }
+  gegl_buffer_set (output, result, format_out, out, GEGL_AUTO_ROWSTRIDE);
+  g_free (in);
+  g_free (out);
+
+  return TRUE;
+}
+
+static void
+gegl_chant_class_init (GeglChantClass *klass)
+{
+  GeglOperationClass         *operation_class;
+  GeglOperationComposerClass *composer_class;
+
+  operation_class = GEGL_OPERATION_CLASS (klass);
+  composer_class  = GEGL_OPERATION_COMPOSER_CLASS (klass);
+
+  composer_class->process = process;
+  operation_class->prepare = prepare;
+  
+  operation_class->name        = "gegl:debugit";
+  
+  operation_class->categories  = "debug";
+  operation_class->description = _("show the first few components of a format");
+}
+#endif
+



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