[IOS] CIFilter filter, ioscifilter Filter
-(Void) viewDidLoad {[super viewDidLoad]; // Do any additional setup after loading the view, typically from a nib. // filter effect NSArray * operations = @ [@ "photo", @ "CIPhotoEffectChrome", @ "CIPhotoEffectFade", @ "CIPhotoEffectInstant", @ "CIPhotoEffectMono", @ "photo ", @ "ciphotospontprocess", @ "ciphotosponttonal", @ "ciphotosponttransfer", @ "CISRGBToneCurveToLinear", @ "CIVignetteEffect"]; CGFloat width = self. view. frame. size. width/3; CGFloat height = self. view. frame. size. height/4; NSMutableArray * imageViews = [NSMutableArray arrayWithCapacity: 0]; for (int I = 0; I <[operations count]; I ++) {UIImageView * imageView = [[UIImageView alloc] initWithFrame: CGRectMake (I % 3 * width, I/3 * height, width, height)]; imageView. image = [UIImage imageNamed: @ "timg.jpeg"]; [imageViews addObject: imageView]; [self. view addSubview: imageView];} dispatch_async (values (0, 0), ^ {NSMutableArray * images = [NSMutableArray arrayWithCapacity: 0]; for (int I = 0; I <[operations count]; I ++) {UIImage * image = [UIImage imageNamed: @ "timg.jpeg"]; CIImage * cImage = [[CIImage alloc] initWithImage: image]; // use the resource CIFilter * filter = [CIFilter filterWithName: operations [I] keysAndValues: kCIInputImageKey, cImage, nil]; // use the default parameter [filter setDefaults]; // generate the context CIContext * context = [CIContext contextwitexceptions: nil]; // The filter generator outputs the image CIImage * outputimage = [filter outputImage]; // convert to UIImage CGImageRef ref = [context createCGImage: outputimage fromRect: [outputimage extent]; UIImage * temp = [UIImage imageWithCGImage: ref]; [images addObject: temp]; // release CGImageRelease (ref);} dispatch_async (dispatch_get_main_queue (), ^ {for (int x = 0; x <[images count]; x ++) {UIImageView * imageView = imageViews [x]; imageView. image = images [x] ;}}) ;}) ;}
Source image
After adding a filter