我正在尝试链接两个滤镜(对比度和亮度)并将其应用于图像,但我只应用了对比度滤镜。
以下是代码:
UIImage *inputImage = [UIImage imageNamed:@"2.jpg"];
GPUImagePicture *stillImageSource = [[GPUImagePicture alloc] initWithImage:inputImage];
//Set Brightness to 60
GPUImageBrightnessFilter *brightnessFilter = [GPUImageBrightnessFilter new];
[brightnessFilter setBrightness:0.5];
//Set Contrast to 12
GPUImageContrastFilter *contrastFilter = [GPUImageContrastFilter new];
[contrastFilter setContrast:1.0];
[contrastFilter addTarget:brightnessFilter];
[stillImageSource addTarget:contrastFilter];
[contrastFilter useNextFrameForImageCapture];
[stillImageSource processImage];
UIImage *outputImage1 = [contrastFilter imageFromCurrentFramebuffer];
imageView.image = outputImage1;
答案 0 :(得分:1)
我希望这能解决你的问题..
GPUImageView *imageView = [[GPUImageView alloc] initWithFrame:CGRectMake(x, y, width, height)];
[self.view addSubview:imageView];
UIImage *inputImage = [UIImage imageNamed:@"2.jpg"];
GPUImagePicture *stillImageSource = [[GPUImagePicture alloc] initWithImage:inputImage];
//Set Brightness to 60
GPUImageBrightnessFilter *brightnessFilter = [[GPUImageBrightnessFilter alloc]init];
[brightnessFilter setBrightness:0.5];
//Set Contrast to 12
GPUImageContrastFilter *contrastFilter = [[GPUImageContrastFilter alloc]init];
[contrastFilter setContrast:1.0];
[stillImageSource addTarget:brightnessFilter];
[brightnessFilter addTarget:contrastFilter];
[contrastFilter addTarget:imageView];
[stillImageSource processImage];
[contrastFilter useNextFrameForImageCapture];
UIImage *outputImage1 = [contrastFilter imageFromCurrentFramebuffer];
imageView.image = outputImage1;