{"id":12483,"date":"2010-10-21T07:00:00","date_gmt":"2010-10-21T07:00:00","guid":{"rendered":"https:\/\/blogs.msdn.microsoft.com\/oldnewthing\/2010\/10\/21\/the-evolution-of-the-ico-file-format-part-3-alpha-blended-images\/"},"modified":"2010-10-21T07:00:00","modified_gmt":"2010-10-21T07:00:00","slug":"the-evolution-of-the-ico-file-format-part-3-alpha-blended-images","status":"publish","type":"post","link":"https:\/\/devblogs.microsoft.com\/oldnewthing\/20101021-00\/?p=12483","title":{"rendered":"The evolution of the ICO file format, part 3: Alpha-blended images"},"content":{"rendered":"<p>Windows&nbsp;XP introduced the ability to provide icon images which contain an 8-bit alpha channel. Up until this point, you had only a 1-bit alpha channel, represented by a <i>mask<\/i>.\n The representation of an alpha-blended image in your ICO file is pretty straightforward. Recall that the old ICO format supports 0RGB 32bpp bitmaps. To use an alpha-blended image, just drop in a ARGB 32bpp bitmap instead. When the window manager sees a 32bpp bitmap, it looks at the alpha channel. If it&#8217;s all zeroes, then it assumes that the image is in 0RGB format; otherwise it assumes it is in ARGB format. Everything else remains the same as for the non-alpha version.\n Note carefully that <i>everything else remains the same<\/i>. In particular, you are still required to provide a mask. I&#8217;ve seen some people be a bit lazy about providing a meaningful mask and just pass in all-zeroes. And everything seems to work just fine, until you hit a case where it doesn&#8217;t work. (Read on.)\n There are basically three ways of drawing an alpha-blended icon image.<\/p>\n<ol>\n<li><code>Draw&shy;Icon(DI_NORMAL)<\/code>:     This is by far the most common way icons are drawn.     In the alpha-blended case, this is done by     blending the <i>image<\/i> with the destination according to the     alpha channel. <\/li>\n<li><code>Draw&shy;Icon(DI_IMAGE)<\/code>:     This draws the <i>image<\/i> portion of the icon image,     completely overwriting the destination. <\/li>\n<li><code>Draw&shy;Icon(DI_MASK)<\/code>:     This draws only the <i>mask<\/i> portion of the icon image,     completely overwriting the destination. <\/li>\n<\/ol>\n<p> The <code>DI_IMAGE<\/code> and <code>DI_MASK<\/code> flags let an application draw just one of the two images contained in an icon image. Applications do this if they want finer control over the icon-drawing process. For example, they might ask for the mask so they can build a shadow effect under the icon. The mask tells them which parts of the icon are opaque and therefore should cast a shadow.\n If you understand this, then you can see how people who set their <i>mask<\/i> image to all-zeroes managed to get away with it most of the time. Since most programs just use <code>DI_NORMAL<\/code> to draw icons, the incorrect mask is never used, so the error never shows up. It&#8217;s only when the icon is used by a program that wants to do fancy icon effects and asks for <code>DI_MASK<\/code> (or calls <code>Get&shy;Icon&shy;Info<\/code> and looks at the <code>hbmMask<\/code>) that the incorrect mask results in an ugly icon.<\/p>\n<p> The ironic thing is that the people who incorrectly set the mask to all-zeroes are probably the same people who will then turn around and say, &#8220;When I try to use alpha-blended icons, the result is hideously ugly under conditions X&nbsp;and&nbsp;Y. Those Microsoft programmers are such idiots. More proof that Windows is a buggy pile of manure.&#8221; What they don&#8217;t realize is that the hideous ugliness was caused by their own error. <\/p>\n","protected":false},"excerpt":{"rendered":"<p>Windows&nbsp;XP introduced the ability to provide icon images which contain an 8-bit alpha channel. Up until this point, you had only a 1-bit alpha channel, represented by a mask. The representation of an alpha-blended image in your ICO file is pretty straightforward. Recall that the old ICO format supports 0RGB 32bpp bitmaps. To use an [&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-12483","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-oldnewthing","tag-other"],"acf":[],"blog_post_summary":"<p>Windows&nbsp;XP introduced the ability to provide icon images which contain an 8-bit alpha channel. Up until this point, you had only a 1-bit alpha channel, represented by a mask. The representation of an alpha-blended image in your ICO file is pretty straightforward. Recall that the old ICO format supports 0RGB 32bpp bitmaps. To use an [&hellip;]<\/p>\n","_links":{"self":[{"href":"https:\/\/devblogs.microsoft.com\/oldnewthing\/wp-json\/wp\/v2\/posts\/12483","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=12483"}],"version-history":[{"count":0,"href":"https:\/\/devblogs.microsoft.com\/oldnewthing\/wp-json\/wp\/v2\/posts\/12483\/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=12483"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/oldnewthing\/wp-json\/wp\/v2\/categories?post=12483"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/oldnewthing\/wp-json\/wp\/v2\/tags?post=12483"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}