Unexpected result of CISourceOverCompositing when alpha is involved
When trying to position an image with 60% alpha on top of another image with 100% alpha on iOS using CoreImage, I got a result I didn't expect. If I take two images and place scene_2_480p on top of scene_480p like this:
let back: CIImage = loadImage("scene_480p", type: "jpg");
let front: CIImage = loadImage("scene_2_480p", type: "png");
let composeFilter: CIFilter = CIFilter(name: "CISourceOverCompositing");
composeFilter.setDefaults();
composeFilter.setValue(front, forKey: kCIInputImageKey);
composeFilter.setValue(back, forKey: kCIInputBackgroundImageKey);
let result: CIImage = composeFilter.outputImage;
I get this:
If I do the same with gimp and place the same two images on two overlapping layers, I get:
The result is close, but not the same. Anyone can provide an explanation why the results are not the same and how to get the same identical gimp result?
These are the original images that I used:
+3
Luca carlon
source
to share
1 answer
I still can't answer the why question, but using this one can get the correct result with the appropriate alpha value. The scale should be set to 1.0 for the same result.
0
Luca carlon
source
to share