{"id":131,"date":"2011-01-07T15:39:29","date_gmt":"2011-01-07T04:39:29","guid":{"rendered":"http:\/\/blog.quppa.net\/2011\/01\/07\/small-icon-size-dpi-in-windows\/"},"modified":"2011-01-07T15:39:29","modified_gmt":"2011-01-07T04:39:29","slug":"small-icon-size-dpi-in-windows","status":"publish","type":"post","link":"https:\/\/www.quppa.net\/blog\/2011\/01\/07\/small-icon-size-dpi-in-windows\/","title":{"rendered":"Small Icon Size &#038; DPI in Windows"},"content":{"rendered":"<p>The <a title=\"MSDN: GetSystemMetrics Function\" href=\"http:\/\/msdn.microsoft.com\/en-us\/library\/ms724385(v=vs.85).aspx\">GetSystemMetrics function<\/a> in Windows retrieves system metrics and configuration settings. One such metric is the recommended size (width and height) of \u2018small icons\u2019:<\/p>\n<blockquote>\n<p>Small icons typically appear in window captions and in small icon view.<\/p>\n<\/blockquote>\n<p>Another place where small icons show up is the notification area.<\/p>\n<p>MSDN contains a guide to <a title=\"MSDN: Creating a DPI-Aware Application\" href=\"http:\/\/msdn.microsoft.com\/en-us\/library\/ms701681(v=vs.85).aspx\">Creating DPI-Aware Applications<\/a>. It notes the challenge posed by <a title=\"Wikipedia: Raster graphics\" href=\"http:\/\/en.wikipedia.org\/wiki\/Bitmap_graphics\">raster graphics<\/a> and different DPIs. Unlike <a title=\"Wikipedia: Vector graphics\" href=\"http:\/\/en.wikipedia.org\/wiki\/Vector_graphics\">vector graphics<\/a>, which can scale without a loss in quality, distinct raster images must be created for different resolutions in order to avoid unpleasant scaling artefacts. (In fact, this is perhaps overstating the benefits of vector graphics: the level of detail suitable for a high-resolution image is not necessarily suitable for a low-resolution image, so using the same vector for all sizes doesn\u2019t always make sense.) Windows icons, as of Windows 7, contain only raster graphics.<\/p>\n<h1><\/h1>\n<h1>Small Icon Sizes<\/h1>\n<p>The small icon size varies according to the system DPI and OS version:<\/p>\n<table border=\"0\" cellspacing=\"0\" cellpadding=\"2\" width=\"400\">\n<tbody>\n<tr>\n<td valign=\"top\" width=\"133\">DPI Setting<\/td>\n<td valign=\"top\" width=\"133\">Windows 7, XP<\/td>\n<td valign=\"top\" width=\"133\">Windows Vista<\/td>\n<\/tr>\n<tr>\n<td valign=\"top\" width=\"133\">96 (Default, 100%)<\/td>\n<td valign=\"top\" width=\"133\">16&#215;16<\/td>\n<td valign=\"top\" width=\"133\">16&#215;16<\/td>\n<\/tr>\n<tr>\n<td valign=\"top\" width=\"133\">120 (125%)<\/td>\n<td valign=\"top\" width=\"133\">20&#215;20<\/td>\n<td valign=\"top\" width=\"133\">22&#215;22<\/td>\n<\/tr>\n<tr>\n<td valign=\"top\" width=\"133\">144 (150%)<\/td>\n<td valign=\"top\" width=\"133\">24&#215;24<\/td>\n<td valign=\"top\" width=\"133\">26&#215;26<\/td>\n<\/tr>\n<tr>\n<td valign=\"top\" width=\"133\">192 (200%)<\/td>\n<td valign=\"top\" width=\"133\">32&#215;32<\/td>\n<td valign=\"top\" width=\"133\">36&#215;36<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<p>The sizes for Windows Vista (apart from the size at 96 DPI) don\u2019t make much sense \u2013 they don\u2019t match up with the DPI scaling ratio. It is possible that this was a mistake, hence the change in Windows 7.<\/p>\n<p>So, if you want to make sure your small icon (e.g. notify icon) looks beautiful under the widest possible range of systems, you should ideally include the images with the sizes <strong>16&#215;16<\/strong>, <strong>20&#215;20<\/strong>, <strong>22&#215;22<\/strong>, <strong>24&#215;24<\/strong>, <strong>26&#215;26<\/strong>, <strong>32&#215;32<\/strong> and <strong>36&#215;36<\/strong>. If that sounds like a lot of work (it shouldn\u2019t be with a high quality tool like <a title=\"Axialis Software\" href=\"http:\/\/www.axialis.com\/\">Axialis IconWorkshop<\/a>), Microsoft\u2019s own <a title=\"MSDN: Notifications and the Notification Area\" href=\"http:\/\/msdn.microsoft.com\/en-us\/library\/ee330740(v=vs.85).aspx\">recommendation<\/a> is to include <strong>16&#215;16<\/strong> and <strong>32&#215;32<\/strong> pixel icons. Keep in mind, though, that scaling either of those sizes to 20&#215;20 or 22&#215;22 pixels can result in a rather awful-looking icon. While it is still rare to see anything but the default setting of 96 DPI, <a title=\"Engineering Windows 7: Follow-up on High DPI resolution\" href=\"http:\/\/blogs.msdn.com\/b\/e7\/archive\/2008\/09\/13\/follow-up-on-high-dpi-resolution.aspx\">this will not be the case forever<\/a>.<\/p>\n<h1>WinForms Icon Sizes<\/h1>\n<p>When using the <a title=\"MSDN: System.Drawing.Icon Class\" href=\"http:\/\/msdn.microsoft.com\/en-us\/library\/system.drawing.icon.aspx\">System.Drawing.Icon class<\/a>, it is a good idea to use one of the constructors that takes the icon size as a parameter.<\/p>\n<p>Windows Forms conveniently exposes a property called <a title=\"MSDN: SystemInformation.SmallIconSize Property\" href=\"http:\/\/msdn.microsoft.com\/en-us\/library\/system.windows.forms.systeminformation.smalliconsize.aspx\">SmallIconSize<\/a> in the <a title=\"MSDN: SystemInformation Class\" href=\"http:\/\/msdn.microsoft.com\/en-us\/library\/dwa74cb8.aspx\">SystemInformation class<\/a>. This property gives us a <a title=\"MSDN: Size Structure\" href=\"http:\/\/msdn.microsoft.com\/en-us\/library\/system.drawing.size.aspx\">System.Drawing.Size<\/a> corresponding to values listed above, which we can put straight into our icon constructor:<\/p>\n<pre class=\"lang:c# decode:true \">System.Drawing.Icon icon = new System.Drawing.Icon(iconstream, System.Windows.Forms.SystemInformation.SmallIconSize);<\/pre>\n<p>The equivalent properties in WPF are <a title=\"MSDN: SystemParameters.SmallIconWidth Property\" href=\"http:\/\/msdn.microsoft.com\/en-us\/library\/system.windows.systemparameters.smalliconwidth.aspx\">SystemParameters.SmallIconWidth<\/a> and <a title=\"MSDN: SystemParameters.SmallIconHeight\" href=\"http:\/\/msdn.microsoft.com\/en-us\/library\/system.windows.systemparameters.smalliconheight.aspx\">SystemParameters.SmallIconHeight<\/a>.<\/p>\n<p>Both WPF and WinForms wrap around the Win32 <a title=\"MSDN: GetSystemMetrics Function\" href=\"http:\/\/msdn.microsoft.com\/en-us\/library\/ms724385(v=vs.85).aspx\">GetSystemMetrics function<\/a> taking the arguments SM_CXSMICON (small icon width) and SM_CYSMICON (small icon height).<\/p>\n","protected":false},"excerpt":{"rendered":"<p>The GetSystemMetrics function in Windows retrieves system metrics and configuration settings. One such metric is the recommended size (width and height) of \u2018small icons\u2019: Small icons typically appear in window captions and in small icon view. Another place where small icons show up is the notification area. MSDN contains a guide to Creating DPI-Aware Applications. &hellip; <a href=\"https:\/\/www.quppa.net\/blog\/2011\/01\/07\/small-icon-size-dpi-in-windows\/\" class=\"more-link\">Continue reading<span class=\"screen-reader-text\"> &#8220;Small Icon Size &#038; DPI in Windows&#8221;<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[6],"tags":[48,87,88,132,133,134,170,179,185],"class_list":["post-131","post","type-post","status-publish","format-standard","hentry","category-programming","tag-dpi","tag-notification-area","tag-notifyicon","tag-sm_cxsmicon","tag-sm_cysmicon","tag-smalliconsize","tag-win32","tag-winforms","tag-wpf"],"_links":{"self":[{"href":"https:\/\/www.quppa.net\/blog\/wp-json\/wp\/v2\/posts\/131","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.quppa.net\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.quppa.net\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.quppa.net\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.quppa.net\/blog\/wp-json\/wp\/v2\/comments?post=131"}],"version-history":[{"count":0,"href":"https:\/\/www.quppa.net\/blog\/wp-json\/wp\/v2\/posts\/131\/revisions"}],"wp:attachment":[{"href":"https:\/\/www.quppa.net\/blog\/wp-json\/wp\/v2\/media?parent=131"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.quppa.net\/blog\/wp-json\/wp\/v2\/categories?post=131"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.quppa.net\/blog\/wp-json\/wp\/v2\/tags?post=131"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}