按照这些步骤,我得到了意想不到的结果:
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。任何想法将不胜感激。
加里