{"id":12473,"date":"2010-10-22T07:00:00","date_gmt":"2010-10-22T07:00:00","guid":{"rendered":"https:\/\/blogs.msdn.microsoft.com\/oldnewthing\/2010\/10\/22\/the-evolution-of-the-ico-file-format-part-4-png-images\/"},"modified":"2010-10-22T07:00:00","modified_gmt":"2010-10-22T07:00:00","slug":"the-evolution-of-the-ico-file-format-part-4-png-images","status":"publish","type":"post","link":"https:\/\/devblogs.microsoft.com\/oldnewthing\/20101022-00\/?p=12473\/","title":{"rendered":"The evolution of the ICO file format, part 4: PNG images"},"content":{"rendered":"<p>We finish our tour of the evolution of the ICO file format with the introduction of PNG-compressed images in Windows&nbsp;Vista.\n The natural way of introducing PNG support for icon images would be to allow the <code>biCompression<\/code> field of the <code>BITMAP&shy;INFO&shy;HEADER<\/code> to take the value <code>BI_PNG<\/code>, in which case the <i>image<\/i> would be represented not by a DIB but by a PNG. After all, that&#8217;s why we have a <code>biCompression<\/code> field: For forward compatibility with future encoding systems. Wipe the dust off your hands and declare victory.\n Unfortunately, it wasn&#8217;t that simple. If you actually try using ICO files in this format, you&#8217;ll find that a number of popular icon-authoring tools crash when asked to load a PNG-compressed icon file for editing.\n The problem appeared to be that the new <code>BI_PNG<\/code> compression type appeared at a point in the parsing code where it was not prepared to handle such a failure (or the failure was never detected). The solution was to change the file format so that PNG-compressed images fail these programs&#8217; parsers at an earlier, safer step. (This is sort of the opposite of penetration testing, which keeps tweaking data to make the failure occur at a deeper, more dangerous step.)\n Paradoxically, the way to be more compatible is to be less compatible.\n The format of a PNG-compressed image consists simply of a PNG image, starting with the PNG file signature. The image must be in 32bpp ARGB format (known to GDI+ as <code>Pixel&shy;Format&shy;32bpp&shy;ARGB<\/code>). There is no <code>BITMAP&shy;INFO&shy;HEADER<\/code> prefix, and no monochrome mask is present.<\/p>\n<p> Since we had to break compatibility with the traditional format for ICO images, we may as well solve the problem we saw last time of <a href=\"http:\/\/blogs.msdn.com\/b\/oldnewthing\/archive\/2010\/10\/21\/10078690.aspx\"> people who specify an incorrect mask<\/a>. With PNG-compressed images, you do not provide the <i>mask<\/i> at all; the <i>mask<\/i> is derived from the alpha channel on the fly. One fewer thing for people to get wrong. <\/p>\n","protected":false},"excerpt":{"rendered":"<p>We finish our tour of the evolution of the ICO file format with the introduction of PNG-compressed images in Windows&nbsp;Vista. The natural way of introducing PNG support for icon images would be to allow the biCompression field of the BITMAP&shy;INFO&shy;HEADER to take the value BI_PNG, in which case the image would be represented not by [&hellip;]<\/p>\n","protected":false},"author":1069,"featured_media":111744,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"footnotes":""},"categories":[1],"tags":[26],"class_list":["post-12473","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-oldnewthing","tag-other"],"acf":[],"blog_post_summary":"<p>We finish our tour of the evolution of the ICO file format with the introduction of PNG-compressed images in Windows&nbsp;Vista. The natural way of introducing PNG support for icon images would be to allow the biCompression field of the BITMAP&shy;INFO&shy;HEADER to take the value BI_PNG, in which case the image would be represented not by [&hellip;]<\/p>\n","_links":{"self":[{"href":"https:\/\/devblogs.microsoft.com\/oldnewthing\/wp-json\/wp\/v2\/posts\/12473","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/devblogs.microsoft.com\/oldnewthing\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/devblogs.microsoft.com\/oldnewthing\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/oldnewthing\/wp-json\/wp\/v2\/users\/1069"}],"replies":[{"embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/oldnewthing\/wp-json\/wp\/v2\/comments?post=12473"}],"version-history":[{"count":0,"href":"https:\/\/devblogs.microsoft.com\/oldnewthing\/wp-json\/wp\/v2\/posts\/12473\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/oldnewthing\/wp-json\/wp\/v2\/media\/111744"}],"wp:attachment":[{"href":"https:\/\/devblogs.microsoft.com\/oldnewthing\/wp-json\/wp\/v2\/media?parent=12473"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/oldnewthing\/wp-json\/wp\/v2\/categories?post=12473"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/oldnewthing\/wp-json\/wp\/v2\/tags?post=12473"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}