【发布时间】:2016-06-08 22:37:23
【问题描述】:
正在开发一个 pdf 照片报告应用程序,并为生成的 pdf 中的低图像质量而苦苦挣扎。
func drawImage(index: Int, rectPos: Int) {
let image = getImage(index)
let xPosition = CGFloat(rectArray[rectPos][0])
let yPosition = CGFloat(rectArray[rectPos][1])
image.drawInRectAspectFill(CGRectMake(xPosition, yPosition, 325, 244))
}
func getImage(index: Int) -> UIImage {
var thumbnail = UIImage()
if self.photoAsset.count != 0 {
let initialRequestOptions = PHImageRequestOptions()
initialRequestOptions.resizeMode = .Exact
initialRequestOptions.deliveryMode = .HighQualityFormat
initialRequestOptions.synchronous = true
PHImageManager.defaultManager().requestImageForAsset(self.photoAsset[index], targetSize: CGSizeMake(325, 244), contentMode: PHImageContentMode.Default, options: initialRequestOptions, resultHandler: { (result, info) -> Void in
thumbnail = result!
})
}
return thumbnail
}
然后我使用这些函数抓取图像并将其放置在 UIGraphicsBeginPDFPageWithInfo(page, nil) 之后的页面上的某个位置...
我正在使用BSImagePicker pod 来获取图像。
最后,我的 photoAsset 只是用户从 pod 的 CollectionView 中选择图像后生成的 PHAsset 照片数组...
到目前为止,我尝试了 initialRequestOptions.deliveryMode 的所有设置...高质量似乎并没有让图像变得更好。
我在这里做错了什么?谢谢!
【问题讨论】: