How do I get combine GI Filter effects. I would like to combine CISepiaTone with CIPhotoEffectMono. Currently I have something like this for a filter.

case 1:{
        filter = [CIFilter filterWithName:@"CISepiaTone" keysAndValues: kCIInputImageKey, beginImage, @"inputIntensity", [NSNumber numberWithFloat:0.8], nil];
        break;
}
有帮助吗?

解决方案

Apple gives a detailed example in its documentation : https://developer.apple.com/library/ios/documentation/graphicsimaging/Conceptual/CoreImaging/ci_tasks/ci_tasks.html

Basically you set the output of one filter to the input of the next filter and crrate a chain that way. From Apple:

CIFilter *gloom = [CIFilter filterWithName:@"CIGloom"];
[gloom setDefaults];                                        
[gloom setValue: result forKey: kCIInputImageKey];
[gloom setValue: @25.0f forKey: kCIInputRadiusKey];         
[gloom setValue: @0.75f forKey: kCIInputIntensityKey];      
CIImage *result = [gloom valueForKey: kCIOutputImageKey];            

and here comes the second filter using result as input

CIFilter *bumpDistortion = [CIFilter filterWithName:@"CIBumpDistortion"];
[bumpDistortion setDefaults];                                               
[bumpDistortion setValue: result forKey: kCIInputImageKey];
[bumpDistortion setValue: [CIVector vectorWithX:200 Y:150]
                forKey: kCIInputCenterKey];                              
[bumpDistortion setValue: @100.0f forKey: kCIInputRadiusKey];                
[bumpDistortion setValue: @3.0f forKey: kCIInputScaleKey];                   
result = [bumpDistortion valueForKey: kCIOutputImageKey];
许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top