applied a slightly modified version of the patch from Luidnel Maignan as

2008-08-12  Sven Neumann  <sven@gimp.org>

	* app/paint-funcs/paint-funcs.c (replace_inten_pixels): applied 
a
	slightly modified version of the patch from Luidnel Maignan as
	attached to bug #105568. Fixes incorrect alpha treatment in
	plug-in selection masking.


svn path=/trunk/; revision=26524
This commit is contained in:
Sven Neumann 2008-08-12 20:01:19 +00:00 committed by Sven Neumann
parent 1a7bdc570d
commit f35066ffe4
2 changed files with 50 additions and 38 deletions

View File

@ -1,3 +1,10 @@
2008-08-12 Sven Neumann <sven@gimp.org>
* app/paint-funcs/paint-funcs.c (replace_inten_pixels): applied a
slightly modified version of the patch from Luidnel Maignan as
attached to bug #105568. Fixes incorrect alpha treatment in
plug-in selection masking.
2008-08-12 Sven Neumann <sven@gimp.org>
* app/widgets/gimphistogrameditor.c

View File

@ -1391,6 +1391,8 @@ behind_indexed_pixels (const guchar *src1,
* The operation is still bounded by mask/opacity constraints
*/
#define INT_DIV(a, b) ((a)/(b) + (((a) % (b)) > ((b) / 2)))
static inline void
replace_inten_pixels (const guchar *src1,
const guchar *src2,
@ -1402,54 +1404,57 @@ replace_inten_pixels (const guchar *src1,
guint bytes1,
guint bytes2)
{
const guint has_alpha1 = HAS_ALPHA (bytes1);
const guint has_alpha2 = HAS_ALPHA (bytes2);
const guint bytes = MIN (bytes1, bytes2);
guint b;
gint tmp;
const guint has_alpha1 = HAS_ALPHA (bytes1);
const guint has_alpha2 = HAS_ALPHA (bytes2);
const guint alpha = bytes1 - has_alpha1;
const guint alpha2 = bytes2 - has_alpha2;
const guchar *m = mask ? mask : &no_mask;
guint b;
gint tmp;
if (mask)
while (length --)
{
const guchar *m = mask;
guchar src1_alpha = has_alpha1 ? src1[alpha] : 255;
guchar src2_alpha = has_alpha2 ? src2[alpha2] : 255;
guchar new_alpha = INT_BLEND (src2_alpha, src1_alpha,
INT_MULT (*m, opacity, tmp), tmp);
while (length --)
if (new_alpha && affect[b])
{
guchar mask_alpha = INT_MULT (*m, opacity, tmp);
guint ratio = *m * opacity;
for (b = 0; b < bytes; b++)
dest[b] = (affect[b] ?
INT_BLEND (src2[b], src1[b], mask_alpha, tmp) :
src1[b]);
ratio = INT_DIV (ratio, new_alpha);
if (has_alpha1 && !has_alpha2)
dest[b] = src1[b];
m++;
src1 += bytes1;
src2 += bytes2;
dest += bytes1;
for (b = 0; b < alpha; b++)
{
if (src2[b] > src1[b])
{
guint t = (src2[b] - src1[b]) * ratio;
dest[b] = src1[b] + INT_DIV (t, 255);
}
else
{
guint t = (src1[b] - src2[b]) * ratio;
dest[b] = src1[b] - INT_DIV (t, 255);
}
}
}
}
else
{
const guchar mask_alpha = opacity;
while (length --)
else
{
for (b = 0; b < bytes; b++)
dest[b] = (affect[b] ?
INT_BLEND (src2[b], src1[b], mask_alpha, tmp) :
src1[b]);
if (has_alpha1 && !has_alpha2)
for (b = 0; b < alpha; b++)
dest[b] = src1[b];
src1 += bytes1;
src2 += bytes2;
dest += bytes1;
}
}
if (has_alpha1)
dest[alpha] = affect[alpha] ? new_alpha : src1[alpha];
if (mask)
m++;
src1 += bytes1;
src2 += bytes2;
dest += bytes1;
}
}
/* replace the contents of one pixel row with the other