GPUImage:更深的iOS 7模糊效果 [英] GPUImage: Darker iOS 7 Blur Effect

查看:93
本文介绍了GPUImage:更深的iOS 7模糊效果的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要一种可靠,有效的方法来创建iOS 7模糊效果.我已经从WWDC代码(UIImage+ImageEffects)实现了Apple的applyBlurWithRadius.实际上,它非常灵活,它可以更改tintColor,还可以创建类似以下的暗色模糊效果:

I need a reliable, efficient method to create iOS 7 blur effect. I've implemented Apple's applyBlurWithRadius from WWDC code (UIImage+ImageEffects). It is pretty flexible actually, it allows to change tintColor also which provides to create a darker blur effect like this:

但是它依赖于Core Graphics,并且正在降低表视图中的滚动性能.然后,我看到了 BradLarson的GPUImage库,它是GPUImageiOSBlurFilter方法,该方法复制了iOS 7效果及其比UIImage+ImageEffects的运行速度快得多,因此在我的情况下似乎更有用.

But it relies on the Core Graphics and it is decreasing the scrolling performance in a table view. Then I've seen BradLarson's GPUImage library and it's GPUImageiOSBlurFilter method which replicates the iOS 7 effect and it works much faster than the UIImage+ImageEffects, so it seems more usable in my case.

但是问题是,它没有像tintColor这样的任何参数.它会像此处一样.另外,还有其他的GPUImage过滤器,但我不确定我能否获得想要的效果.

But the problem is, it doesn't has any parameter like tintColor. It creates whity effect like here. Also there are other filters of GPUImage but I'm not sure I can get the effect that I want.

推荐答案

正如我在评论中所述

As I describe in the comments here, the "whitening" effect that the GPUImageiOSBlur filter provides is due to a luminance range restriction that I apply in the last step of that operation. The filter itself is a grouped filter, where the image is first desaturated and downsampled, Gaussian blurred, and then upsampled and luminance range restricted in the last step.

最后一步是使用GPUImageLuminanceRangeFilter执行的,我将其复制来复制Apple似乎适用于大多数重叠模糊的确切效果.不过,它们似乎在其他颜色中使用了不同的色彩效果,因此,为了模仿您需要更改滤镜中的最后一步.

That last step is performed using a GPUImageLuminanceRangeFilter, which I built to replicate the exact effect that Apple seems to apply to most of their overlay blurs. They appear to use a different color effect in others, though, so to mimic that you'll want to change that last step in the filter.

稍后我可能会为用户指定某种颜色,但现在您可以基于GPUImageiOSBlurFilter和GPUImageLuminanceRangeFilter创建自己的自定义滤镜,并更改GPUImageLuminanceRangeFilter的实现以将最终颜色更改为更暗比正常情况下提供的要多.您必须尝试使用​​该片段着色器中的值,才能看到产生所需效果的东西.

I might make this something that the user can specify as a tint color later on, but for now you can create your own custom filters based on GPUImageiOSBlurFilter and GPUImageLuminanceRangeFilter, and change your implementation of GPUImageLuminanceRangeFilter to alter the final colors to be darker than what is provided normally. You'll have to experiment with the values in that fragment shader to see what produces the effect you want.

其他人已经做到了这一点,效果很好,但是还没有人作为拉取请求将其反馈回来.

Other people have done this, to good effect, but none have fed it back in as a pull request yet.

这篇关于GPUImage:更深的iOS 7模糊效果的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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