3

When trying to place a image with 60% alpha channel over another image with 100% alpha channel on iOS using CoreImage I got a result I didn't expect. If I take the two images and place scene_2_480p over 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:

enter image description here

If I do the same with gimp, and place the same two images on two overlapping layers I get:

enter image description here

The result is close, but not the same. Anyone who can give an explanation of why the results are not the same and how to get the same identical result of gimp?

These are the original images I used:

enter image description here enter image description here

Luca Carlon
  • 9,546
  • 13
  • 59
  • 91

1 Answers1

0

I'm still not able to answer the "why" question, but by using this it is possible to get the correct result, with the proper alpha value. The scale must be set to 1.0 for the same result.

Community
  • 1
  • 1
Luca Carlon
  • 9,546
  • 13
  • 59
  • 91