Swift Gaussian模糊图像 [英] Swift Gaussian Blur an image

查看:570
本文介绍了Swift Gaussian模糊图像的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我一直在开发应用程序已有一段时间了,很快就会完成。我使用 UIImage + ImageEffects.h 库模糊了一些图像,但现在我想切换到高斯模糊一个 UIImage

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?

推荐答案

我在我的应用程序中使用了以下内容。

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

  }

这篇关于Swift Gaussian模糊图像的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆