http://hi.baidu.com/yunhuaikong/item/c173c7dc1aab7354d73aae29
CIFilter用于图片的特效处理,具体使用方法如下:
UIImage *image = [touch_image_view image];
CIImage *beginImage = [CIImage imageWithCGImage:image.CGImage];
CIFilter *filter = [CIFilter filterWithName:@"CIHueAdjust"];//注意这里的filterWithName值不是随便给的。具体使用下面会进行说明。
[filter setValue:beginImage forKey:kCIInputImageKey];
[filter setValue:[NSNumber numberWithFloat:2.0] forKey:@"inputAngle"];
// 得到过滤后的图片
CIImage *outputImage = [filter outputImage];
// 转换图片, 创建基于GPU的CIContext对象
CIContext *context = [CIContext contextWithOptions: nil];
CGImageRef cgimg = [context createCGImage:outputImage fromRect:[outputImage extent]];
UIImage *newImg = [UIImage imageWithCGImage:cgimg];
// 显示图片
UIImageView *image_content = (UIImageView *)[[self.viewviewWithTag:14] viewWithTag:2];
[image_content setImage:newImg];
// 释放C对象
CGImageRelease(cgimg);
使用说明:
NSLog(@"array is %@",[CIFilterfilterNamesInCategory:kCICategoryDistortionEffect]);
NSLog(@"array is %@",[CIFilterfilterNamesInCategory:kCICategoryGeometryAdjustment]);
NSLog(@"array is %@",[CIFilterfilterNamesInCategory:kCICategoryCompositeOperation]);
NSLog(@"array is %@",[CIFilterfilterNamesInCategory:kCICategoryHalftoneEffect]);
NSLog(@"array is %@",[CIFilterfilterNamesInCategory:kCICategoryColorAdjustment]);
NSLog(@"array is %@",[CIFilterfilterNamesInCategory:kCICategoryColorEffect]);
NSLog(@"array is %@",[CIFilterfilterNamesInCategory:kCICategoryTransition]);
NSLog(@"array is %@",[CIFilterfilterNamesInCategory:kCICategoryTileEffect]);
NSLog(@"array is %@",[CIFilterfilterNamesInCategory:kCICategoryGenerator]);
NSLog(@"array is %@",[CIFilterfilterNamesInCategory:kCICategoryReduction]);
NSLog(@"array is %@",[CIFilterfilterNamesInCategory:kCICategoryGradient]);
NSLog(@"array is %@",[CIFilterfilterNamesInCategory:kCICategoryStylize]);
NSLog(@"array is %@",[CIFilterfilterNamesInCategory:kCICategorySharpen]);
NSLog(@"array is %@",[CIFilterfilterNamesInCategory:kCICategoryBlur]);
NSLog(@"array is %@",[CIFilterfilterNamesInCategory:kCICategoryVideo]);
NSLog(@"array is %@",[CIFilterfilterNamesInCategory:kCICategoryStillImage]);
NSLog(@"array is %@",[CIFilterfilterNamesInCategory:kCICategoryInterlaced]);
NSLog(@"array is %@",[CIFilterfilterNamesInCategory:kCICategoryNonSquarePixels]);
NSLog(@"array is %@",[CIFilterfilterNamesInCategory:kCICategoryHighDynamicRange]);
NSLog(@"array is %@",[CIFilterfilterNamesInCategory:kCICategoryApplePrivate]);
filterWithName:说明
部分说明如下 :
CIColorControls,
CIColorCube,
CIColorMatrix,
CIColorMonochrome,
CIExposureAdjust,
CIGammaAdjust,
CIHueAdjust,
CITemperatureAndTint,
CIToneCurve,
CIVibrance,
CIWhitePointAdjust
如果需要更多自己选择。