app: fix GimpOperationReplaceMode to not do two things different than legacy
This commit is contained in:
@ -174,38 +174,45 @@ gimp_operation_replace_mode_process (GeglOperation *operation,
|
|||||||
gfloat *mask = aux2_buf;
|
gfloat *mask = aux2_buf;
|
||||||
gfloat *out = out_buf;
|
gfloat *out = out_buf;
|
||||||
|
|
||||||
|
|
||||||
while (samples--)
|
while (samples--)
|
||||||
{
|
{
|
||||||
gint b;
|
gint b;
|
||||||
gfloat new_alpha;
|
gfloat new_alpha;
|
||||||
gfloat ratio;
|
|
||||||
|
|
||||||
if (mask)
|
if (mask)
|
||||||
|
new_alpha = (layer[ALPHA] - in[ALPHA]) * (*mask) * opacity + in[ALPHA];
|
||||||
|
else
|
||||||
|
new_alpha = (layer[ALPHA] - in[ALPHA]) * opacity + in[ALPHA];
|
||||||
|
|
||||||
|
if (new_alpha)
|
||||||
{
|
{
|
||||||
new_alpha = (layer[ALPHA] - in[ALPHA]) * (*mask) * opacity + in[ALPHA];
|
gfloat ratio;
|
||||||
ratio = *mask * opacity / layer[ALPHA] / new_alpha;
|
|
||||||
|
if (mask)
|
||||||
|
ratio = *mask * opacity * layer[ALPHA] / new_alpha;
|
||||||
|
else
|
||||||
|
ratio = opacity * layer[ALPHA] / new_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;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
new_alpha = (layer[ALPHA] - in[ALPHA]) * opacity + in[ALPHA];
|
for (b = RED; b < ALPHA; b++)
|
||||||
ratio = opacity / layer[ALPHA] / new_alpha;
|
out[b] = in[b];
|
||||||
}
|
|
||||||
|
|
||||||
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] = new_alpha;
|
out[ALPHA] = new_alpha;
|
||||||
|
Reference in New Issue
Block a user