我正在尝试在用户编辑的位置和缩放比例中将旋转和缩放的uiImageView保存为uiImage。但是我只能像编辑之前那样保存原始图像。如何以相同的缩放和旋转保存uiImageView中显示的图像?我已经读到我需要使用uigraphicsgetcurrentContext(),但是我得到了相同的原始图像保存(但翻转),而不是旋转的图像!!建议和提示非常有用。
提前谢谢。
铝
(UIImage *)getImage
{
CGSize size = CGSizeMake(250, 250);
UIGraphicsBeginImageContext(size);
CGContextRef context = UIGraphicsGetCurrentContext();
CGMutablePathRef path = CGPathCreateMutable();
// Add circle to path
CGPathAddEllipseInRect(path, NULL, CGRectMake(0, 0, 250, 250));
CGContextAddPath(context, path);
// ****************** touchImageView is my UIImageView ****************//
CGContextDrawImage(context, CGRectMake(0, 0, 250, 250), [touchImageView image].CGImage);
UIImage *scaledImage = UIGraphicsGetImageFromCurrentImageContext();
// Clip to the circle and draw the logo
CGContextClip(context);
UIGraphicsEndImageContext();
return scaledImage;
}