|
Packit |
bc1512 |
|
|
Packit |
bc1512 |
/* !!!! AUTOGENERATED FILE generated by blend.rb !!!!!
|
|
Packit |
bc1512 |
*
|
|
Packit |
bc1512 |
* This file is an image processing operation for GEGL
|
|
Packit |
bc1512 |
*
|
|
Packit |
bc1512 |
* GEGL is free software; you can redistribute it and/or
|
|
Packit |
bc1512 |
* modify it under the terms of the GNU Lesser General Public
|
|
Packit |
bc1512 |
* License as published by the Free Software Foundation; either
|
|
Packit |
bc1512 |
* version 3 of the License, or (at your option) any later version.
|
|
Packit |
bc1512 |
*
|
|
Packit |
bc1512 |
* GEGL is distributed in the hope that it will be useful,
|
|
Packit |
bc1512 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
Packit |
bc1512 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
Packit |
bc1512 |
* Lesser General Public License for more details.
|
|
Packit |
bc1512 |
*
|
|
Packit |
bc1512 |
* You should have received a copy of the GNU Lesser General Public
|
|
Packit |
bc1512 |
* License along with GEGL; if not, see <http://www.gnu.org/licenses/>.
|
|
Packit |
bc1512 |
*
|
|
Packit |
bc1512 |
* Copyright 2006 Øyvind Kolås <pippin@gimp.org>
|
|
Packit |
bc1512 |
*
|
|
Packit |
bc1512 |
* The formulas used for the blend modes are from:
|
|
Packit |
bc1512 |
* http://www.pegtop.net/delphi/articles/blendmodes/
|
|
Packit |
bc1512 |
*
|
|
Packit |
bc1512 |
* !!!! AUTOGENERATED FILE !!!!!
|
|
Packit |
bc1512 |
*/
|
|
Packit |
bc1512 |
#include "config.h"
|
|
Packit |
bc1512 |
#include <glib/gi18n-lib.h>
|
|
Packit |
bc1512 |
|
|
Packit |
bc1512 |
|
|
Packit |
bc1512 |
#ifdef GEGL_CHANT_PROPERTIES
|
|
Packit |
bc1512 |
|
|
Packit |
bc1512 |
/* no properties */
|
|
Packit |
bc1512 |
|
|
Packit |
bc1512 |
#else
|
|
Packit |
bc1512 |
|
|
Packit |
bc1512 |
#define GEGL_CHANT_TYPE_POINT_COMPOSER
|
|
Packit |
bc1512 |
#define GEGL_CHANT_C_FILE "subtractive.c"
|
|
Packit |
bc1512 |
|
|
Packit |
bc1512 |
#include "gegl-chant.h"
|
|
Packit |
bc1512 |
#include <math.h>
|
|
Packit |
bc1512 |
|
|
Packit |
bc1512 |
static void prepare (GeglOperation *self)
|
|
Packit |
bc1512 |
{
|
|
Packit |
bc1512 |
const Babl *format = babl_format ("RaGaBaA float");
|
|
Packit |
bc1512 |
|
|
Packit |
bc1512 |
gegl_operation_set_format (self, "input", format);
|
|
Packit |
bc1512 |
gegl_operation_set_format (self, "aux", format);
|
|
Packit |
bc1512 |
gegl_operation_set_format (self, "output", format);
|
|
Packit |
bc1512 |
}
|
|
Packit |
bc1512 |
|
|
Packit |
bc1512 |
static gboolean
|
|
Packit |
bc1512 |
process (GeglOperation *op,
|
|
Packit |
bc1512 |
void *in_buf,
|
|
Packit |
bc1512 |
void *aux_buf,
|
|
Packit |
bc1512 |
void *out_buf,
|
|
Packit |
bc1512 |
glong n_pixels,
|
|
Packit |
bc1512 |
const GeglRectangle *roi,
|
|
Packit |
bc1512 |
gint level)
|
|
Packit |
bc1512 |
{
|
|
Packit |
bc1512 |
gfloat *in = in_buf;
|
|
Packit |
bc1512 |
gfloat *aux = aux_buf;
|
|
Packit |
bc1512 |
gfloat *out = out_buf;
|
|
Packit |
bc1512 |
gint i;
|
|
Packit |
bc1512 |
|
|
Packit |
bc1512 |
if (aux == NULL)
|
|
Packit |
bc1512 |
return TRUE;
|
|
Packit |
bc1512 |
|
|
Packit |
bc1512 |
for (i = 0; i < n_pixels; i++)
|
|
Packit |
bc1512 |
{
|
|
Packit |
bc1512 |
gfloat aA, aB;
|
|
Packit |
bc1512 |
gint j;
|
|
Packit |
bc1512 |
|
|
Packit |
bc1512 |
aA = in[3];
|
|
Packit |
bc1512 |
aB = aux[3];
|
|
Packit |
bc1512 |
for (j = 0; j < 3; j++)
|
|
Packit |
bc1512 |
{
|
|
Packit |
bc1512 |
gfloat cA, cB;
|
|
Packit |
bc1512 |
|
|
Packit |
bc1512 |
cA = in[j];
|
|
Packit |
bc1512 |
cB = aux[j];
|
|
Packit |
bc1512 |
out[j] = cA + (cA+cB-1.0-cA) * cB;
|
|
Packit |
bc1512 |
}
|
|
Packit |
bc1512 |
out[j] = aA;
|
|
Packit |
bc1512 |
in += 4;
|
|
Packit |
bc1512 |
aux += 4;
|
|
Packit |
bc1512 |
out += 4;
|
|
Packit |
bc1512 |
}
|
|
Packit |
bc1512 |
|
|
Packit |
bc1512 |
return TRUE;
|
|
Packit |
bc1512 |
}
|
|
Packit |
bc1512 |
|
|
Packit |
bc1512 |
|
|
Packit |
bc1512 |
static void
|
|
Packit |
bc1512 |
gegl_chant_class_init (GeglChantClass *klass)
|
|
Packit |
bc1512 |
{
|
|
Packit |
bc1512 |
GeglOperationClass *operation_class;
|
|
Packit |
bc1512 |
GeglOperationPointComposerClass *point_composer_class;
|
|
Packit |
bc1512 |
|
|
Packit |
bc1512 |
operation_class = GEGL_OPERATION_CLASS (klass);
|
|
Packit |
bc1512 |
point_composer_class = GEGL_OPERATION_POINT_COMPOSER_CLASS (klass);
|
|
Packit |
bc1512 |
|
|
Packit |
bc1512 |
point_composer_class->process = process;
|
|
Packit |
bc1512 |
operation_class->prepare = prepare;
|
|
Packit |
bc1512 |
|
|
Packit |
bc1512 |
gegl_operation_class_set_keys (operation_class,
|
|
Packit |
bc1512 |
"name" , "gegl:subtractive",
|
|
Packit |
bc1512 |
"categories" , "compositors:blend",
|
|
Packit |
bc1512 |
"description" ,
|
|
Packit |
bc1512 |
_("Image blending operation 'subtractive' (<tt>c = cA+cB-1.0</tt>)"),
|
|
Packit |
bc1512 |
NULL);
|
|
Packit |
bc1512 |
}
|
|
Packit |
bc1512 |
|
|
Packit |
bc1512 |
#endif
|