{"id":223,"date":"2006-11-10T10:30:32","date_gmt":"2006-11-10T17:30:32","guid":{"rendered":"http:\/\/www.red-sweater.com\/blog\/223\/resolution-independent-fever"},"modified":"2007-06-03T09:05:22","modified_gmt":"2007-06-03T16:05:22","slug":"resolution-independent-fever","status":"publish","type":"post","link":"https:\/\/redsweater.com\/blog\/223\/resolution-independent-fever","title":{"rendered":"Resolution Independent Fever"},"content":{"rendered":"<p>Resolution independence is the notion that all graphics on a computer display should be zoomable to an arbitrary multiplier without losing quality. If you know even the slightest thing about computer graphics, you&#8217;ll understand that in a resolution independent world, bitmaps are out and vector graphics are in. Vector graphics can scale gracefully to an arbitrary resolution, while bitmap graphics inevitably lose quality.<\/p>\n<p>\nBitmaps specify a graphical image as a grid of colored dots that, when combined at high enough resolution, may create the illusion of a photorealistic image, or a smoothly curved contour. For the time being, we&#8217;re stuck with grids of pixels, because that&#8217;s how our monitors and (most) printers work. Over the course of computer history, bitmap graphics have gotten larger to accommodate increasing display resolutions. For instance, icons &#8220;looked fine&#8221; in Mac System 7 at 32 by 32 pixels, because most monitors were not more than 640 by 480. As monitor sizes grow, the standard sizes for icons and other graphics grow along with them. Suddenly the System 7 icon looks like crap when forced to participate in this modern world:\n<\/p>\n<p>\n<img decoding=\"async\" src=\"http:\/\/www.red-sweater.com\/blog\/images\/ResolutionSideSide.png\"\/>\n<\/p>\n<p>\nSo, <a href=\"http:\/\/ranchero.com\/marsedit\/\">MarsEdit<\/a> pretty, <a href=\"http:\/\/www.mathemaesthetics.com\/ResorcererIndex.html\">Resorcerer<\/a> ugly, right? For now, anyway. Time marches on, and one day we&#8217;re sure to find ourselves struggling to appreciate the relatively low resolution of the MarsEdit icon, too. Look what happens if we quadruple the resolution (caveat, this is from the screen capture, not necessarily from the highest quality available in the MarsEdit bundle):\n<\/p>\n<p>\n<img decoding=\"async\" src=\"http:\/\/www.red-sweater.com\/blog\/images\/MarsEditZoomed.png\"\/>\n<\/p>\n<p>\nSuddenly the cracks are beginning to show. So what&#8217;s the big deal? Can&#8217;t we just continue to improve image quality as resolutions increase? We could, except that the limits of resolution are about to be completely blown away. Resolution independence will debut as a user-level feature in Mac OS X (and Windows Vista, as I understand it) giving users the ability to choose the resolution at which they wish to view any graphics on their screen. Apple has a few documents on this that are worth reviewing<\/p>\n<ul>\n<li><a href=\"http:\/\/developer.apple.com\/releasenotes\/GraphicsImaging\/RN-ResolutionIndependentUI\/\">Resolution Independent UI Release Notes<\/a><\/li>\n<li><a href=\"http:\/\/developer.apple.com\/releasenotes\/Carbon\/RN-CarbonResolutionIndependence\/\">Carbon Resolution Independence Notes<\/a><\/li>\n<\/ul>\n<p>What this means for developers is that every piece of bitmap graphics in your application is now liable to be zoomed to such a degree that it looks like ass. How much like ass? You can get a sneak peek at how well your graphics survive resolution independence by using a little-known feature of the Quartz Debug application (part of developer tools). Select &#8220;Show User Interface Resolution&#8221; from the Tools menu to see the following window:\n<\/p>\n<p>\n<img decoding=\"async\" src=\"http:\/\/www.red-sweater.com\/blog\/images\/QuartzDebugResolution.png\"\/>\n<\/p>\n<p>\nYou&#8217;ll have to quit and relaunch your application to see it at the zoomed level. Now that you know how bad the problem is, what&#8217;s the solution? In order to prevent our graphics looking like ass, they themselves need to be resolution independent. This means they either need to be drawn on the fly, or created and saved in a vector-based format. Ugh! Lots of work. The good news is that lots of designers have been using vector-based art for their work for some time, and can probably accommodate the changes pretty easily. But if you&#8217;re a cheap hack like me, you&#8217;ve probably got lots of bitmaps around that will need to be revised.\n<\/p>\n<p>\n<a href=\"http:\/\/boredzo.org\/\">Peter Hosey<\/a> noticed one such cheap bitmap in <a href=\"http:\/\/www.red-sweater.com\/blog\/219\/flextime-11\">FlexTime 1.1<\/a>: the new pie-chart table header cell. It looks fine at 12&#215;12 pixels, but let&#8217;s see what happens when resolution independence takes its toll:\n<\/p>\n<p>\n<img decoding=\"async\" src=\"http:\/\/www.red-sweater.com\/blog\/images\/ScalingBitmapPie.jpg\"\/>\n<\/p>\n<p>\nYikes! Peter was nice enough to send along a solution, which was a small EPS source file that, when compiled into PDF, made a fast and resolution-independent graphic resource for my product. The only problem was I had some minor qualms with the exact size of the pie-wedge, and wasn&#8217;t comfortable enough in PostScript to easily make (or maintain) the changes. What the heck, I thought, why not do this programatically from Cocoa? I can use NSBezierPath to draw vector scaleable graphics on-the-fly at any resolution. I discovered, with <a href=\"http:\/\/www.noodlesoft.com\/blog\/\">Paul Kim&#8217;s<\/a> help, that <a href=\"http:\/\/developer.apple.com\/documentation\/Cocoa\/Reference\/ApplicationKit\/Classes\/NSCustomImageRep_Class\/Reference\/Reference.html\">NSCustomImageRep<\/a> would allow me to both do all the drawing on the fly, and take advantage of the conveniences of NSImage, such as being able to &#8220;setImage&#8221; on a table header cell. Let&#8217;s see how my pie icon survives zooming now:\n<\/p>\n<p>\n<img decoding=\"async\" src=\"http:\/\/www.red-sweater.com\/blog\/images\/ScalingVectorPie.jpg\"\/>\n<\/p>\n<p>\nWow! That&#8217;s pretty cool. I thought this technique for &#8220;resolution independent generated images&#8221; would be useful for others, so I thought I&#8217;d share some code. But surely you&#8217;d have no use for a quarter-filled pie. Let&#8217;s see, what would be truly useful. A piece of reusable code that will last through the decades, and never turn stale. I know! A little yellow guy!\n<\/p>\n<p>\n<img decoding=\"async\" src=\"http:\/\/www.red-sweater.com\/blog\/images\/ScalingLittleYellowGuy.jpg\"\/>\n<\/p>\n<p>\n<a href=\"http:\/\/www.red-sweater.com\/blog\/downloads\/LittleYellowGuy.zip\">LittleYellowGuy<\/a> contains an example application and Xcode project, demonstrating the creation of an NSImage that draws itself at full resolution for whatever size it&#8217;s set to. This code is available to you under the MIT license.\n<\/p>\n<p>\nNow that my pies and little yellow guys are in order, I can turn my attention to the other vulnerabilities in my interface. Those brand-spanking-new toolbar icons I just designed using PhotoShop? Even they are not ready for 2006.\n<\/p>\n<p>\n<img decoding=\"async\" src=\"http:\/\/www.red-sweater.com\/blog\/images\/ScalingToolbarButton.jpg\"\/>\n<\/p>\n<p>\nBut at least my pie looks good.\n<\/p>\n<\/p>\n<p><strong>Update<\/strong> (Nov 19): This article has inspired a great deal of discussion not only in the comments below but among other blogs. It seems people haev a lot to say about this subject! Many reactions point out that a single vector-based graphic is not likely to look great at all resolutions. Fine-tuning at the pixel level will remain a requirement.  I hadn&#8217;t really considered this, but it makes a lot of sense. Ample payback for the time I spent writing this article!<\/p>\n<p>\nSome of the most substantial reactions are linked to here:\n<\/p>\n<p>\n<a href=\"http:\/\/earthlingsoft.net\/ssp\/blog\/2006\/11\/iconic\">Sven-S. Porst<\/a><br \/>\n<a href=\"http:\/\/www.jasperhauser.nl\/weblog\/2006\/11\/pixel-vs-vector.html\">Jasper Hauser<\/a><br \/>\n<a href=\"http:\/\/iconfactory.com\/home\/permalink\/1731\">Craig Hockenberry<\/a><br \/>\n<a href=\"http:\/\/www.objc.net\/blogger\/2006\/11\/resolution-independent-bullshit-meter.html\">Christopher Lloyd<\/a><br \/>\n<a href=\"http:\/\/stephendeken.net\/index.cgi\/2006\/11\/15\/Vector_Vs_Raster_The_Fools_Game\">Stephen Deken<\/a><br \/>\n<a href=\"http:\/\/islayer.com\/blog\/?p=87\">Marc Edwards<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<p>Resolution independence is the notion that all graphics on a computer display should be zoomable to an arbitrary multiplier without losing quality. If you know even the slightest thing about computer graphics, you&#8217;ll understand that in a resolution independent world, bitmaps are out and vector graphics are in. Vector graphics can scale gracefully to an [&hellip;]<\/p>\n","protected":false},"author":10,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[14,31,11,15,19,5],"tags":[],"class_list":["post-223","post","type-post","status-publish","format-standard","hentry","category-apple","category-carbon","category-cocoa","category-programming","category-technology","category-xcode"],"_links":{"self":[{"href":"https:\/\/redsweater.com\/blog\/wp-json\/wp\/v2\/posts\/223","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/redsweater.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/redsweater.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/redsweater.com\/blog\/wp-json\/wp\/v2\/users\/10"}],"replies":[{"embeddable":true,"href":"https:\/\/redsweater.com\/blog\/wp-json\/wp\/v2\/comments?post=223"}],"version-history":[{"count":0,"href":"https:\/\/redsweater.com\/blog\/wp-json\/wp\/v2\/posts\/223\/revisions"}],"wp:attachment":[{"href":"https:\/\/redsweater.com\/blog\/wp-json\/wp\/v2\/media?parent=223"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/redsweater.com\/blog\/wp-json\/wp\/v2\/categories?post=223"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/redsweater.com\/blog\/wp-json\/wp\/v2\/tags?post=223"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}