the*_*end 6 cocoa-touch uiimage ios
如果我只是将image.size与image.scale相乘,我可以获得UIImage的像素大小吗?这样做是一样的:
guard let cgImage = image.CGImage else{
return nil
}
let width = CGImageGetWidth(cgImage)
let height = CGImageGetHeight(cgImage)
Run Code Online (Sandbox Code Playgroud)
您可以,但它与cgImage.width x cgImage.height(您提供的 CG 函数的新名称)不同。cgImage 至少不知道一些可能已旋转或翻转原始图像的 EXIF 标志。您可以在https://github.com/recurser/exif-orientation-examples 上看到图像 Portrait_5.jpg 到 Portrait_8.jpg 的差异。image.size.height * image.scale给出 1800,但cgImage.height给出 1200(实际上是宽度)。
| 归档时间: |
|
| 查看次数: |
4253 次 |
| 最近记录: |