I have a UIImage that I put in a UIImageView which has a pinch gesture recognizer attached to it which I use to scale the image. When I scale the image in the UIImageView, there is no distortion and it scales perfectly. However, I need to resize the UIImage while not in the UIImageView, and when I do this using the following code, the result is slightly skewed:
CGFloat width = self.imageView.frame.size.width;
CGFloat height = self.imageView.frame.size.height;
UIGraphicsBeginImageContext(CGSizeMake(width, height));
[self.image drawInRect:CGRectMake(0, 0, width, height)];
UIImage *resizedImage = [UIGraphicsGetImageFromCurrentImageContext() retain];
UIGraphicsEndImageContext();
As you can see I'm taking the height and width from the imageView, because that is what the image needs to be scaled to.
I know that it has to be possible to scale it perfectly if the imageView is able to do this, does anyone happen to know what I'm doing incorrectly?
UPDATE: I attached a before / after of an image (which has been rescaled by the user in an imageview) and how it looks after I resized it using the above method.