Conevrting an empty image from grayscale to indexed caused a division by

zero. Fixed this the way it was already handled for empty RGB images.


--Sven
This commit is contained in:
Sven Neumann 1998-04-13 14:26:46 +00:00
parent e70e0388eb
commit 5574104b88
4 changed files with 59 additions and 9 deletions

View File

@ -1,3 +1,8 @@
Mon Apr 13 16:22:38 MEST 1998 Sven Neumann <sven@gimp.org>
* app/convert.c: converting an empty image from grayscale to
indexed used to crash the gimp
Mon Apr 13 15:37:42 MEST 1998 Sven Neumann <sven@gimp.org>
* app/gdisplay.c: correctly update the menu-sensitivity; you can't

View File

@ -27,6 +27,9 @@
*/
/*
* 98/04/13 - avoid a division by zero when converting an empty gray-scale
* image (who would like to do such a thing anyway??) [Sven ]
*
* 98/03/23 - fixed a longstanding fencepost - hopefully the *right*
* way, *again*. (anyone ELSE want a go? okay, just kidding... :))
* [Adam]
@ -1482,9 +1485,21 @@ compute_color_gray (QuantizeObj *quantobj,
}
}
quantobj->cmap[icolor].red = (gtotal + (total >> 1)) / total;
quantobj->cmap[icolor].green = quantobj->cmap[icolor].red;
quantobj->cmap[icolor].blue = quantobj->cmap[icolor].red;
if (total != 0)
{
quantobj->cmap[icolor].red = (gtotal + (total >> 1)) / total;
quantobj->cmap[icolor].green = quantobj->cmap[icolor].red;
quantobj->cmap[icolor].blue = quantobj->cmap[icolor].red;
}
else /* The only situation where total==0 is if the image was null or
* all-transparent. In that case we just put a dummy value in
* the colourmap.
*/
{
quantobj->cmap[icolor].red =
quantobj->cmap[icolor].green =
quantobj->cmap[icolor].blue = 0;
}
}
static void

View File

@ -27,6 +27,9 @@
*/
/*
* 98/04/13 - avoid a division by zero when converting an empty gray-scale
* image (who would like to do such a thing anyway??) [Sven ]
*
* 98/03/23 - fixed a longstanding fencepost - hopefully the *right*
* way, *again*. (anyone ELSE want a go? okay, just kidding... :))
* [Adam]
@ -1482,9 +1485,21 @@ compute_color_gray (QuantizeObj *quantobj,
}
}
quantobj->cmap[icolor].red = (gtotal + (total >> 1)) / total;
quantobj->cmap[icolor].green = quantobj->cmap[icolor].red;
quantobj->cmap[icolor].blue = quantobj->cmap[icolor].red;
if (total != 0)
{
quantobj->cmap[icolor].red = (gtotal + (total >> 1)) / total;
quantobj->cmap[icolor].green = quantobj->cmap[icolor].red;
quantobj->cmap[icolor].blue = quantobj->cmap[icolor].red;
}
else /* The only situation where total==0 is if the image was null or
* all-transparent. In that case we just put a dummy value in
* the colourmap.
*/
{
quantobj->cmap[icolor].red =
quantobj->cmap[icolor].green =
quantobj->cmap[icolor].blue = 0;
}
}
static void

View File

@ -27,6 +27,9 @@
*/
/*
* 98/04/13 - avoid a division by zero when converting an empty gray-scale
* image (who would like to do such a thing anyway??) [Sven ]
*
* 98/03/23 - fixed a longstanding fencepost - hopefully the *right*
* way, *again*. (anyone ELSE want a go? okay, just kidding... :))
* [Adam]
@ -1482,9 +1485,21 @@ compute_color_gray (QuantizeObj *quantobj,
}
}
quantobj->cmap[icolor].red = (gtotal + (total >> 1)) / total;
quantobj->cmap[icolor].green = quantobj->cmap[icolor].red;
quantobj->cmap[icolor].blue = quantobj->cmap[icolor].red;
if (total != 0)
{
quantobj->cmap[icolor].red = (gtotal + (total >> 1)) / total;
quantobj->cmap[icolor].green = quantobj->cmap[icolor].red;
quantobj->cmap[icolor].blue = quantobj->cmap[icolor].red;
}
else /* The only situation where total==0 is if the image was null or
* all-transparent. In that case we just put a dummy value in
* the colourmap.
*/
{
quantobj->cmap[icolor].red =
quantobj->cmap[icolor].green =
quantobj->cmap[icolor].blue = 0;
}
}
static void