1 /* This file is an image processing operation for GEGL
3 * GEGL is free software; you can redistribute it and/or
4 * modify it under the terms of the GNU Lesser General Public
5 * License as published by the Free Software Foundation; either
6 * version 3 of the License, or (at your option) any later version.
8 * GEGL is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
11 * Lesser General Public License for more details.
13 * You should have received a copy of the GNU Lesser General Public
14 * License along with GEGL; if not, see <https://www.gnu.org/licenses/>.
16 * Copyright 2006 Øyvind Kolås <pippin@gimp.org>
17 * Copyright 2006 Geert Jordaens <geert.jordaens@telenet.be>
22 #include <glib/gi18n-lib.h>
25 #ifdef GEGL_PROPERTIES
29 #define GEGL_OP_POINT_FILTER
30 #define GEGL_OP_NAME svg_luminancetoalpha
31 #define GEGL_OP_C_SOURCE svg-luminancetoalpha.c
36 static void prepare (GeglOperation
*operation
)
38 const Babl
*space
= gegl_operation_get_source_space (operation
, "input");
39 const Babl
*format
= babl_format_with_space ("RaGaBaA float", space
);
41 gegl_operation_set_format (operation
, "input", format
);
42 gegl_operation_set_format (operation
, "output", format
);
46 process (GeglOperation
*op
,
50 const GeglRectangle
*roi
,
54 gfloat
*out
= out_buf
;
57 gfloat ma
[25] = { 0.0, 0.0, 0.0, 0.0, 0.0,
58 0.0, 0.0, 0.0, 0.0, 0.0,
59 0.0, 0.0, 0.0, 0.0, 0.0,
60 0.2125, 0.7154, 0.0721, 0.0, 0.0,
61 0.0, 0.0, 0.0, 0.0, 1.0};
65 for (i
=0; i
<n_pixels
; i
++)
67 out
[0] = m
[0] * in
[0] + m
[1] * in
[1] + m
[2] * in
[2] + m
[3] * in
[3] + m
[4];
68 out
[1] = m
[5] * in
[0] + m
[6] * in
[1] + m
[7] * in
[2] + m
[8] * in
[3] + m
[9];
69 out
[2] = m
[10] * in
[0] + m
[11] * in
[1] + m
[12] * in
[2] + m
[13] * in
[3] + m
[14];
70 out
[3] = m
[15] * in
[0] + m
[16] * in
[1] + m
[17] * in
[2] + m
[18] * in
[3] + m
[19];
79 gegl_op_class_init (GeglOpClass
*klass
)
81 GeglOperationClass
*operation_class
;
82 GeglOperationPointFilterClass
*point_filter_class
;
84 operation_class
= GEGL_OPERATION_CLASS (klass
);
85 point_filter_class
= GEGL_OPERATION_POINT_FILTER_CLASS (klass
);
87 point_filter_class
->process
= process
;
88 operation_class
->prepare
= prepare
;
90 gegl_operation_class_set_keys (operation_class
,
91 "name" , "gegl:svg-luminancetoalpha",
92 "categories" , "compositors:svgfilter",
93 "title" , _("SVG Luminance to Alpha"),
94 "needs-alpha", "true",
95 "reference-hash", "6763517c5421d736b855ffa2ebd845c9",
97 _("SVG color matrix operation svg_luminancetoalpha"),