gpt4 book ai didi

ios - 如何向 UIImage GPUImage 添加多个过滤器?

转载 作者:行者123 更新时间:2023-11-28 21:51:04 25 4
gpt4 key购买 nike

我注意到很多人询问有关将过滤器与 GPUImage 链接的问题。我不太清楚如何简洁地做到这一点。今晚终于搞定了。只是想分享我的代码,以便人们可以链接到解决方案。

最佳答案

UIImage *faceImage = [UIImage imageNamed:@"469453586_640.jpg"];
UIImageView *face = [[UIImageView alloc] initWithFrame:CGRectMake(0.0, 0.0, faceImage.size.width/2.0, faceImage.size.height/2.0)];
[face setImage:faceImage];
[self.view addSubview:face];

GPUImagePicture *stillImageSource = [[GPUImagePicture alloc] initWithImage:faceImage];

GPUImageBrightnessFilter *brightnessFilter = [[GPUImageBrightnessFilter alloc] init];
[brightnessFilter setBrightness:.15];
GPUImageGrayscaleFilter *grayscaleFilter = [[GPUImageGrayscaleFilter alloc] init];

GPUImagePosterizeFilter *posterizeFilter = [[GPUImagePosterizeFilter alloc] init];
[posterizeFilter setColorLevels:1];


[stillImageSource addTarget:brightnessFilter];
[brightnessFilter addTarget:grayscaleFilter];
[grayscaleFilter addTarget:posterizeFilter];

// these need to be changed if you change the order of your filters
// [brightnessFilter useNextFrameForImageCapture];
// [grayscaleFilter useNextFrameForImageCapture];
[posterizeFilter useNextFrameForImageCapture];

[stillImageSource processImage];

[face setImage: [posterizeFilter imageFromCurrentFramebuffer]];

关于ios - 如何向 UIImage GPUImage 添加多个过滤器?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/28333594/

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