Patch: fix reading of 24 bit icon files

Hans de Goede <[email protected]>
Newsgroups gmane.comp.video.image-magick.bugs
Message-ID <[email protected]>
Hi All,

Some recent versions of ImageMagick have seen some changes to the .ico handling 
code to support reading 32 bit .ico files which contain a real alpha channel 
instead of an alpha 0/1 bitmask.

These changes have broken support for reading 24 bpp + alpha bitmask .ico 
files, by trying to read an alpha channel there, leading to an early eof.

This patch restores the reading of 24 bit .ico files, by not trying to read an 
alpha channel there, but instead use the alpha bitmask as ImageMagicke did a 
couple of releases ago.

And yes this patch is against a sligthly old version of ImageMagick, but the 
bug is still present in svn trunk.

Regards,

Hans

_______________________________________________
Magick-bugs mailing list
[email protected]
http://studio.imagemagick.org/mailman/listinfo/magick-bugs
ImageMagick-6.3.8-icon-read.patch (text/plain, 1 KB)
diff -up ImageMagick-6.3.8/coders/icon.c~ ImageMagick-6.3.8/coders/icon.c
--- ImageMagick-6.3.8/coders/icon.c~	2008-04-01 17:30:58.000000000 +0200
+++ ImageMagick-6.3.8/coders/icon.c	2008-04-01 17:30:58.000000000 +0200
@@ -501,7 +501,7 @@ static Image *ReadICONImage(const ImageI
             q->blue=ScaleCharToQuantum((unsigned char) ReadBlobByte(image));
             q->green=ScaleCharToQuantum((unsigned char) ReadBlobByte(image));
             q->red=ScaleCharToQuantum((unsigned char) ReadBlobByte(image));
-            if (image->matte != MagickFalse)
+            if (icon_info.bits_per_pixel == 32)
               q->opacity=(Quantum) QuantumRange-ScaleCharToQuantum(
                 (unsigned char) ReadBlobByte(image));
             q++;
@@ -527,7 +527,7 @@ static Image *ReadICONImage(const ImageI
         ThrowReaderException(CorruptImageError,"ImproperImageHeader");
     }
     (void) SyncImage(image);
-    if (icon_info.bits_per_pixel <= 16)
+    if (icon_info.bits_per_pixel != 32)
       {
         /*
           Read the ICON alpha mask.
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.