GPUImage混合滤镜 [英] GPUImage blend filters

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

问题描述

我正在尝试将混合滤镜应用于2张图像.
我最近将GPUImage更新为最新版本. 为了使事情变得简单,我修改了示例SimpleImageFilter.
这是代码:

I'm trying to apply a blend filters to 2 images.
I've recently updated GPUImage to the last version. To make things simple I've modified the example SimpleImageFilter.
Here is the code:

  UIImage * image1 = [UIImage imageNamed:@"PGSImage_0000.jpg"];
    UIImage * image2 = [UIImage imageNamed:@"PGSImage_0001.jpg"];
    twoinputFilter = [[GPUImageColorBurnBlendFilter alloc] init];
    sourcePicture1 = [[GPUImagePicture alloc] initWithImage:image1 ];
    sourcePicture2 = [[GPUImagePicture alloc] initWithImage:image2 ];
    [sourcePicture1 addTarget:twoinputFilter];
    [sourcePicture1 processImage];
    [sourcePicture2 addTarget:twoinputFilter];
    [sourcePicture2 processImage];
    UIImage * image = [twoinputFilter imageFromCurrentFramebuffer];

返回的图像是nil.应用一些断点,我可以看到方法- (CGImageRef)newCGImageFromCurrentlyProcessedOutput中的过滤器失败,问题是framebufferForOutput为零,我正在使用模拟器.
我不明白为什么它不起作用.

The image returned is nil.Applying some breakpoints I can see that the filter fails inside the method - (CGImageRef)newCGImageFromCurrentlyProcessedOutput the problem is that the framebufferForOutput is nil.I'm using simulator.
I don't get why it isn't working.

推荐答案

似乎我缺少此命令,如静态图像处理文档中所述:

It seems that I was missing this command, as written in the documentation for still image processing:

请注意,要从过滤器手动捕获图像,您需要 设置-useNextFrameForImageCapture以便告诉过滤器 您稍后需要从中捕获.默认情况下,GPUImage 重用过滤器中的帧缓冲区以节省内存,因此如果需要 要保留滤镜的帧缓冲区以进行手动图像捕获,您需要 需要提前告知它.

Note that for a manual capture of an image from a filter, you need to set -useNextFrameForImageCapture in order to tell the filter that you'll be needing to capture from it later. By default, GPUImage reuses framebuffers within filters to conserve memory, so if you need to hold on to a filter's framebuffer for manual image capture, you need to let it know ahead of time.

[twoinputFilter useNextFrameForImageCapture];

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

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