码迷,mamicode.com
首页 > 其他好文 > 详细

GPUImage的简单使用

时间:2014-09-17 18:34:14      阅读:231      评论:0      收藏:0      [点我收藏+]

标签:color   使用   ar   for   sp   c   ad   ef   size   

- (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];

}

GPUImage的简单使用

标签:color   使用   ar   for   sp   c   ad   ef   size   

原文地址:http://www.cnblogs.com/qianyindichang/p/3977574.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!