我是 Core Image 的新手,正在尝试一些过滤器。我可以让一些过滤器工作,但其他人只是拒绝工作。
例如,我可以使用如下代码让 CIGaussianGradient 过滤器工作:
CIVector *centerVector = [CIVector vectorWithX:150 Y:150];
CIColor *color0 = [CIColor colorWithRed:1.0 green:0.0 blue:1.0 alpha:1.0];
CIColor *color1 = [CIColor colorWithRed:0.0 green:0.0 blue:0.0 alpha:0.0];
NSNumber *radius = [NSNumber numberWithFloat:300.0];
CIImage *theCIImage = [CIFilter filterWithName:@"CIGaussianGradient" keysAndValues:@"inputCenter", centerVector, @"inputColor0", color0, @"inputColor1", color1, @"inputRadius", radius, nil].outputImage;
UIImage *newImage = [UIImage imageWithCIImage: theCIImage];
self.ImgView.image = newImage;
但我无法使用类似的代码让 CILinearGradient 工作,例如:
CIVector *point0 =[CIVector vectorWithX:0 Y:0];
CIVector *point1 =[CIVector vectorWithX:200 Y:200];
CIColor *color0 = [CIColor colorWithRed:1.0 green:0.0 blue:1.0 alpha:1.0];
CIColor *color1 = [CIColor colorWithRed:0.0 green:0.0 blue:0.0 alpha:0.0];
CIImage *theCIImage = [CIFilter filterWithName:@"CILinearGradient" keysAndValues:@"inputPoint0", point0, @"inputPoint1", point1, @"inputColor0", color0, @"inputColor1", color1, nil].outputImage;
UIImage *newImage = [UIImage imageWithCIImage: theCIImage];
self.ImgView.image = newImage;
我错过了什么?
我正在 iOS 6.0 上测试它。