在iPhone上旋转jpg
我有一个应用程序,可以通过相机拍摄照片,或者从库中选择照片,并将其保存为文档文件夹中的jpg。但在保存之前,我想旋转90度 希望这里有人能帮我 感谢使用iOS 4及更高版本:在iPhone上旋转jpg,iphone,iphone-sdk-3.0,Iphone,Iphone Sdk 3.0,我有一个应用程序,可以通过相机拍摄照片,或者从库中选择照片,并将其保存为文档文件夹中的jpg。但在保存之前,我想旋转90度 希望这里有人能帮我 感谢使用iOS 4及更高版本: 对于iOS 3及以前版本: 对于iOS 4及更高版本: 对于iOS 3及以前版本: 你可以这样做 static inline double radians (double degrees) {return degrees * M_PI/180;} UIImage* rotate(UIImage* src, UIIm
对于iOS 3及以前版本:
对于iOS 4及更高版本:
对于iOS 3及以前版本:
你可以这样做
static inline double radians (double degrees) {return degrees * M_PI/180;}
UIImage* rotate(UIImage* src, UIImageOrientation orientation)
{
UIGraphicsBeginImageContext(src.size);
CGContextRef context = UIGraphicsGetCurrentContext();
if (orientation == UIImageOrientationRight) {
CGContextRotateCTM (context, radians(90));
} else if (orientation == UIImageOrientationLeft) {
CGContextRotateCTM (context, radians(-90));
} else if (orientation == UIImageOrientationDown) {
// NOTHING
} else if (orientation == UIImageOrientationUp) {
CGContextRotateCTM (context, radians(90));
}
[src drawAtPoint:CGPointMake(0, 0)];
return UIGraphicsGetImageFromCurrentImageContext();
}
摘自你可以像
static inline double radians (double degrees) {return degrees * M_PI/180;}
UIImage* rotate(UIImage* src, UIImageOrientation orientation)
{
UIGraphicsBeginImageContext(src.size);
CGContextRef context = UIGraphicsGetCurrentContext();
if (orientation == UIImageOrientationRight) {
CGContextRotateCTM (context, radians(90));
} else if (orientation == UIImageOrientationLeft) {
CGContextRotateCTM (context, radians(-90));
} else if (orientation == UIImageOrientationDown) {
// NOTHING
} else if (orientation == UIImageOrientationUp) {
CGContextRotateCTM (context, radians(90));
}
[src drawAtPoint:CGPointMake(0, 0)];
return UIGraphicsGetImageFromCurrentImageContext();
}
摘自iOS 4.0及更高版本中提供的。iOS 4.0及更高版本中提供的3.x版需要它。3.x版需要它吗
img.transform = CGAffineTransformMakeRotation(3.14159265/2);