Date: Fri, 5 Mar 2010 21:53:33 +0100
Post by Eric Gorr
If you want to draw it pixel for pixel despite the high ppi, use -
pixelsHigh/-pixelsWide, create an NSSize of that size, and draw it
So, the only/recommended way to determine when an image is in this
state is to compare what [image size] returns vs. pixelsHeight &
IIRC, the recommended way is to not care about the number of pixels
of an image, but to draw it by size. Resolution independent display
technologies aren't that far away. With these, image pixels won't
match display pixels even when drawn at 72 dpi (1 pixel = 1 image
If you're "drawing by size", be aware of a longstanding issue with the PNG format, in that resolution in the 'pHYs' chunk can only be specified in meters, meaning there's no exact equivalent for 72 dpi.
I have rdar://5532687 open since 10/10/2007 (!) about this. Basically, if the 'pHYs' chunk in a PNG specifies meters, the nearest equivalent is 72.009. This can distort larger PNGs if you try to draw them as 72 dpi, or at some exact ratio. The bug relates to Preview 4.0(467) and up generating PNG files at 72.009 dpi - older versions set the 'pHYs' chunk to "unknown unit", which defaults the image to exact 72 dpi when read by Mac OS X.
Easily verified: open a .icns file in Preview, save as .png, open the file in (say) Photoshop, you'll see the dpi set to 72.009.
I've just tested this again in 10.6.2 (Preview 5.0.1). This now seems to round 72.009 down to 72, so that all appears to be well, but it's not! Preview 4.x showed 72.01.
Anyway, be sure to double-check your PNG files. I just filed this on OpenRadar: http://openradar.appspot.com/radar?id=169405
Rainer Brockerhoff <***@brockerhoff.net>
Belo Horizonte, Brazil
"In the affairs of others even fools are wise
In their own business even sages err."