ios iPhone 中的像素和点是什么?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/12019170/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
What is pixel and points in iPhone?
提问by eugene
from UIImage reference,
来自 UIImage 参考,
size
The dimensions of the image, taking orientation into account. (read-only)
尺寸
图像的尺寸,考虑到方向。(只读)
@property(nonatomic, readonly) CGSize size
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.
讨论
在 iOS 4.0 及更高版本中,此值反映图像的逻辑大小并以点为单位。在 iOS 3.x 及更早版本中,此值始终反映以像素为单位测量的图像尺寸。
What's the difference between pixel and points?
像素和点有什么区别?
回答by CodaFi
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.
iOS 上的像素是设备的全分辨率,这意味着如果我的图像长度为 100x100 像素,那么手机将在标准非视网膜设备上呈现 100x100 像素。但是,由于较新的 iPhone 的像素密度增加了四倍,因此相同的图像将以 100x100 像素呈现,但看起来只有一半大小。很久以前,iOS 工程师在引入 Core Graphics 的点系统时就解决了这个问题(回到带有 Quartz 的 OS X 中)。点是标准长度,相当于非视网膜设备上的 1x1 像素,视网膜设备上的 2x2 像素。这样,您的 100x100 图像将在视网膜设备上呈现两倍大小,并且基本上使用户看到的内容正常化。
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.*
它还提供了 iOS 设备上的标准测量系统,因为无论像素密度如何变化,iPhone 屏幕上始终有 320x480 点,iPad 屏幕上始终有 768x1024 点。*
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.
但与此同时,考虑到 Retina 设备至少是随 iOS 4 一起引入的,您基本上可以忽略文档,而且我不知道有太多人仍在较新的 iPhone 上运行 iOS 3。但是,如果出现这种情况,您的 UIImage 需要在视网膜 iPhone 上以像素尺寸的两倍渲染,以弥补像素密度差异。
*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.
*从 iPhone 5 开始,iPhone 的尺寸现在不再标准化。请使用适当的 API 来检索屏幕的尺寸或使用布局约束。
回答by Zorayr
The Ultimate Guide To iPhone Resolutions
iPhone 分辨率的终极指南
These guys did an awesome job, take a look here — The Ultimate Guide To iPhone Resolutions.
这些人做得很棒,看看这里 - iPhone 分辨率的终极指南。
回答by Jacob R
Using data from http://www.paintcodeapp.com/news/ultimate-guide-to-iphone-resolutionsI set up the formula sqrt(pointWidth^2+pointHeight^2)/diagonalInches to figure out how many points each phone displayed per inch.
使用来自http://www.paintcodeapp.com/news/ultimate-guide-to-iphone-resolutions 的数据我设置了公式 sqrt(pointWidth^2+pointHeight^2)/diagonalInches 来计算每部手机显示的点数每英寸。
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
iPhone 2G、3G、3GS、4、4s = 每英寸 164.825201164068082 点数
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.
正如你所知道的,每部手机上一个点的大小大致相同。使用相同的网页,您可以使用像素值设置相同的公式,并且由于较新手机的像素密度较高,您会注意到很大的不规则性。