GPUImage组过滤器 [英] GPUImage group filters
问题描述
我正在尝试在单个视图中实现亮度,对比度和曝光滤镜,就像在iPhoto应用程序中看到的一样.我试图做同样的组过滤器.但是它显示的是白色屏幕,而不是修改后的图片.这是我应用的代码.
I am trying to implement brightness,contrast and exposure filters in a single view same as you see in iPhoto app. I have tried to put up group filter for doing the same. But it shows up a white screen instead of modified picture. Here is the code I applied.
GPUImageFilterGroup *groupFilter = [[GPUImageFilterGroup alloc]init];
GPUImageBrightnessFilter *brightnessFilter = [[GPUImageBrightnessFilter alloc]init];
[brightnessFilter setBrightness:brightnessValue];
GPUImageContrastFilter *contrastFilter = [[GPUImageContrastFilter alloc]init];
[contrastFilter setContrast:contrastValue];
GPUImageExposureFilter *exposureFilter =[[GPUImageExposureFilter alloc]init];
[exposureFilter setExposure:exposureValue];
[groupFilter addFilter:brightnessFilter];
[groupFilter addFilter:contrastFilter];
[groupFilter addFilter:exposureFilter];
GPUImagePicture *stillImage= [[GPUImagePicture alloc]initWithImage:self.imageToModify];
[stillImage addTarget:groupFilter];
[stillImage processImage];
previewPicture.image = [groupFilter imageFromCurrentlyProcessedOutputWithOrientation:self.imageToModify.imageOrientation];
我什至试图将每个单独放置,但仍然显示白色图像.我使用的上述代码正确吗?
我也尝试使用GPUImageFilterPipeline
而不是GPUImageFilterGroup
,但是仍然存在相同的问题.
作为记录,该图像是静止图像而不是实时供稿.
I even tried to put each individually but still it shows up white image. Is the above code I am using correct?
I have also tried using GPUImageFilterPipeline
instead of GPUImageFilterGroup
but still having the same issue.
For the record, the image is a still image and not live feed.
推荐答案
您错过了执行以下操作的代码声明.
you have missed some code statement for doing it which is as below.
[brightnessFilter addTarget: contrastFilter];
[contrastFilter addTarget: exposureFilter];
[(GPUImageFilterGroup *) groupFilter setInitialFilters:[NSArray arrayWithObject: brightnessFilter]];
[(GPUImageFilterGroup *) groupFilter setTerminalFilter:exposureFilter];
谢谢
这篇关于GPUImage组过滤器的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!