有人可以解释一下,这个过滤器是如何工作的,我看到了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];
}
答案 0 :(得分:1)
在Apple的开发人员库中,'Subclassing CIFilter: Recipes for Custom Effects'上有一个文档,展示了如何制作彩色地图..
此外,在XCode中,您可以查找ImageApp示例代码,它还会显示ImageFilter.m中的内容。