Commit 6735a7b6 authored by jaycox's avatar jaycox

Make sure we don't divide by zero in scale_region. Fixes bugs #4783 and


	* app/paint_funcs.c:  Make sure we don't divide by zero in
 	scale_region.  Fixes bugs #4783 and #6907.
parent 383663c4
2000-03-18 Jay Cox <jaycox@earthlink.net>
* app/paint_funcs.c: Make sure we don't divide by zero in
scale_region. Fixes bugs #4783 and #6907.
2000-03-17 Birger Langkjer <birger.langkjer@image.dk>
* plug-ins/MapObject/mapobject_ui.c:565: fixed typo/spelling
......
......@@ -4181,26 +4181,31 @@ scale_region (PixelRegion *srcPR,
guchar *d = dest;
for (x = 0; x < width; x++)
{
inv_alpha = 255.0 / p[alpha];
for (b = 0; b < alpha; b++)
if (p[alpha] > 0.001)
{
result = RINT(inv_alpha * p[b]);
if (result < 0)
d[b] = 0;
else if (result > 255)
d[b] = 255;
inv_alpha = 255.0 / p[alpha];
for (b = 0; b < alpha; b++)
{
result = RINT(inv_alpha * p[b]);
if (result < 0)
d[b] = 0;
else if (result > 255)
d[b] = 255;
else
d[b] = result;
}
result = RINT(p[alpha]);
if (result > 255)
d[alpha] = 255;
else
d[b] = result;
d[alpha] = result;
}
result = RINT(p[alpha]);
if (result < 0)
d[alpha] = 0;
else if (result > 255)
d[alpha] = 255;
else
d[alpha] = result;
else /* alpha <= 0 */
for (b = 0; b <= alpha; b++)
d[b] = 0;
d += bytes;
p += bytes;
}
}
else
......
......@@ -4181,26 +4181,31 @@ scale_region (PixelRegion *srcPR,
guchar *d = dest;
for (x = 0; x < width; x++)
{
inv_alpha = 255.0 / p[alpha];
for (b = 0; b < alpha; b++)
if (p[alpha] > 0.001)
{
result = RINT(inv_alpha * p[b]);
if (result < 0)
d[b] = 0;
else if (result > 255)
d[b] = 255;
inv_alpha = 255.0 / p[alpha];
for (b = 0; b < alpha; b++)
{
result = RINT(inv_alpha * p[b]);
if (result < 0)
d[b] = 0;
else if (result > 255)
d[b] = 255;
else
d[b] = result;
}
result = RINT(p[alpha]);
if (result > 255)
d[alpha] = 255;
else
d[b] = result;
d[alpha] = result;
}
result = RINT(p[alpha]);
if (result < 0)
d[alpha] = 0;
else if (result > 255)
d[alpha] = 255;
else
d[alpha] = result;
else /* alpha <= 0 */
for (b = 0; b <= alpha; b++)
d[b] = 0;
d += bytes;
p += bytes;
}
}
else
......
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