1

以下代码为图像添加了漂亮的棕褐色效果,但是当我选择另一个过滤器时: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"];

但是当我这样做时,我在启动应用程序时根本看不到任何图像。

4

1 回答 1

2

CISepiaTone 在 Mac OS X v10.4 及更高版本和 iOS 5.0 及更高版本中可用,而 CIBloom 仅在 Mac OS X v10.4 及更高版本中可用。

https://developer.apple.com/library/mac/#documentation/graphicsimaging/reference/CoreImageFilterReference/Reference/reference.html

于 2012-05-17T11:59:25.533 回答