From: glennrp Date: Sat, 20 Aug 2011 03:43:18 +0000 (+0000) Subject: Merge multiple transparent colors to the background color when writing PNG8. X-Git-Tag: 7.0.1-0~7175 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=130fc4535f884af19ec188e80a5cdcd89b0052e0;p=imagemagick Merge multiple transparent colors to the background color when writing PNG8. --- diff --git a/coders/png.c b/coders/png.c index 7aa749b91..19a7c035f 100644 --- a/coders/png.c +++ b/coders/png.c @@ -8381,9 +8381,11 @@ static MagickBooleanType WriteOnePNGImage(MngInfo *mng_info, break; /* PNG8 can't have semitransparent colors so we threshold the - * alpha to 0 or OpaqueAlpha + * opacity to 0 or OpaqueOpacity, and PNG8 can only have one + * transparent color so if more than one is transparent we merge + * them into image->background_color. */ - if (number_semitransparent != 0) + if (number_semitransparent != 0 || number_transparent > 1) { (void) LogMagickEvent(CoderEvent,GetMagickModule(), " Thresholding the alpha channel to binary"); @@ -10719,7 +10721,9 @@ static MagickBooleanType WriteOnePNGImage(MngInfo *mng_info, % transparent). If other values are present they will be % 50%-thresholded to binary transparency. If more than 256 % colors are present, they will be quantized to the 4-4-4-1, -% 3-3-3-1, or 3-3-2-1 palette. +% 3-3-3-1, or 3-3-2-1 palette. The underlying RGB color +% of any resulting fully-transparent pixels is changed to +% the image's background color. % % If you want better quantization or dithering of the colors % or alpha than that, you need to do it before calling the