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>
20 #include <glib/gi18n-lib.h>
22 #ifdef GEGL_PROPERTIES
28 #define GEGL_OP_POINT_FILTER
29 #define GEGL_OP_NAME unpremultiply
30 #define GEGL_OP_C_SOURCE unpremultiply.c
35 process (GeglOperation
*op
,
39 const GeglRectangle
*roi
,
44 gfloat
*out
= out_buf
;
46 for (i
=0; i
<samples
; i
++)
52 out
[j
] = in
[j
] / in
[3];
65 gegl_op_class_init (GeglOpClass
*klass
)
67 GeglOperationClass
*operation_class
;
68 GeglOperationPointFilterClass
*point_filter_class
;
70 operation_class
= GEGL_OPERATION_CLASS (klass
);
71 point_filter_class
= GEGL_OPERATION_POINT_FILTER_CLASS (klass
);
73 point_filter_class
->process
= process
;
75 gegl_operation_class_set_keys (operation_class
,
76 "name" , "gegl:unpremultiply",
77 "categories" , "color",
78 "title" , _("Unpremultiply alpha"),
79 "reference-hash", "1e2a03d51d8cc5868c1921fdee58b2c9",
80 "description" , _("Unpremultiplies a buffer that contains pre-multiplied colors (but according to the babl format is not.)"),