Да, похоже, некоторые фильтры пока недоступны для iOS.Был такой же забавный опыт при чтении документации.Однако вы можете проверить с помощью кода, чтобы увидеть, какой фильтр доступен для iOS, как указано выше.Некоторый фильтр, например CIVingette, который я не нашел в документации, я сделал это, чтобы также получить значения-параметры для каждого доступного фильтра для iOS на 5.1.
NSArray *supportedFilters = [CIFilter filterNamesInCategory:kCICategoryBuiltIn];
for (CIFilter *filter in supportedFilters) {
NSString *string = [NSString stringWithFormat:@"%@",[[CIFilter filterWithName:(NSString *)filter] inputKeys]];
NSLog(@"%@ %@", filter, string);
}
Ответ:
...
2012-04-19 14:02:55.597 ImageFiltering[12190:707] CIVibrance (
inputImage,
inputAmount
)
2012-04-19 14:02:55.599 ImageFiltering[12190:707] CIVignette (
inputImage,
inputIntensity,
inputRadius
)
2012-04-19 14:02:55.601 ImageFiltering[12190:707] CIWhitePointAdjust (
inputImage,
inputColor
)
...
Обратите внимание, что в будущем (или кто-то уже знает, где вы можете прочитать об этом больше) вы, вероятно, захотите прочитать документацию.Это просто я играю в детектива, чтобы обойти это, потому что я не нашел никакой документации по некоторым фильтрам, как я упоминал ранее.
Вот пример, который я получил с CIVingette из предыдущей информации:
- (void)displayVingetteFilterWithImage{
// Get image and set it as CIImage
NSString *filePath = [[NSBundle mainBundle] pathForResource:@"image_1" ofType:@"jpg"];
NSURL *fileNameAndPath = [NSURL fileURLWithPath:filePath];
CIImage *image = [CIImage imageWithContentsOfURL:fileNameAndPath];
// Create context
CIContext *imageContext = [CIContext contextWithOptions:nil];
// Set filter to image, in this case CIVignette, knowing it uses inputImage, inputIntensity and inputRadius from previous log-response.
CIFilter *vignette = [CIFilter filterWithName:@"CIVignette"];
[vignette setDefaults];
[vignette setValue: image forKey: @"inputImage"];
[vignette setValue: [NSNumber numberWithFloat: 5.0] forKey: @"inputIntensity"];
[vignette setValue: [NSNumber numberWithFloat: 30.0] forKey: @"inputRadius"];
// Attach the CIImage to CGImageRef and attach it as UIImage
CIImage *result = [vignette valueForKey: @"outputImage"];
CGImageRef cgImageRef = [imageContext createCGImage:result fromRect:[result extent]];
UIImage *targetImage = [UIImage imageWithCGImage:cgImageRef];
// Attach UIImage to UIImageView in self.view, also position it, just for fun.
UIImageView *imageView = [[UIImageView alloc] initWithImage:targetImage];
[self.view addSubview:imageView];
[imageView setImage:targetImage];
imageView.frame = CGRectMake(0.0, 10.0, imageView.frame.size.width, imageView.frame.size.height);
// Release CGImageRef we created earlier.
CGImageRelease(cgImageRef);
}