0

嗨,我正在尝试做这样的事情:

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

显然它不起作用,那么,如何从已经存在的字典中填充 keysAndValues 呢?谢谢!

4

2 回答 2

1

[filter setValue:value forKey:key]您应该使用最简单的构造方法 (filterWithName:) 并通过迭代现有字典的键来填充值。它只需要几行代码。

于 2012-07-26T09:40:52.947 回答
1

你可以像这样使用字典:

 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]];
于 2012-07-26T09:54:12.577 回答