简体   繁体   English

如何将两个图像合并为一个图像对象?

[英]How can I combine two images into one image object?

How can I combine two images? 如何组合两个图像?

I mean I have two images: one small and another big one. 我的意思是我有两个图像:一个小图像和另一个大图像。 I want to add small image onto big one at a specific point and I need to get an UIImage as the result. 我想在特定点UIImage小图像添加到大图像上,我需要得到一个UIImage作为结果。

I have tried CGCreateImageFromMask but that makes small image to cover bigger image completely. 我已经尝试过CGCreateImageFromMask但这会使小图像完全覆盖更大的图像。

You'll want to use UIGraphicsBeginImageContext() to generate a CGContextRef , then use UIGraphicsGetCurrentContext() to get a reference to it. 您将要使用UIGraphicsBeginImageContext()生成CGContextRef ,然后使用UIGraphicsGetCurrentContext()来获取对它的引用。

Now draw your current images into the context. 现在将当前图像绘制到上下文中。 When you're done, use UIGraphicsGetImageFromCurrentContext() to generate an UIImage from that context, and UIGraphicsEndImageContext() to clean up. 完成后,使用UIGraphicsGetImageFromCurrentContext()从该上下文生成UIImage ,并使用UIGraphicsEndImageContext()进行清理。

See Apple's UIKit Function Reference doc . 请参阅Apple的UIKit函数参考文档

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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