开发者

Need some assistance in overlaying a UIImage onto another UIImage?

开发者 https://www.devze.com 2023-03-13 14:41 出处:网络
I have an application where a user is able to annotate a signature image on top of a fax image (tif) before sending out the fax. I have seen a very good question mentioned here开发者_运维知识库: iPhon

I have an application where a user is able to annotate a signature image on top of a fax image (tif) before sending out the fax. I have seen a very good question mentioned here开发者_运维知识库: iPhone SDK - How to draw a UIImage onto another UIImage? however I still am unable to do what I am looking for. Can someone walk me through as I am new to graphical contexts ETC.


This is what you need to do to get the image,

CGRect faxImageRect = CGRectZero;
CGRect signatureRect = CGRectZero;

faxImageRect.size = faxImage.size;
signatureRect.size = signature.size;

// Adjust the signature's location within the fax image
signatureRect.origin = desirableLocation;

UIGraphicsBeginImageContext(faxImage.size);
[faxImage drawInRect:faxImageRect];
[signature drawInRect:signatureRect];
image = UIGraphicsGetImageFromCurrentImageContext();
UIGraphicsEndImageContext();

By the end image will contain the image you want to send.

This sample uses the true sizes of their images. You can alter that although they could be subject to stretching.


Well, I can suggest a workaround. :) Actually, because the iOS is working with views you can create yourself 2 UIImageViews and add one as a subview of the other. If you are interested in the lower level drawing stuff just read Quartz 2D.

0

精彩评论

暂无评论...
验证码 换一张
取 消