From: glennrp Date: Tue, 17 Jul 2012 19:15:58 +0000 (+0000) Subject: Write 256x256 ICON subimage as PNG32 if image->compression is undefined or zip X-Git-Tag: 7.0.1-0~5253 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=4b708b85d92f5ee5e5996b1b019b45136e45e33a;p=imagemagick Write 256x256 ICON subimage as PNG32 if image->compression is undefined or zip --- diff --git a/coders/icon.c b/coders/icon.c index f530ddd31..744cc74e5 100644 --- a/coders/icon.c +++ b/coders/icon.c @@ -757,6 +757,10 @@ ModuleExport void UnregisterICONImage(void) % image format, version 3 for Windows or (if the image has a matte channel) % version 4. % +% It encodes any subimage as a compressed PNG image ("BI_PNG)", +% only when its dimensions are 256x256 and image->compression is +% undefined or is defined as ZipCompression. +% % The format of the WriteICONImage method is: % % MagickBooleanType WriteICONImage(const ImageInfo *image_info, @@ -863,8 +867,9 @@ static MagickBooleanType WriteICONImage(const ImageInfo *image_info, next=image; do { - if ((next->columns > 256L) && (next->rows > 256L) && - (next->compression == ZipCompression)) + if ((next->columns > 255L) && (next->rows > 255L) && + ((next->compression == UndefinedCompression) || + (next->compression == ZipCompression))) { Image *write_image; @@ -878,19 +883,18 @@ static MagickBooleanType WriteICONImage(const ImageInfo *image_info, unsigned char *png; - /* - Icon image encoded as a compressed PNG image. - */ write_image=CloneImage(next,0,0,MagickTrue,exception); if (write_image == (Image *) NULL) return(MagickFalse); write_info=CloneImageInfo(image_info); (void) CopyMagickString(write_info->filename,"PNG:",MaxTextExtent); - /* - Don't write any ancillary chunks except for gAMA and tRNS. - */ - (void) SetImageArtifact(write_image,"png:include-chunk", - "none,trns,gama"); + + /* Don't write any ancillary chunks except for gAMA */ + (void) SetImageArtifact(write_image,"png:include-chunk","none,gama"); + + /* Only write PNG32 formatted PNG (32-bit RGBA), 8 bits per channel */ + (void) SetImageArtifact(write_image,"png:format","png32"); + png=(unsigned char *) ImageToBlob(write_info,write_image,&length, exception); write_image=DestroyImage(write_image);