I am applying 3D transform on a image layer by follow code.
UIImageView *view = (UIImageView *)[recognizer view];
CGPoint translation = [recognizer translationInView:self.view];
CGPoint newCenter = view.center;
newCenter.x += translation.x;
newCenter.y += translation.y;
view.center = newCenter;
[recognizer setTranslation:CGPointZero inView:self.view];
Following is the from which the points are converted to transform.
[self.view transformToFitQuadTopLeft:self.topLeftControl.center
topRight:self.topRightControl.center
bottomLeft:self.bottomLeftControl.center
bottomRight:self.bottomRightControl.center];
For Saving the transform Image to UIImage i have used following code using renderInContext
.
UIGraphicsBeginImageContext(view.frame.size);
[view.layer renderInContext:UIGraphicsGetCurrentContext()];
UIImage *newImage = UIGraphicsGetImageFromCurrentImageContext();
UIGraphicsEndImageContext();
and Second using drawViewHierarchyInRect
UIGraphicsBeginImageContextWithOptions(self.toothImageView_1.bounds.size, NO, 0);
BOOL ok = [self.toothImageView_1 drawViewHierarchyInRect:self.toothImageView_1.bounds afterScreenUpdates:YES];
UIImage *img = nil;
if( ok )
{
image = UIGraphicsGetImageFromCurrentImageContext();
}
self.imageView.image = image;
UIGraphicsEndImageContext();
I am getting a original framed square image not transformed image. I actually require a 3d transform image to be saved in the document directory.
Thanks in advance. Any suggestion and answers are most welcome.
You can do it by CoreImage Framework provided by Apple
Swift version