You could create a CGImageRef
that 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 CIPerspectiveTransform
is 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 UIImageView
s on top of each other, the one containing the perspective image being transformed using a cleverly designed CATransform3D
If 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
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…