GPUImage blend filters

扶醉桌前 提交于 2019-12-11 12:57:07

问题


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];

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.


回答1:


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

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];


来源:https://stackoverflow.com/questions/22580432/gpuimage-blend-filters

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!