- (void)viewDidLoad
{
[super viewDidLoad];
// Do any additional setup after loading the view, typically from a nib. // 滤镜效果
NSArray *operations = @[@"CILinearToSRGBToneCurve",
@"CIPhotoEffectChrome",
@"CIPhotoEffectFade",
@"CIPhotoEffectInstant",
@"CIPhotoEffectMono",
@"CIPhotoEffectNoir",
@"CIPhotoEffectProcess",
@"CIPhotoEffectTonal",
@"CIPhotoEffectTransfer",
@"CISRGBToneCurveToLinear",
@"CIVignetteEffect"]; CGFloat width = self.view.frame.size.width/;
CGFloat height = self.view.frame.size.height/; NSMutableArray *imageViews = [NSMutableArray arrayWithCapacity:]; for (int i = ; i < [operations count]; i++)
{
UIImageView *imageView = [[UIImageView alloc]initWithFrame:
CGRectMake(i%*width, i/*height, width, height)];
imageView.image = [UIImage imageNamed:@"timg.jpeg"];
[imageViews addObject:imageView];
[self.view addSubview:imageView];
} dispatch_async(dispatch_get_global_queue(, ),^{ NSMutableArray *images = [NSMutableArray arrayWithCapacity:]; for (int i = ; i < [operations count]; i++)
{
UIImage *image = [UIImage imageNamed:@"timg.jpeg"];
CIImage *cImage = [[CIImage alloc]initWithImage:image]; //使用资源
CIFilter *filter = [CIFilter filterWithName:operations[i]
keysAndValues:kCIInputImageKey,cImage, nil]; //使用默认参数
[filter setDefaults]; //生成上下文
CIContext*context = [CIContext contextWithOptions:nil]; //滤镜生成器输出图片
CIImage *outputimage = [filter outputImage]; //转换为UIImage
CGImageRef ref = [context createCGImage:outputimage fromRect:[outputimage extent]];
UIImage *temp = [UIImage imageWithCGImage:ref]; [images addObject:temp]; //释放
CGImageRelease(ref);
} dispatch_async(dispatch_get_main_queue(), ^{
for (int x = ; x < [images count]; x++)
{
UIImageView *imageView = imageViews[x];
imageView.image = images[x];
}
});
});
}

原图

添加滤镜后效果图

最新文章

  1. Logstash为什么那么慢?—— json序列化
  2. GJM : Python简单爬虫入门(二) [转载]
  3. javascript边角知识
  4. php socket函数详解
  5. jquery 之height(),innerHeight(),outerHeight()方法区别详解
  6. Gradle 教程:第一部分,安装【翻译】
  7. DTD限制XML文件
  8. Map,HashMap
  9. 倒影(box-reflect)
  10. ORACLE函数详解【weber出品】
  11. des和Rijndael加密
  12. 设计模式:Prototype 原型模式 - 同学你抄过别人的作业么?-clone()方法的使用
  13. 文本去重-----awk或者uniq
  14. JavaSE(十二)之IO流的字节流(一)
  15. Leetcode 19——Remove Nth Node From End of List
  16. Access text files using SQL statements by DB Query Analyzer
  17. 【Debug】串口发送数据时部分字节被拉长,出现帧错误,原因MCU进入低功耗模式导致串口时钟停了!
  18. Python项目--Scrapy框架(一)
  19. 使用proxy来简单的实现一个观察者
  20. RNN实例

热门文章

  1. drupal7在page中直接输出区块
  2. Eclipse 分屏显示同一个代码文件
  3. 《ArcGIS Runtime SDK for Android开发笔记》——(4)、基于Android Studio构建ArcGIS Android开发环境
  4. 查看oracle 11g数据库用户的密码是否区分大小写
  5. 封装和 property方法
  6. setfacl 命令的常用用法
  7. Python语言特性
  8. Linux命令--用户管理
  9. https nginx 设置
  10. mysql install steps