想看一看我们要实现的效果
//原图
UIImage * inputImage = [UIImage imageNamed:@"IMG_0160.jpg"];
//使用滤镜(滤镜的名称反色等)
GPUImageColorInvertFilter *disFilter = [[GPUImageColorInvertFilter alloc] init];
// disFilter.crosshairWidth = 100;
// [disFilter setCrosshairColorRed:1 green:0 blue:0];
//设置要渲染的区域
[disFilter forceProcessingAtSize:inputImage.size];
[disFilter useNextFrameForImageCapture];
//获取数据源
GPUImagePicture *stillImageSource = [[GPUImagePicture alloc]initWithImage:inputImage];
//添加上滤镜
[stillImageSource addTarget:disFilter];
//开始渲染
[stillImageSource processImage];
//获取渲染后的图片
UIImage *newImage = [disFilter imageFromCurrentFramebuffer];
//加载出来
UIImageView *imageView = [[UIImageView alloc] initWithImage:newImage];
imageView.frame = CGRectMake(50,50,inputImage.size.width ,inputImage.size.height);
[self.view addSubview:imageView];