2012-09-11 3 views
0

가능한 중복 : 나는 두 이미지 전경 이미지 회전을 사용한
How to merge two images after rotate the image?회전 이미지를 배경 이미지와 병합하는 방법은 무엇입니까?

는 배경 이미지는 안정적이다. 이 두 이미지를 병합하는 방법은 무엇입니까? 그게 나를 위해 제대로 작동하지 않습니다. 미리 감사드립니다.

UIGraphicsBeginImageContext(itemSize); 
CGRect backgroundImageRect = CGRectMake(0.0, 0.0, itemSize.width, itemSize.height); 
CGRect foregroundImageRect = CGRectMake(rsImageView.frame.origin.x, rsImageView.frame.origin.y, rsImageView.frame.size.width, rsImageView.frame.size.height); 
[backgroundImageView.image drawInRect:backgroundImageRect]; 
[rsImageView.image drawInRect:foregroundImageRect]; 
overlappedImage = UIGraphicsGetImageFromCurrentImageContext(); 
UIGraphicsEndImageContext(); 

이 코드를 사용하고 있습니다. 그러나 회전 이미지를 병합하지 마십시오. 그것만이 마지막 이미지 프레임을 병합합니다.

+0

무슨 시도를 imgDisplayImage입니다? 어떻게 실패 했니? 오류가 무엇입니까? 당신의 코드는 무엇입니까? –

+0

UIGraphicsBeginImageContext (itemSize); CGRect backgroundImageRect = CGRectMake (0.0, 0.0, itemSize.width, itemSize.height); CGRect foregroundImageRect = CGRectMake (rsImageView.frame.origin.x, rsImageView.frame.origin.y, rsImageView.frame.size.width, rsImageView.frame.size.height); [backgroundImageView.image drawInRect : backgroundImageRect]; [rsImageView.image drawInRect : foregroundImageRect]; overlappedImage = UIGraphicsGetImageFromCurrentImageContext(); UIGraphicsEndImageContext(); 나는 이렇게 시험해 보았다. 그러나 회전 이미지가 제대로 병합되지 않습니다. – Mani

+1

의견에 많은 양의 코드를 게시하는 대신 질문을 편집하십시오. 감사! –

답변

0

여기 UIInageVew의 경우, lastRotation 전체 회전 각도

//...code...// 
CGContextRef context = UIGraphicsGetCurrentContext(); 
    CGContextSaveGState(context); 

    CGContextTranslateCTM(context, [self.imgDisplayImage center].x, [self.imgDisplayImage center].y); 
    CGContextRotateCTM(context, lastRotation); 
    CGContextTranslateCTM(context, 
          -self.imgDisplayImage.frame.size.width * [[self.imgDisplayImage layer] anchorPoint].x, 
          -self.imgDisplayImage.frame.size.height * [[self.imgDisplayImage layer] anchorPoint].y); 

     [self.imgDisplayImage.layer renderInContext:context]; 
    CGContextRestoreGState(context); 
    // . . . 
+0

도움 주셔서 감사합니다. 나는 이것을 시도 할 것이다. – Mani

관련 문제