iPhone - 使图像适应视网膜显示
我有一个关于更新 iPhone 4 视网膜显示屏的应用程序图形的问题。
我将每个视图的分辨率保持为 480 x 320 点。
所以我想知道:假设我有一个 100 x 50 UIImageView。 对于我要加载的实际图像来说,200 x 100 像素 @ 163 ppi 或 100 x 50 像素 @ 326 ppi 更好?就“亮度”而言,这是一样的吗?哪种方式是首选方式?
谢谢,你太棒了
洛伦佐
I have a question about updating my app's graphics for the retina display of the iPhone 4.
I am keeping each view's resolution to 480 x 320 Points.
So I was wondering: suppose I have a 100 x 50 UIImageView.
It's better for my actual image I am going to load to be 200 x 100 pixels @ 163 ppi or 100 x 50 pixels @ 326 ppi? Is it the same thing in terms of 'lightness'? which is the preferred way?
Thanks, you're awesome
Lorenzo
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
1) 按照上面的描述将 UIImageView 定义为 100 x 50 像素。
2) 拥有一个 100x50 像素的图像文件“MyImage”和第二个 200x100 像素的图像文件,并将其命名为“MyImage@2x”。
3) 在您的代码中,引用图像文件“MyImage”。
iOS 会自动选择正确的图像。在没有视网膜显示屏的旧设备(即 iPhone 3GS)上,将使用“MyImage”文件。在具有视网膜显示屏的较新设备上,将使用“@2x”版本。
1) Define your UIImageView to be 100 x 50 pixels as you describe it above.
2) Have one image file that is 100x50 pixels "MyImage", and a second image file that is 200x100 pixels, and name it "MyImage@2x".
3) In your code, refer to the image file "MyImage".
iOS will automatically select the correct image. On older devices without the retina display (i.e., iPhone 3GS), the "MyImage" file will be used. On newer devices that have the retina display, the "@2x" version will be used.
嗯,好问题。
因为我不知道苹果如何检查图像,也许你应该加载 200x100 的图像(通过使用 @2x 命名文件,例如 [电子邮件受保护] 而不是 image.png)。
但如果您尝试其他选项并进行一些基准测试,请随时告诉我们结果!
祝你好运
Hummm good question.
As I don't know how Apple is checking images, maybe you should load the 200x100 ones (by naming the file with @2x like [email protected] instead of image.png).
But if you try the other option and do some benchmarks, don't hesitate to tell us the results !
Good Luck
如果我错了,请纠正我,我不是图形专家,但这是我对这个主题的理解:
PPI - 每英寸像素(或点) - 它不是图像数据的属性,而是图像数据的属性屏幕(硬件),理论上你并不能真正控制它。换句话说,png文件并不描述每英寸要显示多少个点,它只会描述每个像素的颜色。
图像文件的 PPI 是不存在的。在决定图像的分辨率时,您应该牢记目标设备的 PPI,以便图像以正确的尺寸显示在屏幕上,而不必在软件中拉伸图像并失去清晰度。 100x100 的图像在 1 英寸屏幕上显示为 100ppi,相同图像在 2 英寸屏幕上显示为 50ppi。
简而言之:
图像没有 PPI,它们有分辨率,这将决定文件的大小。
Please correct me if i'm wrong, i'm not a graphics expert, but this is my understanding of the subject:
PPI - Pixels (or points) Per Inch - it is not a property of the image data, it's a property of the screen (hardware), and you in theory don't really have control over it. In other words, a png file does not describe how many points are to be displayed per inch, it will only describe the color of each pixel.
There is no such thing as an image file's PPI. You should keep the PPI of the target device in mind when deciding the image's resolution, in order for it to appear with the right size on the screen without having to stretch it out in your software and losing sharpness. A 100x100 image displayed on a 1 inch screen with have 100ppi, the same image on a 2 inch screen will be displayed with 50ppi.
So in short:
Images don't have PPI's, they have resolutions, and this is what will decide the file's size.