11

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

2 Answers 2

29

Answering the question as asked about the size of pixels:

Pixel size on an iPhone and iPod Touch

  1. The earlier iPhones (pre-iPhone 4) Apple iPhone Technical Specifications said : 480-by-320-pixel resolution at 163 pixels per inch(ppi). About 0.006135 inches per pixel or 0.1558282 mm per pixel.

  2. The first three iPod touch generations stated the same 163 ppi.

  3. The iPhone 4 specs said 960-by-640-pixel resolution at 326 ppi . So pixel width is 1 inch / 326 pixels per inch or about 0.003067 inches per pixel or 0.0779 mm per pixel. You use points, not pixels. Edit: As noted in Olaf's comment, below, pixels are actually addressable, using half-points.

  4. The fourth generation iPod touch (Sept 2010) has specs the same as the iPhone 4, 960-by-640-pixel resolution at 326 ppi

  5. The iPhone 4S (Oct 2011) is unchanged from the iPhone 4 in terms of resolution.

  6. The iPhone 5 (Sept 2012) specs said 1136-by-640 pixel resolution at 326 ppi. Pixel size is unchanged. Screen diagonal is 4 inches.

  7. The iPhone 5C and iPhone 5S (Sept 2013) have the same resolution, pixel size, and diagonal as the iPhone 5.

  8. The iPhone 6, 4.7 inch, (Sept 2014) specs are 1334-by-750-pixel resolution, at 326 pixels per inch (ppi). pixel size is unchanged from 4, 4S, 5 5s.

  9. The iPhone 6 Plus, 5.5 inch, (Sept 2014) specs are 1920-by-1080-pixel resolution, at 401 pixels per inch (ppi). pixel size is about 20% smaller. The pixel width is 1 inch / 401 pixels per inch or about 0.002494 inches per pixel or 0.06334 mm per pixel.

Pixel size on an iPad

  1. The iPad 1 and 2 are 9.7 inch (diagonal) display with 1024-by-768-pixel resolution at 132 ppi per the iPad specs. That is about .0075758 inches per pixel or 0.1924 mm per pixel.

  2. The new iPad (March 2012) is a 9.7 inch (diagonal) display with 2048-by-1536-pixel resolution at 264 ppi per the current iPad specs. That is about .0037879 inches per pixel or 0.09621 mm per pixel.
  3. The iPad Mini (1st generation - October 2012) is a 7.9 inch (diagonal) display with a 1024-by-768-pixel resolution at 163 ppi per the original iPad mini specs. That is about .006135 inches per pixel or 0.156 mm per pixel.
  4. The iPad Mini 2 (2nd generation - October 2013) is a 7.9 inch (diagonal) display with a 2048-by-1536-pixel resolution at 326 ppi per the current iPad mini specs. That is about .0030675 inches per pixel or 0.0779 mm per pixel.
  5. The iPad Air 2 (October 2014) and the iPad Mini 3 (October 2014) have the same resolution, pixel size, and diagonal as the previous versions of those products.

    Comparison of the iPad Air, and iPad Air 2, iPad Mini, iPad 2 and iPad3.

You don't need to have the iPhone SDK calculate the size of a single pixel. One option is to determine what you are running on and then select the needed mm size.

The iPhone (up to and including the 4S) / iPod Touch screen sizes, with a 3.5 inch (diagonal) display are NOT exactly 2" x 3". They are a tiny bit smaller than that. The iPhone 5 has a 4 inch (diagonal) display.

What the questioner may actually need: points. See Removers comment to the previous answer. Coordinates are specified in points, not pixels.

5
  • of course they are individually addressable. You can specify positions on half-points, which would make your graphics look fuzzy on old iphones, but just as crisp on iphone 4. (or you could use opengl, or an offscreen buffer and copy it to the screen for low-level access) Nov 2, 2010 at 0:34
  • When people are saying 960 by 640 or 640 x 960 here, why are they not saying whether this is portrait or landscape mode? Please specify.
    – Volomike
    Nov 13, 2012 at 16:19
  • The mode depends on how you are holding the iPhone or iPad. See this stackoverflow.com/questions/4482893/…
    – Refactor
    Dec 2, 2012 at 2:49
  • The iPad Mini resolution is 163 ppi, not 162 ppi. Per spec linked in the answer.
    – yurish
    Aug 5, 2013 at 9:51
  • This all is true unless an app runs in upscaled mode: e.g when the app has no launch image for iphone6, the app runs ins iPhone5 emulation mode, giving schreen width and height of an iphone5. So to correctly detect the current point size measured in milimters , one has to find out the machine name, and store a table of known screen sizes in milimiter. and then caluclate via the got mainscreen.size
    – AlexWien
    Jul 25, 2015 at 19:38
25

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

4
  • Agreed, little point to calculate the value of a fixed known value.
    – schooner
    Mar 4, 2009 at 11:46
  • 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
    Mar 4, 2009 at 11:49
  • 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
    Mar 4, 2009 at 11:55
  • 4
    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
    Jul 14, 2010 at 21:56

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.