* Scan the colormap instead of all of the pixels, when possible, to
determine whether the image received by the PNG encoder is grayscale
or black-and-white.
+ * Avoid reading from the colormap in coders/png.c when it is NULL.
2011-02-22 6.6.7-9 Cristy <quetzlzacatenango@image...>
* New version 6.6.7-9.
image_matte=image->matte;
mng_info->IsPalette=image->storage_class == PseudoClass &&
- image_colors <= 256;
+ image_colors <= 256 && image->colormap != NULL;
/*
Allocate the PNG structures
matte=image_matte;
old_bit_depth=0;
- if (mng_info->write_png8)
+ if (mng_info->IsPalette && mng_info->write_png8)
{
/* TO DO: make this a function cause it's used twice, except
ping_have_tRNS=MagickTrue;
}
- if (ping_exclude_bKGD == MagickFalse)
+ if (ping_exclude_bKGD == MagickFalse)
{
- /*
- * Identify which colormap entry is the background color.
- */
+ /*
+ * Identify which colormap entry is the background color.
+ */
+
for (i=0; i < (ssize_t) MagickMax(1L*number_colors-1L,1L); i++)
if (IsPNGColorEqual(ping_background,image->colormap[i]))
break;
{
if (mng_info->IsPalette)
{
-
ping_color_type=PNG_COLOR_TYPE_GRAY_ALPHA;
if (ping_have_color != MagickFalse)
else
{
unsigned int
- mask;
+ mask;
mask=0xffff;
if (ping_exclude_bKGD == MagickFalse)
{
- if ((int) ping_color_type == PNG_COLOR_TYPE_PALETTE)
+ if (mng_info->IsPalette && (int) ping_color_type == PNG_COLOR_TYPE_PALETTE)
{
/*
Identify which colormap entry is the background color.