Reputation: 2317
I want to blend an image with a blue color, using the CIScreenBlendMode filter.
For that, I use the following code:
-(CIImage*)makeitBlue:(CIImage*)greyImage{
CIImage* outputImage = nil;
//create some blue
CIFilter* blueGenerator = [CIFilter filterWithName:@"CIConstantColorGenerator"];
CIColor* blue = [CIColor colorWithString:@"0.1 0.5 0.8 1.0"];
[blueGenerator setValue:blue forKey:@"inputColor"];
CIImage* blueImage = [blueGenerator valueForKey:@"outputImage"];
//apply a screen filter
CIFilter* filter = [CIFilter filterWithName:@"CIScreenBlendMode"];
[filter setValue:blueImage forKey:@"inputImage"];
[filter setValue:greyImage forKey:@"inputBackgroundImage"];
outputImage = [filter valueForKey:@"outputImage"];
return outputImage;
}
This method makes my app crash and I don't know why.
In its documentation Apple states the following parameters for CIScreenBlendMode:
inputImage | A CIImage object whose display name is Image.
inputBackgroundImage | A CIImage object whose display name is Background Image.
I think that is just what I'm providing.
When I replace CIScreenBlendMode with CIMultiplyCompositing, this code is running fine.
Maybe some of you can spot the mistake I make?
Upvotes: 0
Views: 542
Reputation: 2317
I found the answer here: Using a CIImage from CIColor in a CIFilter: getting empty image.
As user578205 states:
You should crop the generated image to beginImage size because generated image's size is infinite. I don't know why, but CIOverlayBlendMode isn't tolerant to infinite size
And in a way it makes sense: how could you align two images of which one is of infinite size?
Upvotes: 0