过滤图层

时间:2014-02-18 11:20:41

标签: ios objective-c core-image cifilter

我在CALayer添加过滤器时遇到问题....这是代码,但最后有一行我们在CALayer添加过滤器..

CIImage *inputImage = [[CIImage alloc]initWithImage:[UIImage imageNamed:@"%d.jpg"]];
CIFilter *minimumComponent = [ CIFilter filterWithName:@"CIMinimumComponent"];
[minimumComponent setValue:inputImage forKey:@"inputImage"];
[minimumComponent setDefaults];

CIImage *outputImage = [minimumComponent valueForKey:@"outputImage"];
CIContext *context = [CIContext contextWithOptions:nil];
imageLayer = [UIImage imageWithCGImage:[context createCGImage:outputImage fromRect:outputImage.extent]];

我猜这里是错误

imageLayer = [UIImage imageWithCGImage:[context createCGImage:outputImage fromRect:outputImage.extent]];

here是我明白这个想法的链接......

1 个答案:

答案 0 :(得分:1)

好的,首先我不是100%肯定你得到的错误是什么,但我建议换成这样的......

CIImage *outputImage = [minimumComponent valueForKey:@"outputImage"];
UIImage *uiImage = [UIImage imageWithCIImage:outputImage];