有人可以解释一下,这个过滤器是如何工作的,我看到了 WWDC 2012 和文档,但仍然不太明白。在哪里以及如何定义立方体颜色图。它是在 .h 还是 .m 文件中?我有 ViewController.h 和 .m,我在其中使用一些过滤器,我需要使用 CiColorCube 过滤器,但我只是不知道如何。这是我的代码:
- (void)viewDidLoad
{
// here i would like to use CIColorCube
CIImage *inputImage = [[CIImage alloc]initWithImage:[UIImage imageNamed:@"background.jpg"]];
CIImage *inputBackgroundImg = [[CIImage alloc]initWithImage:[UIImage imageNamed:@"image.jpeg"]];
CIContext *context = [CIContext contextWithOptions:nil];
vignette = [CIFilter filterWithName:@"CIVignette"];
[vignette setValue:inputImage forKey:kCIInputImageKey];
[vignette setValue:[NSNumber numberWithFloat:2.5] forKey:@"inputRadius"];
[vignette setValue:[NSNumber numberWithFloat:2.9] forKey:@"inputIntensity"];
sourceOC = [CIFilter filterWithName:@"CISourceOverCompositing"];
[sourceOC setValue:vignette.outputImage forKey:kCIInputImageKey];
[sourceOC setValue:inputBackgroundImg forKey:@"inputBackgroundImage"];
maskToAlpha = [CIFilter filterWithName:@"CIMaskToAlpha"];
[maskToAlpha setValue:inputImage forKey:kCIInputImageKey];
CIImage *outputImage = maskToAlpha.outputImage;
imageView.image = [UIImage imageWithCGImage:[context createCGImage:outputImage fromRect:outputImage.extent]];
[super viewDidLoad];
}