2011-09-30 5 views
1

카메라를 통해 사진을 찍거나 라이브러리에서 사진을 선택하고 문서 폴더에 jpg로 저장하는 앱이 있습니다. 하지만 저장하기 전에 90도 회전하고 싶습니다.iPhone에서 jpg 회전

누구나 나를 도와 줄 수 있기를 바랍니다.

감사

답변

1
아이폰 OS 4

이상 :
UIImage imageWithCGImage:scale:orientation:

아이폰 OS 3

이전 :
How to Rotate a UIImage 90 degrees?

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(); 
} 
+0

iOS 4.0 이상에서 사용할 수 있습니다. 3.x – eemceebee

+0

이 (가) 필요합니다. 모두 sdk 's와 (과) 일치하도록 편집되었습니다. –

0

당신은

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(); 
} 
처럼 그것을 할 수 있습니다

촬영 한 날짜 : here

0
img.transform = CGAffineTransformMakeRotation(3.14159265/2);