2012-09-10 1 views
-1

내 애플리케이션에서는 왼쪽으로 회전, 오른쪽으로 회전, 수직선 뒤집기, UIImageview으로 수평 이동, 등 여러 가지 변형을 적용합니다. 이러한 작업을 적용하면 UIImageview의 위치가 변경됩니다. 이 변경된 이미지를 원본 이미지가 아닌 다른보기에 지정하려고합니다. imageview.image을 다른보기에 할당 할 때 원본 이미지가 지정됩니다. 이 문제를 어떻게 해결할 수 있습니까?변환 된 UIImageview 이미지를 다른 UIImageview에 할당하는 방법은 무엇입니까?

데이빗에 의해 제안은 왼쪽 회전

//rotation left; 
     int x1=ivPhoto.frame.origin.x; 
     int y1=ivPhoto.frame.origin.y; 

     UIGraphicsBeginImageContext(ivPhoto.image.size); 


     CGAffineTransform transform = CGAffineTransformMakeRotation(DEGREES_TO_RADIANS(degrees2));   

     CGContextConcatCTM(UIGraphicsGetCurrentContext(), transform); 
     [ivPhoto.image drawInRect:CGRectMake(x1,y1,ivPhoto.frame.size.width, ivPhoto.frame.size.height)]; 

     UIImage *newImage = UIGraphicsGetImageFromCurrentImageContext(); 

     ivPhoto.image=newImage; 

에 대해 다음 코드를 적용하고하지만 난 당신의 변환과 같은 새로운 이미지를 캡처 완료되면 image.the 이미지가 원래의 위치

답변

0

에 회전지고 있지 않다 이 :

CGSize fittingSize = yourImgView.frame.size; 
UIGraphicsBeginImageContext(fittingSize); 
[yourImgView.layer renderInContext:UIGraphicsGetCurrentContext()]; 
UIImahe *capImage = UIGraphicsGetImageFromCurrentImageContext(); 
UIGraphicsEndImageContext(); 

지금 변환 이미지

와 다른 UIImageView에 이러한 capImage을 할당
0

상황에 따라 변경하고 완료되면 UIImage에 저장해야합니다.

UIGraphicsBeginImageContext(sizeOfImage); 


    CGAffineTransform transform = CGAffineTransformIdentity; 

등 등

CGContextConcatCTM(UIGraphicsGetCurrentContext(), transform); 
[imageView.image drawInRect:CGRectMake(position.x, position.y, size.width, size.height)]; 
UIImage *newImage = UIGraphicsGetImageFromCurrentImageContext(); 
: 그런 다음 이미지 뷰에서 해당 이미지를 설정