GPUImage的简单使用
- (void)viewDidLoad
{
[super viewDidLoad];
self.view.backgroundColor = [UIColor whiteColor];
UIImage *image = [UIImage imageNamed:@"2"];
//原图片
UIImageView *imageOri = [[UIImageView alloc]initWithFrame:CGRectMake(5, 20, 150, 90)];
imageOri.image = image;
[self.view addSubview:imageOri];
//创建一个亮度滤镜
GPUImageBrightnessFilter *passthroughFilter = [[GPUImageBrightnessFilter alloc]init];
passthroughFilter.brightness = - 0.5;
//设置要渲染的滤镜
[passthroughFilter forceProcessingAtSize:image.size];
//获取要渲染的图片
GPUImagePicture *stillImageSource = [[GPUImagePicture alloc]initWithImage:image];
//添加上滤镜
[stillImageSource addTarget:passthroughFilter];
//开始渲染
[stillImageSource processImage];
//获取渲染后的图片
UIImage *nearestNeighborImage = [passthroughFilter imageFromCurrentlyProcessedOutput];
//加载出来
UIImageView *imageView = [[UIImageView alloc]initWithImage:nearestNeighborImage];
imageView.frame = CGRectMake(160, 20, 150, 90);
[self.view addSubview:imageView];
}