app: added gegl erase mode

This commit is contained in:
Ville Sokk
2012-04-28 19:34:10 +03:00
committed by Michael Natterer
parent c24ff24311
commit c5d7aaf52e
2 changed files with 36 additions and 12 deletions

View File

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

View File

@ -3,6 +3,7 @@
* *
* gimpoperationerasemode.c * gimpoperationerasemode.c
* Copyright (C) 2008 Michael Natterer <mitch@gimp.org> * Copyright (C) 2008 Michael Natterer <mitch@gimp.org>
* 2012 Ville Sokk <ville.sokk@gmail.com>
* *
* This program is free software; you can redistribute it and/or modify * This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by * it under the terms of the GNU General Public License as published by
@ -72,21 +73,45 @@ gimp_operation_erase_mode_process (GeglOperation *operation,
const GeglRectangle *roi, const GeglRectangle *roi,
gint level) gint level)
{ {
GimpOperationPointLayerMode *point = GIMP_OPERATION_POINT_LAYER_MODE (operation);
gfloat *in = in_buf; gfloat *in = in_buf;
gfloat *layer = aux_buf; gfloat *layer = aux_buf;
gfloat *out = out_buf; gfloat *out = out_buf;
if (point->premultiplied)
{
while (samples--) while (samples--)
{ {
out[RED] = in[RED]; gint b;
out[GREEN] = in[GREEN];
out[BLUE] = in[BLUE]; out[ALPHA] = in[ALPHA] - in[ALPHA] * layer[ALPHA];
out[ALPHA] = in[ALPHA]; for (b = RED; b < ALPHA; b++)
{
out[b] = in[b] / in[ALPHA] * out[ALPHA];
}
in += 4; in += 4;
layer += 4; layer += 4;
out += 4; out += 4;
} }
}
else
{
while (samples--)
{
gint b;
for (b = RED; b < ALPHA; b++)
{
out[b] = in[b];
}
out[ALPHA] = in[ALPHA] - in[ALPHA] * layer[ALPHA];;
in += 4;
layer += 4;
out += 4;
}
}
return TRUE; return TRUE;
} }