Update Chinese (China) translation
[gegl.git] / operations / common / unpremultiply.c
blob6152d344d58eb343940f16b218377ff7813a2e1d
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>
19 #include "config.h"
20 #include <glib/gi18n-lib.h>
22 #ifdef GEGL_PROPERTIES
24 /* no properties */
26 #else
28 #define GEGL_OP_POINT_FILTER
29 #define GEGL_OP_NAME unpremultiply
30 #define GEGL_OP_C_SOURCE unpremultiply.c
32 #include "gegl-op.h"
34 static gboolean
35 process (GeglOperation *op,
36 void *in_buf,
37 void *out_buf,
38 glong samples,
39 const GeglRectangle *roi,
40 gint level)
42 glong i;
43 gfloat *in = in_buf;
44 gfloat *out = out_buf;
46 for (i=0; i<samples; i++)
48 int j;
49 for (j=0; j<3; j++)
51 if (in[3] != 0)
52 out[j] = in[j] / in[3];
53 else
54 out[j] = 0.0;
56 out[3]=in[3];
57 in += 4;
58 out+= 4;
60 return TRUE;
64 static void
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.)"),
81 NULL);
84 #endif