
How to merge these two images(see attached image).I am using the below code. Its working for ordinary images not for 3D transform images. How to handle this issue. I have searched lot of times still not getting the proper result. Please help me. Thanks in advance.
UIImage *mergedImage;
UIGraphicsBeginImageContext(backgroundImageView.frame.size);
[backgroundImageView.layer renderInContext:UIGraphicsGetCurrentContext()]; //bacgroundImageView here
mergedImage = UIGraphicsGetImageFromCurrentImageContext();
UIGraphicsEndImageContext();
You could create a
CGImageRefthat contain the distorted image to put on top, (with the background of that image being 0% alpha) that way you could blend the images using your above code.So what you are truly looking for is how to apply a 3D transform to an image. More precisely, as you are looking for “perspective” in you own words, you are looking on how to warp an homography to an image.
The CoreImage programming guide specify that
CIPerspectiveTransformis the way to go, unfortunately for you this is not available on iOS as of iOS 5.1.So you are left with a few choices :
If you want to display only the result blend and not manipulate it, you can use two
UIImageViews on top of each other, the one containing the perspective image being transformed using a cleverly designedCATransform3DIf you absolutely need to blend the images, you will need to use another framework such as OpenCV (
warpPerspective()is the function you are looking for) or OpenGL ES