Hi Guys,
I have written following code for cropping image in oval. but not getting expected result. The original image size is 382x453. and put an eclipse at CGRectMake(50, 100, 100, 150). But image always crop from the 0,0 position of the original image. I'm doing somthing worng in this code. please help me out where i'm wrong. Many thanks,Ghufran
CGSize croppedSize = CGSizeMake(100, 150);
CGRect clippedRect = CGRectMake(0, 0, croppedSize.width, croppedSize.height);
UIGraphicsBeginImageContext(croppedSize);
CGContextBeginPath(UIGraphicsGetCurrentContext());
CGContextAddEllipseInRect(UIGraphicsGetCurrentContext(), clippedRect);
CGContextClosePath(UIGraphicsGetCurrentContext());
CGContextClip(UIGraphicsGetCurrentContext());
CGContextTranslateCTM(UIGraphicsGetCurrentContext(), 0, croppedSize.height);
CGContextScaleCTM(UIGraphicsGetCurrentContext(), 1.0, -1.0);
CGContextDrawImage(UIGraphicsGetCurrentContext(), CGRectMake(clippedRect.origin.x * -1, clippedRect.origin.y * -1, mImage.size.width, mImage.size.height), mImage.CGImage);
//pull the image from our cropped context
UIImage *croppedImage = UIGraphicsGetImageFromCurrentImageContext();