whitespace cleanup.

2007-04-25  Sven Neumann  <sven@gimp.org>

	* app/paint-funcs/paint-funcs.c: whitespace cleanup.

svn path=/trunk/; revision=22321
This commit is contained in:
Sven Neumann
2007-04-25 11:36:39 +00:00
committed by Sven Neumann
parent 9e0e86f7bd
commit 8bfd436f31
2 changed files with 94 additions and 72 deletions

View File

@ -1,5 +1,7 @@
2007-04-25 Sven Neumann <sven@gimp.org> 2007-04-25 Sven Neumann <sven@gimp.org>
* app/paint-funcs/paint-funcs.c: whitespace cleanup.
* plug-ins/common/despeckle.c: minor cleanups. * plug-ins/common/despeckle.c: minor cleanups.
2007-04-25 Sven Neumann <sven@gimp.org> 2007-04-25 Sven Neumann <sven@gimp.org>

View File

@ -471,7 +471,7 @@ combine_indexed_and_indexed_pixels (const guchar *src1,
while (length --) while (length --)
{ {
guchar new_alpha = INT_MULT(*m , opacity, tmp); guchar new_alpha = INT_MULT (*m , opacity, tmp);
for (b = 0; b < bytes; b++) for (b = 0; b < bytes; b++)
dest[b] = (affect[b] && new_alpha > 127) ? src2[b] : src1[b]; dest[b] = (affect[b] && new_alpha > 127) ? src2[b] : src1[b];
@ -521,7 +521,7 @@ combine_indexed_and_indexed_a_pixels (const guchar *src1,
while (length --) while (length --)
{ {
guchar new_alpha = INT_MULT3(src2[alpha], *m, opacity, tmp); guchar new_alpha = INT_MULT3 (src2[alpha], *m, opacity, tmp);
for (b = 0; b < bytes; b++) for (b = 0; b < bytes; b++)
dest[b] = (affect[b] && new_alpha > 127) ? src2[b] : src1[b]; dest[b] = (affect[b] && new_alpha > 127) ? src2[b] : src1[b];
@ -537,7 +537,7 @@ combine_indexed_and_indexed_a_pixels (const guchar *src1,
{ {
while (length --) while (length --)
{ {
guchar new_alpha = INT_MULT(src2[alpha], opacity, tmp); guchar new_alpha = INT_MULT (src2[alpha], opacity, tmp);
for (b = 0; b < bytes; b++) for (b = 0; b < bytes; b++)
dest[b] = (affect[b] && new_alpha > 127) ? src2[b] : src1[b]; dest[b] = (affect[b] && new_alpha > 127) ? src2[b] : src1[b];
@ -570,7 +570,7 @@ combine_indexed_a_and_indexed_a_pixels (const guchar *src1,
while (length --) while (length --)
{ {
guchar new_alpha = INT_MULT3(src2[alpha], *m, opacity, tmp); guchar new_alpha = INT_MULT3 (src2[alpha], *m, opacity, tmp);
for (b = 0; b < alpha; b++) for (b = 0; b < alpha; b++)
dest[b] = (affect[b] && new_alpha > 127) ? src2[b] : src1[b]; dest[b] = (affect[b] && new_alpha > 127) ? src2[b] : src1[b];
@ -589,7 +589,7 @@ combine_indexed_a_and_indexed_a_pixels (const guchar *src1,
{ {
while (length --) while (length --)
{ {
guchar new_alpha = INT_MULT(src2[alpha], opacity, tmp); guchar new_alpha = INT_MULT (src2[alpha], opacity, tmp);
for (b = 0; b < alpha; b++) for (b = 0; b < alpha; b++)
dest[b] = (affect[b] && new_alpha > 127) ? src2[b] : src1[b]; dest[b] = (affect[b] && new_alpha > 127) ? src2[b] : src1[b];
@ -626,7 +626,7 @@ combine_inten_a_and_indexed_pixels (const guchar *src1,
while (length --) while (length --)
{ {
gint index = src2[0] * 3; gint index = src2[0] * 3;
guchar new_alpha = INT_MULT3(255, *m, opacity, tmp); guchar new_alpha = INT_MULT3 (255, *m, opacity, tmp);
for (b = 0; b < bytes-1; b++) for (b = 0; b < bytes-1; b++)
dest[b] = (new_alpha > 127) ? cmap[index + b] : src1[b]; dest[b] = (new_alpha > 127) ? cmap[index + b] : src1[b];
@ -646,7 +646,7 @@ combine_inten_a_and_indexed_pixels (const guchar *src1,
while (length --) while (length --)
{ {
gint index = src2[0] * 3; gint index = src2[0] * 3;
guchar new_alpha = INT_MULT(255, opacity, tmp); guchar new_alpha = INT_MULT (255, opacity, tmp);
for (b = 0; b < bytes-1; b++) for (b = 0; b < bytes-1; b++)
dest[b] = (new_alpha > 127) ? cmap[index + b] : src1[b]; dest[b] = (new_alpha > 127) ? cmap[index + b] : src1[b];
@ -686,7 +686,7 @@ combine_inten_a_and_indexed_a_pixels (const guchar *src1,
while (length --) while (length --)
{ {
gint index = src2[0] * 3; gint index = src2[0] * 3;
guchar new_alpha = INT_MULT3(src2[alpha], *m, opacity, tmp); guchar new_alpha = INT_MULT3 (src2[alpha], *m, opacity, tmp);
for (b = 0; b < bytes-1; b++) for (b = 0; b < bytes-1; b++)
dest[b] = (new_alpha > 127) ? cmap[index + b] : src1[b]; dest[b] = (new_alpha > 127) ? cmap[index + b] : src1[b];
@ -706,7 +706,7 @@ combine_inten_a_and_indexed_a_pixels (const guchar *src1,
while (length --) while (length --)
{ {
gint index = src2[0] * 3; gint index = src2[0] * 3;
guchar new_alpha = INT_MULT(src2[alpha], opacity, tmp); guchar new_alpha = INT_MULT (src2[alpha], opacity, tmp);
for (b = 0; b < bytes-1; b++) for (b = 0; b < bytes-1; b++)
dest[b] = (new_alpha > 127) ? cmap[index + b] : src1[b]; dest[b] = (new_alpha > 127) ? cmap[index + b] : src1[b];
@ -743,12 +743,11 @@ combine_inten_and_inten_pixels (const guchar *src1,
while (length --) while (length --)
{ {
guchar new_alpha = INT_MULT(*m, opacity, tmp); guchar new_alpha = INT_MULT (*m, opacity, tmp);
for (b = 0; b < bytes; b++) for (b = 0; b < bytes; b++)
dest[b] = (affect[b]) ? dest[b] = (affect[b] ?
INT_BLEND(src2[b], src1[b], new_alpha, tmp) : INT_BLEND (src2[b], src1[b], new_alpha, tmp) : src1[b]);
src1[b];
m++; m++;
@ -763,9 +762,8 @@ combine_inten_and_inten_pixels (const guchar *src1,
{ {
for (b = 0; b < bytes; b++) for (b = 0; b < bytes; b++)
dest[b] = (affect[b]) ? dest[b] = (affect[b] ?
INT_BLEND(src2[b], src1[b], opacity, tmp) : INT_BLEND (src2[b], src1[b], opacity, tmp) : src1[b]);
src1[b];
src1 += bytes; src1 += bytes;
src2 += bytes; src2 += bytes;
@ -796,12 +794,11 @@ combine_inten_and_inten_a_pixels (const guchar *src1,
while (length --) while (length --)
{ {
guchar new_alpha = INT_MULT3(src2[alpha], *m, opacity, t1); guchar new_alpha = INT_MULT3 (src2[alpha], *m, opacity, t1);
for (b = 0; b < bytes; b++) for (b = 0; b < bytes; b++)
dest[b] = (affect[b]) ? dest[b] = (affect[b] ?
INT_BLEND(src2[b], src1[b], new_alpha, t1) : INT_BLEND (src2[b], src1[b], new_alpha, t1) : src1[b]);
src1[b];
m++; m++;
src1 += bytes; src1 += bytes;
@ -815,11 +812,12 @@ combine_inten_and_inten_a_pixels (const guchar *src1,
{ {
while (length --) while (length --)
{ {
guchar new_alpha = INT_MULT(src2[alpha],opacity,t1); guchar new_alpha = INT_MULT (src2[alpha],opacity,t1);
dest[0] = INT_BLEND (src2[0] , src1[0] , new_alpha, t1);
dest[1] = INT_BLEND (src2[1] , src1[1] , new_alpha, t1);
dest[2] = INT_BLEND (src2[2] , src1[2] , new_alpha, t1);
dest[0] = INT_BLEND(src2[0] , src1[0] , new_alpha, t1);
dest[1] = INT_BLEND(src2[1] , src1[1] , new_alpha, t1);
dest[2] = INT_BLEND(src2[2] , src1[2] , new_alpha, t1);
src1 += bytes; src1 += bytes;
src2 += src2_bytes; src2 += src2_bytes;
dest += bytes; dest += bytes;
@ -829,12 +827,12 @@ combine_inten_and_inten_a_pixels (const guchar *src1,
{ {
while (length --) while (length --)
{ {
guchar new_alpha = INT_MULT(src2[alpha],opacity,t1); guchar new_alpha = INT_MULT (src2[alpha],opacity,t1);
for (b = 0; b < bytes; b++) for (b = 0; b < bytes; b++)
dest[b] = (affect[b]) ? dest[b] = (affect[b] ?
INT_BLEND(src2[b] , src1[b] , new_alpha, t1) : INT_BLEND (src2[b] , src1[b] , new_alpha, t1) :
src1[b]; src1[b]);
src1 += bytes; src1 += bytes;
src2 += src2_bytes; src2 += src2_bytes;
@ -944,7 +942,7 @@ combine_inten_a_and_inten_pixels (const guchar *src1,
{ {
guchar src2_alpha = *m; guchar src2_alpha = *m;
guchar new_alpha = guchar new_alpha =
src1[alpha] + INT_MULT((255 - src1[alpha]), src2_alpha, tmp); src1[alpha] + INT_MULT ((255 - src1[alpha]), src2_alpha, tmp);
alphify (src2_alpha, new_alpha); alphify (src2_alpha, new_alpha);
@ -968,9 +966,9 @@ combine_inten_a_and_inten_pixels (const guchar *src1,
{ {
while (length--) while (length--)
{ {
guchar src2_alpha = INT_MULT(*m, opacity, tmp); guchar src2_alpha = INT_MULT (*m, opacity, tmp);
guchar new_alpha = guchar new_alpha =
src1[alpha] + INT_MULT((255 - src1[alpha]), src2_alpha, tmp); src1[alpha] + INT_MULT ((255 - src1[alpha]), src2_alpha, tmp);
alphify (src2_alpha, new_alpha); alphify (src2_alpha, new_alpha);
@ -997,7 +995,7 @@ combine_inten_a_and_inten_pixels (const guchar *src1,
{ {
guchar src2_alpha = opacity; guchar src2_alpha = opacity;
guchar new_alpha = guchar new_alpha =
src1[alpha] + INT_MULT((255 - src1[alpha]), src2_alpha, tmp); src1[alpha] + INT_MULT ((255 - src1[alpha]), src2_alpha, tmp);
alphify (src2_alpha, new_alpha); alphify (src2_alpha, new_alpha);
@ -1053,10 +1051,10 @@ combine_inten_a_and_inten_a_pixels (const guchar *src1,
while (i--) while (i--)
{ {
/* GUTS */ /* GUTS */
guchar src2_alpha = INT_MULT(src2[alpha], *m, tmp); guchar src2_alpha = INT_MULT (src2[alpha], *m, tmp);
guchar new_alpha = guchar new_alpha =
src1[alpha] + src1[alpha] +
INT_MULT((255 - src1[alpha]), src2_alpha, tmp); INT_MULT ((255 - src1[alpha]), src2_alpha, tmp);
alphify (src2_alpha, new_alpha); alphify (src2_alpha, new_alpha);
@ -1093,10 +1091,10 @@ combine_inten_a_and_inten_a_pixels (const guchar *src1,
while (j--) while (j--)
{ {
/* GUTS */ /* GUTS */
guchar src2_alpha = INT_MULT(src2[alpha], *m, tmp); guchar src2_alpha = INT_MULT (src2[alpha], *m, tmp);
guchar new_alpha = guchar new_alpha =
src1[alpha] + src1[alpha] +
INT_MULT((255 - src1[alpha]), src2_alpha, tmp); INT_MULT ((255 - src1[alpha]), src2_alpha, tmp);
alphify (src2_alpha, new_alpha); alphify (src2_alpha, new_alpha);
@ -1136,9 +1134,9 @@ combine_inten_a_and_inten_a_pixels (const guchar *src1,
while (length--) while (length--)
{ {
/* GUTS */ /* GUTS */
guchar src2_alpha = INT_MULT(src2[alpha], *m, tmp); guchar src2_alpha = INT_MULT (src2[alpha], *m, tmp);
guchar new_alpha = guchar new_alpha =
src1[alpha] + INT_MULT((255 - src1[alpha]), src2_alpha, tmp); src1[alpha] + INT_MULT ((255 - src1[alpha]), src2_alpha, tmp);
alphify (src2_alpha, new_alpha); alphify (src2_alpha, new_alpha);
@ -1176,10 +1174,11 @@ combine_inten_a_and_inten_a_pixels (const guchar *src1,
while (i--) while (i--)
{ {
/* GUTS */ /* GUTS */
guchar src2_alpha = INT_MULT3(src2[alpha], *m, opacity, tmp); guchar src2_alpha = INT_MULT3 (src2[alpha], *m, opacity,
tmp);
guchar new_alpha = guchar new_alpha =
src1[alpha] + src1[alpha] +
INT_MULT((255 - src1[alpha]), src2_alpha, tmp); INT_MULT ((255 - src1[alpha]), src2_alpha, tmp);
alphify (src2_alpha, new_alpha); alphify (src2_alpha, new_alpha);
@ -1216,10 +1215,10 @@ combine_inten_a_and_inten_a_pixels (const guchar *src1,
while (j--) while (j--)
{ {
/* GUTS */ /* GUTS */
guchar src2_alpha = INT_MULT3(src2[alpha], *m, opacity, tmp); guchar src2_alpha = INT_MULT3 (src2[alpha], *m, opacity, tmp);
guchar new_alpha = guchar new_alpha =
src1[alpha] + src1[alpha] +
INT_MULT((255 - src1[alpha]), src2_alpha, tmp); INT_MULT ((255 - src1[alpha]), src2_alpha, tmp);
alphify (src2_alpha, new_alpha); alphify (src2_alpha, new_alpha);
@ -1260,10 +1259,10 @@ combine_inten_a_and_inten_a_pixels (const guchar *src1,
while (length--) while (length--)
{ {
/* GUTS */ /* GUTS */
guchar src2_alpha = INT_MULT3(src2[alpha], *m, opacity, tmp); guchar src2_alpha = INT_MULT3 (src2[alpha], *m, opacity, tmp);
guchar new_alpha = guchar new_alpha =
src1[alpha] + src1[alpha] +
INT_MULT((255 - src1[alpha]), src2_alpha, tmp); INT_MULT ((255 - src1[alpha]), src2_alpha, tmp);
alphify (src2_alpha, new_alpha); alphify (src2_alpha, new_alpha);
@ -1294,7 +1293,7 @@ combine_inten_a_and_inten_a_pixels (const guchar *src1,
guchar src2_alpha = src2[alpha]; guchar src2_alpha = src2[alpha];
guchar new_alpha = guchar new_alpha =
src1[alpha] + src1[alpha] +
INT_MULT((255 - src1[alpha]), src2_alpha, tmp); INT_MULT ((255 - src1[alpha]), src2_alpha, tmp);
alphify (src2_alpha, new_alpha); alphify (src2_alpha, new_alpha);
@ -1317,9 +1316,9 @@ combine_inten_a_and_inten_a_pixels (const guchar *src1,
{ {
while (length --) while (length --)
{ {
guchar src2_alpha = INT_MULT(src2[alpha], opacity, tmp); guchar src2_alpha = INT_MULT (src2[alpha], opacity, tmp);
guchar new_alpha = guchar new_alpha =
src1[alpha] + INT_MULT((255 - src1[alpha]), src2_alpha, tmp); src1[alpha] + INT_MULT ((255 - src1[alpha]), src2_alpha, tmp);
alphify (src2_alpha, new_alpha); alphify (src2_alpha, new_alpha);
@ -1460,9 +1459,9 @@ behind_inten_pixels (const guchar *src1,
while (length --) while (length --)
{ {
guchar src1_alpha = src1[alpha]; guchar src1_alpha = src1[alpha];
guchar src2_alpha = INT_MULT3(src2[alpha], *m, opacity, tmp); guchar src2_alpha = INT_MULT3 (src2[alpha], *m, opacity, tmp);
guchar new_alpha = guchar new_alpha =
src2_alpha + INT_MULT((255 - src2_alpha), src1_alpha, tmp); src2_alpha + INT_MULT ((255 - src2_alpha), src1_alpha, tmp);
if (new_alpha) if (new_alpha)
ratio = (float) src1_alpha / new_alpha; ratio = (float) src1_alpha / new_alpha;
@ -1514,7 +1513,7 @@ behind_indexed_pixels (const guchar *src1,
while (length --) while (length --)
{ {
guchar src1_alpha = src1[alpha]; guchar src1_alpha = src1[alpha];
guchar src2_alpha = INT_MULT3(src2[alpha], *m, opacity, tmp); guchar src2_alpha = INT_MULT3 (src2[alpha], *m, opacity, tmp);
guchar new_alpha = guchar new_alpha =
(src2_alpha > 127) ? OPAQUE_OPACITY : TRANSPARENT_OPACITY; (src2_alpha > 127) ? OPAQUE_OPACITY : TRANSPARENT_OPACITY;
@ -1560,11 +1559,11 @@ replace_inten_pixels (const guchar *src1,
while (length --) while (length --)
{ {
guchar mask_alpha = INT_MULT(*m, opacity, tmp); guchar mask_alpha = INT_MULT (*m, opacity, tmp);
for (b = 0; b < bytes; b++) for (b = 0; b < bytes; b++)
dest[b] = (affect[b]) ? dest[b] = (affect[b]) ?
INT_BLEND(src2[b], src1[b], mask_alpha, tmp) : INT_BLEND (src2[b], src1[b], mask_alpha, tmp) :
src1[b]; src1[b];
if (has_alpha1 && !has_alpha2) if (has_alpha1 && !has_alpha2)
@ -1585,7 +1584,7 @@ replace_inten_pixels (const guchar *src1,
{ {
for (b = 0; b < bytes; b++) for (b = 0; b < bytes; b++)
dest[b] = (affect[b]) ? dest[b] = (affect[b]) ?
INT_BLEND(src2[b], src1[b], mask_alpha, tmp) : INT_BLEND (src2[b], src1[b], mask_alpha, tmp) :
src1[b]; src1[b];
if (has_alpha1 && !has_alpha2) if (has_alpha1 && !has_alpha2)
@ -1622,7 +1621,7 @@ replace_indexed_pixels (const guchar *src1,
while (length --) while (length --)
{ {
guchar mask_alpha = INT_MULT(*m, opacity, tmp); guchar mask_alpha = INT_MULT (*m, opacity, tmp);
for (b = 0; b < bytes; b++) for (b = 0; b < bytes; b++)
dest[b] = (affect[b] && mask_alpha) ? src2[b] : src1[b]; dest[b] = (affect[b] && mask_alpha) ? src2[b] : src1[b];
@ -1667,8 +1666,8 @@ erase_inten_pixels (const guchar *src1,
for (b = 0; b < alpha; b++) for (b = 0; b < alpha; b++)
dest[b] = src1[b]; dest[b] = src1[b];
src2_alpha = INT_MULT3(src2[alpha], *m, opacity, tmp); src2_alpha = INT_MULT3 (src2[alpha], *m, opacity, tmp);
dest[alpha] = src1[alpha] - INT_MULT(src1[alpha], src2_alpha, tmp); dest[alpha] = src1[alpha] - INT_MULT (src1[alpha], src2_alpha, tmp);
m++; m++;
@ -1686,8 +1685,8 @@ erase_inten_pixels (const guchar *src1,
for (b = 0; b < alpha; b++) for (b = 0; b < alpha; b++)
dest[b] = src1[b]; dest[b] = src1[b];
src2_alpha = INT_MULT3(src2[alpha], *m, opacity, tmp); src2_alpha = INT_MULT3 (src2[alpha], *m, opacity, tmp);
dest[alpha] = src1[alpha] - INT_MULT(src1[alpha], src2_alpha, tmp); dest[alpha] = src1[alpha] - INT_MULT (src1[alpha], src2_alpha, tmp);
src1 += bytes; src1 += bytes;
src2 += bytes; src2 += bytes;
@ -1722,7 +1721,7 @@ erase_indexed_pixels (const guchar *src1,
for (b = 0; b < alpha; b++) for (b = 0; b < alpha; b++)
dest[b] = src1[b]; dest[b] = src1[b];
src2_alpha = INT_MULT3(src2[alpha], *m, opacity, tmp); src2_alpha = INT_MULT3 (src2[alpha], *m, opacity, tmp);
dest[alpha] = (src2_alpha > 127) ? TRANSPARENT_OPACITY : src1[alpha]; dest[alpha] = (src2_alpha > 127) ? TRANSPARENT_OPACITY : src1[alpha];
if (mask) if (mask)
@ -1755,9 +1754,9 @@ anti_erase_inten_pixels (const guchar *src1,
for (b = 0; b < alpha; b++) for (b = 0; b < alpha; b++)
dest[b] = src1[b]; dest[b] = src1[b];
src2_alpha = INT_MULT3(src2[alpha], *m, opacity, tmp); src2_alpha = INT_MULT3 (src2[alpha], *m, opacity, tmp);
dest[alpha] = dest[alpha] =
src1[alpha] + INT_MULT((255 - src1[alpha]), src2_alpha, tmp); src1[alpha] + INT_MULT ((255 - src1[alpha]), src2_alpha, tmp);
if (mask) if (mask)
m++; m++;
@ -1790,7 +1789,7 @@ anti_erase_indexed_pixels (const guchar *src1,
for (b = 0; b < alpha; b++) for (b = 0; b < alpha; b++)
dest[b] = src1[b]; dest[b] = src1[b];
src2_alpha = INT_MULT3(src2[alpha], *m, opacity, tmp); src2_alpha = INT_MULT3 (src2[alpha], *m, opacity, tmp);
dest[alpha] = (src2_alpha > 127) ? OPAQUE_OPACITY : src1[alpha]; dest[alpha] = (src2_alpha > 127) ? OPAQUE_OPACITY : src1[alpha];
if (mask) if (mask)
@ -1948,9 +1947,9 @@ extract_from_inten_pixels (guchar *src,
if (HAS_ALPHA (src_bytes)) if (HAS_ALPHA (src_bytes))
{ {
dest[alpha] = INT_MULT(*m, src[alpha], tmp); dest[alpha] = INT_MULT (*m, src[alpha], tmp);
if (cut) if (cut)
src[alpha] = INT_MULT((255 - *m), src[alpha], tmp); src[alpha] = INT_MULT ((255 - *m), src[alpha], tmp);
} }
else else
{ {
@ -1959,7 +1958,7 @@ extract_from_inten_pixels (guchar *src,
if (cut) if (cut)
for (b = 0; b < src_bytes; b++) for (b = 0; b < src_bytes; b++)
src[b] = INT_BLEND(bg[b], src[b], *m, tmp); src[b] = INT_BLEND (bg[b], src[b], *m, tmp);
} }
if (mask) if (mask)
@ -2409,7 +2408,9 @@ convolve_region (PixelRegion *srcR,
mode = GIMP_NORMAL_CONVOL; mode = GIMP_NORMAL_CONVOL;
} }
else else
offset = 0; {
offset = 0;
}
/* check for the boundary cases */ /* check for the boundary cases */
if (srcR->w < (size - 1) || srcR->h < (size - 1)) if (srcR->w < (size - 1) || srcR->h < (size - 1))
@ -2427,12 +2428,14 @@ convolve_region (PixelRegion *srcR,
{ {
m = matrix; m = matrix;
i = size; i = size;
while (i --) while (i --)
{ {
j = size; j = size;
while (j --) while (j --)
matrixsum += *m++; matrixsum += *m++;
} }
if (matrixsum == 0.0) if (matrixsum == 0.0)
matrixsum = 1.0; matrixsum = 1.0;
} }
@ -2470,7 +2473,7 @@ convolve_region (PixelRegion *srcR,
s = s_row; s = s_row;
m = matrix; m = matrix;
total [0] = total [1] = total [2] = total [3] = 0.0; total [0] = total [1] = total [2] = total [3] = 0;
weighted_divisor = 0.0; weighted_divisor = 0.0;
i = size; i = size;
@ -2488,10 +2491,13 @@ convolve_region (PixelRegion *srcR,
for (b = 0; b < a_byte; b++) for (b = 0; b < a_byte; b++)
total [b] += mult_alpha * *s++; total [b] += mult_alpha * *s++;
total [a_byte] += *m * *s++; total [a_byte] += *m * *s++;
} }
else else
s += bytes; {
s += bytes;
}
m ++; m ++;
} }
@ -2505,8 +2511,10 @@ convolve_region (PixelRegion *srcR,
for (b = 0; b < bytes; b++) for (b = 0; b < bytes; b++)
{ {
total [b] /= divisor; total [b] /= divisor;
if (b != a_byte) if (b != a_byte)
total [b] = total [b] * matrixsum / weighted_divisor; total [b] = total [b] * matrixsum / weighted_divisor;
total [b] += offset; total [b] += offset;
if (total [b] < 0.0 && mode != GIMP_NORMAL_CONVOL) if (total [b] < 0.0 && mode != GIMP_NORMAL_CONVOL)
@ -2526,7 +2534,7 @@ convolve_region (PixelRegion *srcR,
s = s_row; s = s_row;
m = matrix; m = matrix;
total [0] = total [1] = total [2] = total [3] = 0.0; total [0] = total [1] = total [2] = total [3] = 0;
i = size; i = size;
while (i --) while (i --)
@ -2539,6 +2547,7 @@ convolve_region (PixelRegion *srcR,
total [b] += *m * *s++; total [b] += *m * *s++;
else else
s += bytes; s += bytes;
m ++; m ++;
} }
@ -2564,6 +2573,7 @@ convolve_region (PixelRegion *srcR,
/* handle the last pixel... */ /* handle the last pixel... */
s = s_row + (srcR->rowstride + bytes) * margin; s = s_row + (srcR->rowstride + bytes) * margin;
b = bytes * margin; b = bytes * margin;
while (b --) while (b --)
*d++ = *s++; *d++ = *s++;
@ -2603,13 +2613,17 @@ multiply_alpha_region (PixelRegion *srcR)
for (y = 0; y < height; y++) for (y = 0; y < height; y++)
{ {
s = src; s = src;
for (x = 0; x < width; x++) for (x = 0; x < width; x++)
{ {
alpha_val = s[bytes - 1] * (1.0 / 255.0); alpha_val = s[bytes - 1] * (1.0 / 255.0);
for (b = 0; b < bytes - 1; b++) for (b = 0; b < bytes - 1; b++)
s[b] = 0.5 + s[b] * alpha_val; s[b] = 0.5 + s[b] * alpha_val;
s += bytes; s += bytes;
} }
src += srcR->rowstride; src += srcR->rowstride;
} }
} }
@ -2635,6 +2649,7 @@ separate_alpha_region (PixelRegion *srcR)
for (y = 0; y < height; y++) for (y = 0; y < height; y++)
{ {
s = src; s = src;
for (x = 0; x < width; x++) for (x = 0; x < width; x++)
{ {
/* predicate is equivalent to: /* predicate is equivalent to:
@ -2643,6 +2658,7 @@ separate_alpha_region (PixelRegion *srcR)
if (s[bytes - 1] != 0 && s[bytes - 1] != 255) if (s[bytes - 1] != 0 && s[bytes - 1] != 255)
{ {
alpha_recip = 255.0 / s[bytes - 1]; alpha_recip = 255.0 / s[bytes - 1];
for (b = 0; b < bytes - 1; b++) for (b = 0; b < bytes - 1; b++)
{ {
new_val = 0.5 + s[b] * alpha_recip; new_val = 0.5 + s[b] * alpha_recip;
@ -2650,8 +2666,10 @@ separate_alpha_region (PixelRegion *srcR)
s[b] = new_val; s[b] = new_val;
} }
} }
s += bytes; s += bytes;
} }
src += srcR->rowstride; src += srcR->rowstride;
} }
} }
@ -2798,6 +2816,7 @@ gaussian_blur_region (PixelRegion *srcR,
pixels = b[0]; pixels = b[0];
i += pixels; i += pixels;
if (i > end) if (i > end)
i = end; i = end;
@ -3254,6 +3273,7 @@ thin_region (PixelRegion *region,
for (x = 0; x < region->w; x++) /* set up max for top of image */ for (x = 0; x < region->w; x++) /* set up max for top of image */
{ {
max[x][0] = buf[0][x]; max[x][0] = buf[0][x];
for (j = 1; j < yradius + 1; j++) for (j = 1; j < yradius + 1; j++)
max[x][j] = MIN(buf[j][x], max[x][j-1]); max[x][j] = MIN(buf[j][x], max[x][j-1]);
} }
@ -3261,6 +3281,7 @@ thin_region (PixelRegion *region,
for (y = 0; y < region->h; y++) for (y = 0; y < region->h; y++)
{ {
rotate_pointers (buf, yradius + 1); rotate_pointers (buf, yradius + 1);
if (y < region->h - yradius) if (y < region->h - yradius)
pixel_region_get_row (region, pixel_region_get_row (region,
region->x, region->y + y + yradius, region->w, region->x, region->y + y + yradius, region->w,
@ -3273,9 +3294,8 @@ thin_region (PixelRegion *region,
for (x = 0 ; x < region->w; x++) /* update max array */ for (x = 0 ; x < region->w; x++) /* update max array */
{ {
for (i = yradius; i > 0; i--) for (i = yradius; i > 0; i--)
{ max[x][i] = MIN (MIN (max[x][i - 1], buf[i - 1][x]), buf[i][x]);
max[x][i] = MIN (MIN (max[x][i - 1], buf[i - 1][x]), buf[i][x]);
}
max[x][0] = buf[0][x]; max[x][0] = buf[0][x];
} }