Commit 5581372d authored by Garry R. Osgood's avatar Garry R. Osgood Committed by Garry R. Osgood

*app/paint_funcs.c: replace_pixels() was naively zeroing RGB components of

2000-02-16 Garry R. Osgood <gosgood@idt.net>
*app/paint_funcs.c: replace_pixels() was
naively zeroing RGB components of RGBA pixels
when projecting and compositing paint_core
and currently active layer pixels. Closes
#5947. See bug report, and
http://idt.net/~gosgood/gimp-patch/patch06.html
for further detail.
parent 1417c36b
2000-02-16 Garry R. Osgood <gosgood@idt.net>
*app/paint_funcs.c: replace_pixels() was
naively zeroing RGB components of RGBA pixels
when projecting and compositing paint_core
and currently active layer pixels. Closes
#5947. See bug report, and
http://idt.net/~gosgood/gimp-patch/patch06.html
for further detail.
Wed Feb 16 21:42:19 CET 2000 Sven Neumann <sven@gimp.org>
* app/channel_ops.c: copy image parasites on image duplicate
......
......@@ -1281,7 +1281,7 @@ replace_pixels (unsigned char *src1,
}
alpha = bytes1 - 1;
norm_opacity = opacity * (1.0 / 65025.0);
norm_opacity = opacity * (1.0 / 65536.0);
while (length --)
{
......@@ -1290,17 +1290,51 @@ replace_pixels (unsigned char *src1,
s1_a = src1[alpha];
s2_a = src2[alpha];
a_val = s1_a + mask_val * (s2_a - s1_a);
if (a_val == 0)
a_recip = 0;
if (a_val == 0) /* In any case, write out versions of the blending function */
/* that result when combinations of s1_a, s2_a, and */
/* mask_val --> 0 (or mask_val -->1) */
{
/* Case 1: s1_a, s2_a, AND mask_val all approach 0+: */
/* Case 2: s1_a AND s2_a both approach 0+, regardless of mask_val: */
if(s1_a + s2_a == 0.0)
{
for (b = 0; b < alpha; b++)
{
new_val = 0.5 + (double)src1[b] + mask_val*((double)src2[b] - (double)src1[b]);
dest[b] = affect[b] ? MIN (new_val, 255) : src1[b];
}
}
/* Case 3: mask_val AND s1_a both approach 0+, regardless of s2_a */
else if(s1_a + mask_val == 0.0)
{
for (b = 0; b < alpha; b++)
{
dest[b] = src1[b];
}
}
/* Case 4: mask_val -->1 AND s2_a -->0, regardless of s1_a */
else if(1.0 - mask_val + s2_a == 0.0)
{
for (b = 0; b < alpha; b++)
{
dest[b] = affect[b] ? src2[b] : src1[b];
}
}
}
else
a_recip = 1.0 / a_val;
/* possible optimization: fold a_recip into s1_a and s2_a */
for (b = 0; b < alpha; b++)
{
new_val = 0.5 + a_recip * (src1[b] * s1_a + mask_val *
(src2[b] * s2_a - src1[b] * s1_a));
dest[b] = affect[b] ? MIN (new_val, 255) : src1[b];
}
a_recip = 1.0 / a_val;
/* possible optimization: fold a_recip into s1_a and s2_a */
for (b = 0; b < alpha; b++)
{
new_val = 0.5 + a_recip * (src1[b] * s1_a + mask_val *
(src2[b] * s2_a - src1[b] * s1_a));
dest[b] = affect[b] ? MIN (new_val, 255) : src1[b];
}
}
dest[alpha] = affect[alpha] ? a_val + 0.5: s1_a;
src1 += bytes1;
src2 += bytes2;
......
......@@ -1281,7 +1281,7 @@ replace_pixels (unsigned char *src1,
}
alpha = bytes1 - 1;
norm_opacity = opacity * (1.0 / 65025.0);
norm_opacity = opacity * (1.0 / 65536.0);
while (length --)
{
......@@ -1290,17 +1290,51 @@ replace_pixels (unsigned char *src1,
s1_a = src1[alpha];
s2_a = src2[alpha];
a_val = s1_a + mask_val * (s2_a - s1_a);
if (a_val == 0)
a_recip = 0;
if (a_val == 0) /* In any case, write out versions of the blending function */
/* that result when combinations of s1_a, s2_a, and */
/* mask_val --> 0 (or mask_val -->1) */
{
/* Case 1: s1_a, s2_a, AND mask_val all approach 0+: */
/* Case 2: s1_a AND s2_a both approach 0+, regardless of mask_val: */
if(s1_a + s2_a == 0.0)
{
for (b = 0; b < alpha; b++)
{
new_val = 0.5 + (double)src1[b] + mask_val*((double)src2[b] - (double)src1[b]);
dest[b] = affect[b] ? MIN (new_val, 255) : src1[b];
}
}
/* Case 3: mask_val AND s1_a both approach 0+, regardless of s2_a */
else if(s1_a + mask_val == 0.0)
{
for (b = 0; b < alpha; b++)
{
dest[b] = src1[b];
}
}
/* Case 4: mask_val -->1 AND s2_a -->0, regardless of s1_a */
else if(1.0 - mask_val + s2_a == 0.0)
{
for (b = 0; b < alpha; b++)
{
dest[b] = affect[b] ? src2[b] : src1[b];
}
}
}
else
a_recip = 1.0 / a_val;
/* possible optimization: fold a_recip into s1_a and s2_a */
for (b = 0; b < alpha; b++)
{
new_val = 0.5 + a_recip * (src1[b] * s1_a + mask_val *
(src2[b] * s2_a - src1[b] * s1_a));
dest[b] = affect[b] ? MIN (new_val, 255) : src1[b];
}
a_recip = 1.0 / a_val;
/* possible optimization: fold a_recip into s1_a and s2_a */
for (b = 0; b < alpha; b++)
{
new_val = 0.5 + a_recip * (src1[b] * s1_a + mask_val *
(src2[b] * s2_a - src1[b] * s1_a));
dest[b] = affect[b] ? MIN (new_val, 255) : src1[b];
}
}
dest[alpha] = affect[alpha] ? a_val + 0.5: s1_a;
src1 += bytes1;
src2 += bytes2;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment