Create a CI Filter Chain
Asked Answered
P

1

4

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;
}
Pereyra answered 4/3, 2014 at 21:8 Comment(0)
N
10

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];
Nitz answered 4/3, 2014 at 22:5 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.