views:

3652

answers:

2

Is there a way in the iPhone SDK to calculate the size (in millimeters) of a single pixel?

+7  A: 

Well, the size of a pixel is a constant. The screen size of a current iPhone or iPod touch 2" x 3" (50.8 mm x 76.2 mm) and the resolution is 320 x 480 pixel.

50.8 / 320 (or 76.2 / 480) => the size of 1 pixel is 0.15875 mm x 0.15875 mm

splattne
Agreed, little point to calculate the value of a fixed known value.
schooner
Thanks for that. I did originally think of doing that, but then it occurred to me that if they changed the screen size and resolution in a future model then I would have more changes to make to make my application display nicely on the new device.
Ian1971
Well, I think if future versions change the pixel density (currently 160 ppi) you would check the device model and use different constants. I guess if Apple changes resolution and/or screen size on future models, they will provide that API in an updated SDK.
splattne
indeed the pixel density has been doubled for iphone 4 but no need to test for it in your applications since the coordinates you specify are in points, not pixels. where pixels:points used to have a 1:1 ratio, they now have a 2:1 ratio.
Remover
+2  A: 
Refactor