gpt4 book ai didi

ios - 链接 GPUImage 过滤器仅应用最后一个过滤器

转载 作者:行者123 更新时间:2023-11-29 12:23:26 25 4
gpt4 key购买 nike

我试图链接两个滤镜(对比度和亮度)并将其应用于图像,但我只应用了对比度滤镜。

代码如下:

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;

最佳答案

我希望这能解决您的问题..

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;

关于ios - 链接 GPUImage 过滤器仅应用最后一个过滤器,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/29900707/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com