Sorry if I am posting a duplicated question.

I am newbie in IOS programming with CoreImage. I am going to composite an image over another image. The problem is the Composite filters from Core image don't support a composition at specific location. It is compositing the two images at the location (0,0) only.

For example, I need to composite an image at the location (100,100) of another image, not at the left-top corner.

Any suggestion for this issue must be appreciated.

有帮助吗?

解决方案

What you want to do, I believe, is move the image you want offset to the correct location before applying the composite filter. You can create a CGAffineTransform to do this like so:

CGAffineTransform transform = CGAffineTransformMakeTranslation(100, 100);
CIImage *adjustedImage = [inputImage imageByApplyingTransform:transform]; 

Alternatively there is a CIAffineTransform filter which does the same job. Once you've got your transformed image, you can comp it with the other image normally and it should appear offset in the output.

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top