我想在 Image 上应用 CIColorMatrix :
下面是代码,在“过滤器”变量下一切正常,但不适用于图像:
- (IBAction)filterImage:(id)sender {
CIImage *rawImageData;
rawImageData =[[CIImage alloc] initWithImage:self.imageView.image];
CIFilter *filter = [CIFilter filterWithName:@"CIColorMatrix"];
[filter setDefaults];
[filter setValue:rawImageData forKey:kCIInputImageKey];
[filter setValue:[CIVector vectorWithX:1 Y:0 Z:0 W:0]
forKey:@"inputRVector"];
[filter setValue:[CIVector vectorWithX:0 Y:1 Z:0 W:0]
forKey:@"inputGVector"];
[filter setValue:[CIVector vectorWithX:0 Y:0 Z:1 W:0]
forKey:@"inputBVector"];
[filter setValue:[CIVector vectorWithX:0 Y:0 Z:0 W:1]
forKey:@"inputAVector"];
[filter setValue:[CIVector vectorWithX:0 Y:0 Z:0 W:0]
forKey:@"inputBiasVector"];
CIImage *filteredImageData = [filter outputImage];
UIImage *filteredImage = [[UIImage alloc]init];
filteredImage = [UIImage imageWithCIImage:filteredImageData];
self.imageView.image = filteredImage;
}