我有一个带滤镜的图像,现在我想单击按钮返回到原始图像。
不确定我是否需要对此进行修正
php bin/console doctrine:migrations:diff
php bin/console doctrine:migrations:migrate
答案 0 :(得分:0)
仅将原始图像存储在ViewController中并根据状态应用文件管理器难道不是很容易吗?
我认为您所说的UIImage
是UIImageView
,告诉我我是否错了。
let inputImg = // Your original image
let isBlured = false
@IBAction func didClickButton(_ sender: Any) {
if isBlured {
myUIImageView.image = inputImg // original image
isBlured = false
} else {
let inputCIImage = CIImage(image: inputImg)
let blurFilter = CIFilter(name: "CIGaussianBlur")!
blurFilter.setValue(inputCIImage, forKey: kCIInputImageKey)
blurFilter.setValue(8, forKey: kCIInputRadiusKey)
let context = CIContext(options: nil)
if let output = blurFilter.outputImage{
if let ciImg = context.createCGImage(output, from: output.extent){
myUIImageView.image = UIImage(cgImage: ciImg)
isBlured = true
}
}
}
}