以下代码为图像添加了漂亮的棕褐色效果,但是当我选择另一个过滤器时:CIBloom
我根本看不到图像。你能帮我吗?
- (void)drawRect:(CGRect)rect
{
UIImage *megan = [UIImage imageNamed:@"megan.png"];
CIImage *cimage = [[CIImage alloc] initWithImage:megan];
CIFilter *myFilter = [CIFilter filterWithName:@"CISepiaTone"];
[myFilter setDefaults];
[myFilter setValue:cimage forKey:@"inputImage"];
[myFilter setValue:[NSNumber numberWithFloat:0.8f] forKey:@"inputIntensity"];
CIImage *image = [myFilter outputImage];
CIContext *context = [CIContext contextWithOptions:nil];
CGImageRef cgImage = [context createCGImage:image fromRect:image.extent];
UIImage *resultUIImage = [UIImage imageWithCGImage:cgImage];
CGImageRelease(cgImage);
CGRect imageRecht = [[UIScreen mainScreen] bounds];
[resultUIImage drawInRect:imageRecht];
}
据我了解,我应该能够只编辑以下几行来更改过滤器:
CIFilter *myFilter = [CIFilter filterWithName:@"CIBloom"];
[myFilter setValue:[NSNumber numberWithFloat:10.0f] forKey:@"inputIntensity"];
但是当我这样做时,我在启动应用程序时根本看不到任何图像。