app: added initial gegl replace mode

This commit is contained in:
Ville Sokk 2012-04-24 12:25:19 +03:00 committed by Michael Natterer
parent 558d4879cd
commit 7eb0d8f4c8
2 changed files with 20 additions and 5 deletions

View file

@ -256,7 +256,6 @@ gimp_gegl_node_set_layer_mode (GeglNode *node,
case GIMP_VALUE_MODE:
case GIMP_COLOR_ERASE_MODE:
case GIMP_ERASE_MODE:
case GIMP_REPLACE_MODE:
case GIMP_ANTI_ERASE_MODE:
gegl_node_set (node,
"operation", "gimp:point-layer-mode",

View file

@ -78,10 +78,26 @@ gimp_operation_replace_mode_process (GeglOperation *operation,
while (samples--)
{
out[RED] = in[RED];
out[GREEN] = in[GREEN];
out[BLUE] = in[BLUE];
out[ALPHA] = in[ALPHA];
gint b;
gfloat ratio = 1 / layer[ALPHA] / layer[ALPHA];
for (b = RED; b < ALPHA; b++)
{
gfloat t;
if (layer[b] > in[b])
{
t = (layer[b] - in[b]) * ratio;
out[b] = in[b] + t;
}
else
{
t= (in[b] - layer[b]) * ratio;
out[b] = in[b] - t;
}
}
out[ALPHA] = layer[ALPHA];
in += 4;
layer += 4;