Monday, 15 April 2013

iphone - UIImageView: Rotated and Scaled. How do I save the results? -


I am trying to save a rotated and in position as a UIImage and zoom scale that user too UIImageView enhanced with edit But I can only manage to save the original image because it was before editing. How can I save the image as shown in UIMAJEW with the same scaling and rotation? I have read that I need to use UIGraphicsGetCurrentContext (), but I get the same original image saved (but flipped) and not rotated one !! Suggestions and hints will really be helpful. Thank you very much. Al

  (UIImage *) getImage {CGSize size = CGSizeMake (250, 250); UIGraphicsBeginImageContext (size); CGContextRef Reference = UIGraphicsGetCurrentContext (); CGMutablePathRef Path = CGPathCreateMutable (); // Path to the join circle CGPathAddEllipseInRect (path, zero, CGRectMake (0, 0, 250, 250)); CGContextAddPath (reference, path); // ****************** TouchImageView is my UIImageView ****************************** CGContextDrawImage (Reference, CGRectMake (0, 0, 250, 250), [Touch ImageView Image]. CGImage); UIImage * scaledImage = UIGraphicsGetImageFromCurrentImageContext (); // Drag the clip and logo into the circle CGContextClip (reference); UIGraphicsEndImageContext (); Return scale image;  

}

I do not see anything in code Posted that an image rotates, did you forget to add it?

It seems that you are on the right track. Now you can use the Transform routine CGContextScaleCTM and CGContextRotateCTM to properly modify your conversion metrics. , And then (to avoid flipping), use - [UIImage drawAtPoint:] to attract UIImage instead of using CGContextDrawImage


No comments:

Post a Comment