GPUImage学习demo1

ViewController.m

#import "ViewController.h"
#import "GPUImage.h"

- (void)viewDidLoad {
      [super viewDidLoad];
      UIImage *inputImage = [UIImage imageNamed:@"lufei.jpeg"];
     GPUImageVignetteFilter *disFilter = [[GPUImageVignetteFilter alloc] init];
     //设置要渲染的区域
     [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 = self.view.frame;
     [self.view addSubview:imageView];

}

你可能感兴趣的:(GPUImage学习demo1)