Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What are pixels and points in iOS?

Tags:

ios

pixel

iphone

from UIImage reference:

@property(nonatomic, readonly) CGSize size

The dimensions of the image, taking orientation into account.

Discussion

In iOS 4.0 and later, this value reflects the logical size of the image and is measured in points. In iOS 3.x and earlier, this value always reflects the dimensions of the image measured in pixels.

What's the difference between pixels and points in iOS?

like image 699
eugene Avatar asked Aug 18 '12 14:08

eugene


People also ask

What is iOS pixel?

A pixel on iOS is the full resolution of the device, which means if I have an image that is 100x100 pixels in length, then the phone will render it 100x100 pixels on a standard non-retina device.

What's the difference between points and pixels?

Point is a physical unit of length, used in typography. It's equal to 1/12 Pica, and 1 Pica = 1/6 inch. So 1 pt = 1/72 inch. Therefore, on a 72 ppi display, 1 point = 1 pixel.

How many pixels are in a point?

A point (pt) is equal to 0.352778 millimeters, 0.0138889 inches, or 1.333 pixels.

What is 1x 2x and 3x in iOS?

1x, 2x, and 3x images allow developers and Apple to optimize app presentation based on the user's device, whether an entry-level iPhone or the most expensive iPad. Conceptually, 1x, 2x, and 3x images are the same image -- simply at different sizes.


3 Answers

A pixel on iOS is the full resolution of the device, which means if I have an image that is 100x100 pixels in length, then the phone will render it 100x100 pixels on a standard non-retina device. However, because newer iPhones have a quadrupled pixel density, that same image will render at 100x100 pixels, but look half that size. The iOS engineers solved this a long time ago (way back in OS X with Quartz) when they introduced Core Graphics' point system. A point is a standard length equivalent to 1x1 pixels on a non-retina device, and 2x2 pixels on a retina device. That way, your 100x100 image will render twice the size on a retina device and basically normalize what the user sees.

It also provides a standard system of measurement on iOS devices because no matter how the pixel density changes, there have always been 320x480 points on an iPhone screen and 768x1024 points on an iPad screen.*

But at the same time, you can basically disregard the documentation considering that retina devices were introduced with iOS 4 at a minimum, and I don't know of too many people still running iOS 3 on a newer iPhone. But if such a case arises, your UIImage would need to be rendered at exactly twice its dimensions in pixels on a retina iPhone to make up for the pixel density difference.

*Starting with the iPhone 5, the iPhone's dimensions are now no longer standardized. Please use the appropriate APIs to retrieve the screen's dimensions or use layout constraints.

like image 57
CodaFi Avatar answered Oct 09 '22 06:10

CodaFi


The Ultimate Guide To iPhone Resolutions

enter image description here

These guys did an awesome job, take a look here — The Ultimate Guide To iPhone Resolutions.

like image 42
Zorayr Avatar answered Oct 09 '22 06:10

Zorayr


Using data from http://www.paintcodeapp.com/news/ultimate-guide-to-iphone-resolutions I set up the formula sqrt(pointWidth^2+pointHeight^2)/diagonalInches to figure out how many points each phone displayed per inch.

Results:

  • iPhone 2G, 3G, 3GS, 4, 4s = 164.825201164068082 Points Per Inch

  • iPhone 5, 5s = 162.9846618550346903

  • iPhone 6 = 162.8061416117083255

  • iPhone 6 Plus = 153.535954278463216

As you can tell a point is roughly the same size on each phone. Using the same webopage, you can set up the same formula with the pixel values, and you'll notice large irregularities due to higher pixel densities on the newer phones.

like image 35
Jacob R Avatar answered Oct 09 '22 04:10

Jacob R