GPUImageMaskFilter背景颜色

时间:2014-11-25 12:06:01

标签: ios objective-c gpuimage

我在使用GPUImageMaskFilter设置背景颜色时遇到问题。似乎是我第一次按下按钮来运行脚本时输出是白色的。在第二次按下时,将返回正确的黑色作为背景颜色。

UIImage *imgMask = [self createMaskImage:maskImage canvasImage:sourceImage maskWidth:200 maskHeight:200];
UIImage *imgBgImage = sourceImage;


GPUImagePicture * maskGpuImage = [[GPUImagePicture alloc] initWithImage:imgMask ];
GPUImagePicture *FullGpuImage = [[GPUImagePicture alloc] initWithImage:imgBgImage];

GPUImageMaskFilter *maskingFilter = [[GPUImageMaskFilter alloc] init];
[maskingFilter setBackgroundColorRed:0 green:0 blue:0 alpha:1];

// Image first, Mask next
[FullGpuImage addTarget:maskingFilter];
[FullGpuImage processImage];

[maskingFilter useNextFrameForImageCapture];

[maskGpuImage addTarget:maskingFilter];
[maskGpuImage processImage];

return [maskingFilter imageFromCurrentFramebuffer];

0 个答案:

没有答案