What are pixels and points in iOS?
Asked Answered
D

4

48

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?

Darkness answered 18/8, 2012 at 14:1 Comment(4)
Chec the very first answer : graphicdesign.stackexchange.com/questions/199/…Indubitable
@doNotCheckMyBlog Actually that answer does not apply to iPhone - it's a different kind of point. See CodaFi's answer below for the definition of point in iOS.Paradigm
I try not to be redundant, but this is ESSENTIAL to get correct: TeaCupApp's link is referring to a DIFFERENT definition of point (typography, 1/72 inch), whereas the iOS doc mentioned is referring to a unit that is approximately 1/160 inch (though it varies slightly from device to device). As LoPoBo mentions, CodaFi's answer is technically correct; see picture in Zorayr's answer for an easier to understand and more detailed explanation. It is unfortunate that Apple chose to abuse the widely used term "point" for a unit that is quite different.Ranunculaceous
The key fact to remember is: "points" are approximately the same size on every iOS device. Working in them makes it easier to design consistent layouts.Ranunculaceous
H
67

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.

Halation answered 18/8, 2012 at 14:10 Comment(3)
It's unclear how this answers the question...was this answer moved from somewhere else? I don't see any mention of points in here.Amalgam
The question is, and I quote, “What is the difference between pixels and points?” Aside from the last paragraph and a half that has become inaccurate after 6 years, is there some part of the question in particular I failed to address adequately?Halation
@Halation - this answer is technically correct, but verges on confusing. Would be improved by explaining that "points" are approximately the same size on every iOS device - so they make it easier to design layouts that are consistent, given devices that have different density of pixels (different number of pixels per inch).Ranunculaceous
P
40

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.

Primp answered 20/9, 2015 at 18:31 Comment(1)
But they didn't do it for iPad.Bondswoman
W
2

iOS pixels, points, units

We should review them in context of

  • coordinate systems
  • absolute and relative positioning

Differences

  • pixels(absolute) - pixel-based coordinate systems of current screen. Is used in very specific cases. For example CGImage (The width/height, in pixels, of the required image), CGContext

  • points(virtual pixels, logical pixels)(absolute) - default Point-based coordinate systems. It is a kind of density independent pixel - dp in Android.

  • units - unit coordinate systems(relative). From 0.0 to 1.0. For example CALayer.anchorPoint, VNImageBasedRequest.regionOfInterest, CAGradientLayer.startPoint/endPoint

[iOS Frame vs Bounds]

Waterlogged answered 8/9, 2022 at 19:5 Comment(0)
B
1

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.

Bagpipe answered 3/7, 2015 at 9:8 Comment(6)
OP asked what points and pixels were, so I tried to explain exactly what a point is on iPhone and compare that to a pixel.Bagpipe
the relation between points and pixels in the Apple's SDK is pixels = logicalPoints * scaleFactor. related to OP's question your answer does not make any sense at all.Rydder
@JacobR well, you didn't compare the result to pixels, so I agree with holex that this doesn't answer the question, but this is still useful to know.Ranunculaceous
I think these calculations are incorrect. Could it be because you're using the diagonal, but the angle varies between models based on aspect ratio? For example: iPhone 6 - screen width is 2.3 inches (calculated by dividing specs pixel count (750) by specs dpi (326)); iOS points width is 375. So points per inch = 375/2.3 = 163. Note that for the physical width in inches, if we were to derive it from the diagonal and ratio specs (4.7 inches at 16:9 ratio), we get 2.304227826 inches, which then would make the points per inch 162.744324. Both values are different than the one you calculated.Giorgia
Aren't points supposed to have a fixed physical size (the same for all devices)?Henriquez
@Henriquez No, not at all.Overhasty

© 2022 - 2024 — McMap. All rights reserved.