2
我調整了的UIImage,調整大小後,如果我打印尺寸:UIImage.size與像素分辨率不同嗎?
print(myImage.size)
我得到的輸出:
(295.5,350.0)
後保存圖像我檢查分辨率,我得到: 555×700像素
是不是UIImage.size圖像的分辨率?
我調整了的UIImage,調整大小後,如果我打印尺寸:UIImage.size與像素分辨率不同嗎?
print(myImage.size)
我得到的輸出:
(295.5,350.0)
後保存圖像我檢查分辨率,我得到: 555×700像素
是不是UIImage.size圖像的分辨率?
爲了讓您的圖像的像素分辨率,你可以使用下一個片段:
let image: UIImage = ...
let size = CGSize(width: image.size.width * image.scale, height: image.size.height * image.scale)
它考慮到圖像的比例值。
['size' documentation](https://developer.apple.com/library/ios/documentation/UIKit/Reference/UIImage_Class/#//apple_ref/occ/instp/UIImage/size)描述了邏輯大小和像素尺寸:「該值反映圖像的邏輯大小....將尺寸值乘以scale屬性中的值以獲取圖像的像素尺寸。」 –
你是什麼意思? @MartinR – Danny182
所以它取決於* scale *? – Danny182