Swift Gaussian Blur an image [closed]

回眸只為那壹抹淺笑 提交于 2019-11-29 07:17:09

问题


I've been developing an app for quite a while now and am soon to finish. I have been blurring some images using the UIImage+ImageEffects.h library, but now I want to switch to Gaussian blurring an UIImage

Is there any library or something similar that would allow me to gaussian blur an image in my app?


回答1:


I use following in my app.

 func applyBlurEffect(image: UIImage){
    var imageToBlur = CIImage(image: image)
    var blurfilter = CIFilter(name: "CIGaussianBlur")
    blurfilter.setValue(imageToBlur, forKey: "inputImage")
    var resultImage = blurfilter.valueForKey("outputImage") as CIImage
    var blurredImage = UIImage(CIImage: resultImage)
    self.blurImageView.image = blurredImage

  }



回答2:


I think UIBlurEffect is what you want, if you want to avoid the delay. The second half of this tutorial on Gaussian blur techniques in iOS 8 walks you through adding a UIBlurEffect to a UIImage.



来源:https://stackoverflow.com/questions/27045475/swift-gaussian-blur-an-image

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!