将GPUImage过滤器应用于UIView(Apply GPUImage filter to a UIView)

系统教程 行业动态 更新时间:2024-06-14 17:04:02
将GPUImage过滤器应用于UIView(Apply GPUImage filter to a UIView)

我有一个问题。 我需要将像Pixelate or Blur这样的滤镜应用到整个UIView 。 像eBay iPad应用程序一样。

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

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

谢谢大家!

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!

最满意答案

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

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

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.

更多推荐

本文发布于:2023-04-24 20:53:00,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/dzcp/9c0bc33842b95ada94911fdf15ba61b2.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:应用于   过滤器   GPUImage   filter   Apply

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!