简体   繁体   中英

CIFilter filterWithName:keysAndValues: set keysAndValues from NSDictionary

Hi im trying to do something like this:

NSMutableDictionary *param1 = [NSMutableDictionary dictionaryWithObjectsAndKeys:@"inputIntensity", [NSNumber numberWithFloat:0.8], nil];
[param1 setObject:file forKey:kCIInputImageKey];
CIFilter *filter = [CIFilter filterWithName:@"CISepiaTone" keysAndValues:param1];

Obviously it doesnt work, so, how can a fill keysAndValues from an already existing dictionary? Thank you!

You should use the simplest construction method (filterWithName:) and fill out the values with [filter setValue:value forKey:key] iterating through the keys of the existing dictionary. It will require just few lines of code.

U can use dictionary like this:

 NSMutableDictionary *param = [NSMutableDictionary dictionaryWithObjectsAndKeys:[NSNumber numberWithFloat:0.8],@"inputIntensity",imageView.image,@"inputImage",nil]

 CIFilter *filter = [CIFilter filterWithName:@"CISepiaTone" keysAndValues:@"inputImage",[param objectForKey:@"inputImage"],@"inputIntensity",[param objectForKey:@"inputIntensity",nil]];

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM