iOS图像处理——Core Image框架

Core Image框架包含几个比较重要的类:

  • CIImage,图像类;
  • CIContext,上下文对象,所有图像处理都在一个CIContext中完成,通过Quartz 2D和OpenGL渲染CIImage对象;
  • CIFilter,滤镜类;
  • CIDetector,面部识别类;

CIImage同样有多种创建方法:

  • 通过CGImage;
  • 通过文件路径;
  • 通过NSData对象;
NSString *path = [[NSBundle mainBundle] pathForResource:@"flower" ofType:@"jpg"];
NSData *data = [[NSData alloc] initWithContentsOfFile:path];
CIImage *ciImage = [CIImage imageWithData:data];
NSArray *ary = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
NSString *path = [[ary lastObject] stringByAppendingPathComponent:@"flower.jpg"];
NSURL *pathUrl = [NSURL fileURLWithPath:path];
CIImage *ciImage = [[CIImage alloc] initWithContentsOfURL:pathUrl];

猜你喜欢

转载自blog.csdn.net/run_in_road/article/details/113277641
今日推荐