将CIFilter应用于使用相机拍摄的照片后,所拍摄的图像会自动收缩并重新定位。将CIFilter应用于UIImage会导致调整大小和重新定位图像
我在想,如果我能够获得原始图像的大小和方向,它将相应地缩放并将图像视图固定到屏幕的角落。然而,这种方法没有什么改变,也没有意识到我可以正确地将图像缩放到屏幕的全尺寸。
func applyBloom() -> UIImage {
let ciImage = CIImage(image: image) // image is from UIImageView
let filteredImage = ciImage?.applyingFilter("CIBloom",
withInputParameters: [ kCIInputRadiusKey: 8,
kCIInputIntensityKey: 1.00 ])
let originalScale = image.scale
let originalOrientation = image.imageOrientation
if let image = filteredImage {
let image = UIImage(ciImage: image, scale: originalScale, orientation: originalOrientation)
return image
}
return self.image
}
图片说明: 照片捕获并与空间距作为一个图像收缩的结果的图像的屏幕截图。
从CIImage到UIImage的转换中删除'scale'和'orientation'参数,事情会很好 –