将GPUImage过滤器应用于UIView [英] Apply GPUImage filter to a UIView

查看:174
本文介绍了将GPUImage过滤器应用于UIView的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个问题。我需要对整个 UIView 应用像 Pixelate或Blur 这样的过滤器。
eBay iPad 应用程序。



我以为使用 GPUImage 但我不知道该怎么做。
有一种方法可以将过滤器直接应用到 GPUImageView ,而不需要传递 UIImage



主要问题是在 iPad上制作一个大的 UIView 的屏幕截图 3rd是昂贵的(对于 UIWindow 抓取2秒)。所以完美的解决方案是直接应用过滤器的意见,就像易趣应用程序,但..如何?

感谢所有!

解决方案

要将视图拉入GPUImage,可以使用GPUImageUIElement源代码,该源代码将UIView或CALayer作为输入。在FilterShowcase示例应用程序中有一个这样的例子。

这个依赖于 -renderInContext:方法基础CALayer,这可能是重绘视图的昂贵。但是,如果视图是静态的,则只需要使用此更新一次,并将生成的图像作为纹理缓存在GPU上。在该点之后应用到它的筛选器操作将非常快。


I've a problem. I need to apply a filter like Pixelate or Blur to an entire UIView. Like the eBay iPad app.

I thought to use GPUImage but I don't know how to do it. There is a way to apply a filter to a GPUImageView directly without pass a UIImage?

The primary problem is that making a screenshot of a large UIView on an iPad 3rd is to expensive (2 seconds for the UIWindow grab). So the perfect solution is to apply filter directly to the views, just like eBay app, but.. how?

Thanks to all!

解决方案

To pull a view into GPUImage, you can use a GPUImageUIElement source, which takes a UIView or CALayer as input. There's an example of this in the FilterShowcase sample application.

This does rely on the -renderInContext: method of an underlying CALayer, which can be expensive for redrawing the view. However, if the view is static, you just need to use this update once and the resulting image will be cached on the GPU as a texture. Filter actions applied to it after that point will be very fast.

这篇关于将GPUImage过滤器应用于UIView的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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