1

按照这些步骤,我得到了意想不到的结果:

1) 将 UIImage 写入 PNG

2)将PNG读入UIImage

结果:UIImage 的大小(PNG 之前和之后)不同。通过从 PNG 读取创建的 UIImage 的分辨率是用于创建 PNG 的原始 UIImage 的两倍。

Swift 伪代码如下:

var initialImage : UIImage;
// Obtain UIImage from UIImagePickerController, Images.xcassets, ...
// As an example, consider a UIImage with size = (420.0, 280.0).

println("Image size = \(initialImage.size)") // Indicates "Image size = (420.0, 280.0)"

// Write image to file
UIImagePNGRepresentation(myImage).writeToFile(imagePath, atomically: true)

// Retrieve image from file
let newImage = UIImage(contentsOfFile: imagePath)!
println("Image size = \(initialImage.size)") // Indicates "Image size = (840.0, 560.0)"!

否则一切都很好。显示新读取的图像效果很好。

我正在运行这个连接到 iPhone 6。任何想法将不胜感激。

加里

4

1 回答 1

0

它正在将其转换为视网膜显示。每个点在屏幕上由 2 个像素表示,因此保存的图像是分辨率的两倍。这是一篇很好的参考文章:http: //www.paintcodeapp.com/news/iphone-6-screens-demystified

于 2015-03-02T17:57:54.230 回答