[英]BSImagePicker all Images blurred
I'm using BSImagePicker instead of UIImagePicker to enable multi select.我使用 BSImagePicker 而不是 UIImagePicker 来启用多选。 I'm using following code for this:
我为此使用以下代码:
let bsImagePicker = BSImagePickerViewController()
bsImagePicker.maxNumberOfSelections = 4
self.bs_presentImagePickerController(bsImagePicker, animated: true, select: { (asset : PHAsset) in
}, deselect: { (asset : PHAsset) in
}, cancel: { (assets : [PHAsset]) in
}, finish: { (assets : [PHAsset]) in
for asset in assets {
self.selectedAssets.append(asset)
self.convertAssetsToImage()
}
}, completion: nil)
And for converting the PHAsset to an image I'm using this code:为了将 PHAsset 转换为图像,我使用了以下代码:
func convertAssetsToImage() {
for asset in selectedAssets {
let manager = PHImageManager.default()
let option = PHImageRequestOptions()
var thumbnail = UIImage()
option.isSynchronous = true
manager.requestImage(for: asset, targetSize: CGSize(width: 340, height: 365), contentMode: .aspectFit, options: option, resultHandler: {(result, info) -> Void in
thumbnail = result!
})
self.selectedPhotos.append(thumbnail)
}
DispatchQueue.main.async {
self.imageViewImage.animationImages = self.selectedPhotos
self.imageViewImage.animationDuration = 5.0
self.imageViewImage.startAnimating()
}
}
But all images are blurred.但是所有的图像都是模糊的。 If the ImagePicker is shown, all images are slightly blurred and after selection the image is still blurred.
如果显示 ImagePicker,则所有图像都会略微模糊,选择后图像仍然模糊。
Thats an image of selection Screen:那是选择屏幕的图像:
Thats an Image of the selected Image:这是所选图像的图像:
And for example, this is an image if I'm using an UIImagePicker:例如,如果我使用 UIImagePicker,这是一个图像:
You can add these two PHImageRequestOptions
to tell photos to provide a high-quality image (possibly sacrificing speed).您可以添加这两个
PHImageRequestOptions
来告诉照片提供高质量的图像(可能会牺牲速度)。
option.deliveryMode = .highQualityFormat
option.resizeMode = .exact
100% worked for me :) 100% 为我工作:)
let option = PHImageRequestOptions()
option.deliveryMode = .highQualityFormat
option.resizeMode = .exact
PHImageManager.default().requestImage(for: asset, targetSize: PHImageManagerMaximumSize, contentMode: .aspectFit, options: option) { (image, info) in
// Do something with image
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.