我注意到很多人问有关将过滤器与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/