我希望使用在Snapchat过滤器之后建模的CIFilter来制作自定义过滤器,但我似乎无法接近。
这是我试图通过改变亮度,饱和度和曝光水平来做的事情。有什么建议吗?
CIImage *beginImage = [CIImage imageWithCGImage:myImageView.image.CGImage];
CIImage *filter = [CIFilter filterWithName:@"CIColorControls" keysAndValues:kCIInputImageKey, beginImage, @"inputBrightness", [NSNumber numberWithFloat:-0.05], @"inputContrast", [NSNumber numberWithFloat:1.0], @"inputSaturation", [NSNumber numberWithFloat:1.05], nil].outputImage;
CIImage *output = [CIFilter filterWithName:@"CIExposureAdjust" keysAndValues:kCIInputImageKey, filter, @"inputEV", [NSNumber numberWithFloat:1.0], nil].outputImage;
CIContext *context = [CIContext contextWithOptions:nil];
CGImageRef cgiimage = [context createCGImage:output fromRect:output.extent];
UIImage *newImage = [UIImage imageWithCGImage:cgiimage scale:image.scale orientation:UIImageOrientationRight];
myImageView.image = newImage;
CGImageRelease(cgiimage);