简体   繁体   English

iOS-CoreImage在特定位置将一个图像合成到另一个图像

[英]IOS - CoreImage composite one image to another image at specific location

Sorry if I am posting a duplicated question. 抱歉,如果我发布重复的问题。

I am newbie in IOS programming with CoreImage. 我是使用CoreImage进行IOS编程的新手。 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. 问题是来自Core image的Composite滤镜不支持特定位置的合成。 It is compositing the two images at the location (0,0) only. 它仅在位置(0,0)上合成两个图像。

For example, I need to composite an image at the location (100,100) of another image, not at the left-top corner. 例如,我需要在另一个图像的位置(100,100)而不是在左上角合成一个图像。

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来做到这一点,如下所示:

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

Alternatively there is a CIAffineTransform filter which does the same job. 另外,也可以使用CIAffineTransform过滤器完成相同的工作。 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 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM