user1010563
user1010563

Reputation:

CIFilter integration only works with CISepiaTone

Following code adds a nice sepia effect to an image but when I choose another filter for example: CIBloom I see no image at all. Can you help?

- (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];
}

From my understanding I should be able to just edit following lines to change the filter:

CIFilter *myFilter = [CIFilter filterWithName:@"CIBloom"];
[myFilter setValue:[NSNumber numberWithFloat:10.0f] forKey:@"inputIntensity"];

but when I do this I see no image at all when I start the app.

Upvotes: 1

Views: 3898

Answers (1)

Basel
Basel

Reputation: 2368

CISepiaTone is available in Mac OS X v10.4 and later and in iOS 5.0 and later, while CIBloom is only available in Mac OS X v10.4 and later.

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

Upvotes: 2

Related Questions