From: glennrp Date: Fri, 11 Mar 2011 18:03:44 +0000 (+0000) Subject: Don't store background color in the colormap if there are already 256 X-Git-Tag: 7.0.1-0~7995 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=a080bc32a4a8b2ffec83fd836a28753959175363;p=imagemagick Don't store background color in the colormap if there are already 256 colors present and we are writing a PNG8. --- diff --git a/ChangeLog b/ChangeLog index ce1827131..aa1985536 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,9 @@ +2011-03-11 6.6.8-4 Glenn Randers-Pehrson + * Don't try to store a bKGD chunk in a PNG8 when there are already + 256 colors in the palette and the background colors is not in that + palette (reference + http://www.imagemagick.org/discourse-server/viewtopic.php?f=3&t=18199); + 2011-03-10 6.6.8-4 Cristy * Fx is a mathematicals function. Do not treat transparency as black. diff --git a/coders/png.c b/coders/png.c index b4eb16cf0..cd66d0dc7 100644 --- a/coders/png.c +++ b/coders/png.c @@ -7189,8 +7189,7 @@ static MagickBooleanType WriteOnePNGImage(MngInfo *mng_info, */ for (i=0; ibackground_color)) + if (IsColorEqual(opaque+i, &image->background_color)) break; } @@ -7200,10 +7199,20 @@ static MagickBooleanType WriteOnePNGImage(MngInfo *mng_info, opaque[i].opacity = OpaqueOpacity; number_opaque++; } + else if (logging != MagickFalse) + (void) LogMagickEvent(CoderEvent,GetMagickModule(), + " No room in the colormap to add background color"); } image_colors=number_opaque+number_transparent+number_semitransparent; + if (mng_info->write_png8 != MagickFalse && image_colors > 256) + { + /* No room for the background color; remove it. */ + number_opaque--; + image_colors--; + } + if (logging != MagickFalse) { if (image_colors > 256)