在我的应用程序中,我可以将图像旋转 90 度。当我旋转多次时......它变得模糊(缺少像素清晰度)。我失去了img质量。任何人都可以建议实现这一点的方法。
在这里,我使用了一个按钮来旋转图像。用于旋转的代码是:
- (UIImage *)rotateImage:(UIImage *) img
{
CGRect rect = CGRectMake(0, 0, img.size.width, img.size.height);
UIGraphicsBeginImageContext(rect.size);
CGContextRef context = UIGraphicsGetCurrentContext();
if (img.imageOrientation == UIImageOrientationRight)
{
CGContextRotateCTM (context, M_PI_2);
}
else if (img.imageOrientation == UIImageOrientationLeft)
{
CGContextRotateCTM (context, -(M_PI_2));
}
else if (img.imageOrientation == UIImageOrientationDown)
{
// NOTHING
}
else if (img.imageOrientation == UIImageOrientationUp)
{
CGContextRotateCTM (context, M_PI_2);
}
//CGContextRotateCTM(context, M_PI_2);
CGContextTranslateCTM(context,0, -(img.size.width));
[img drawInRect:CGRectMake(0, 0, img.size.height,img.size.width)];
UIImage *newImage = UIGraphicsGetImageFromCurrentImageContext();
appDelegate.savedImage=newImage;
UIGraphicsEndImageContext();
CGContextRelease(context);
return newImage;
}
提前致谢。