/* 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 . * * Copyright 2006 Øyvind Kolås * Copyright 2006 Geert Jordaens */ #include "config.h" #include #ifdef GEGL_CHANT_PROPERTIES gegl_chant_string (values, _("Values"), "", _("list of s")) #else #define GEGL_CHANT_TYPE_POINT_FILTER #define GEGL_CHANT_C_FILE "svg-matrix.c" #include "gegl-chant.h" #include #include static void prepare (GeglOperation *operation) { const Babl *format = babl_format ("RaGaBaA float"); gegl_operation_set_format (operation, "input", format); gegl_operation_set_format (operation, "output", format); } static gboolean process (GeglOperation *op, void *in_buf, void *out_buf, glong n_pixels, const GeglRectangle *roi, gint level) { GeglChantO *o = GEGL_CHANT_PROPERTIES (op); gfloat *in = in_buf; gfloat *out = out_buf; gfloat *m; gfloat mi[25] = { 1.0, 0.0, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 0.0, 0.0, 0.0, 1.0}; gfloat ma[25] = { 1.0, 0.0, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 0.0, 0.0, 0.0, 1.0}; char *endptr; gfloat value; const gchar delimiter=','; const gchar *delimiters=" "; gchar **values; glong i; m = ma; if (o->values != NULL) { g_strstrip(o->values); g_strdelimit (o->values, delimiters, delimiter); values = g_strsplit (o->values, ",", 20); for (i = 0 ; i < 20 ; i++) if ( values[i] != NULL ) { value = g_ascii_strtod(values[i], &endptr); if (endptr != values[i]) ma[i] = value; else { m = mi; i = 21; } } else { m = mi; i = 21; } g_strfreev(values); } for (i=0; iprocess = process; operation_class->prepare = prepare; gegl_operation_class_set_keys (operation_class, "name" , "gegl:svg-matrix", "categories" , "compositors:svgfilter", "description", _("SVG color matrix operation svg_matrix"), NULL); } #endif