0

重複の可能性:
画像を回転させた後に 2 つの画像を結合する方法は?

前景画像が回転し、背景画像が安定している2つの画像を使用しました。これらの2つの画像をマージするにはどうすればよいですか? それは私にとって適切に機能していません。前もって感謝します。

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();

私はこのコードを使用しています。ただし、回転画像をマージしないでください。最後の画像フレームのみをマージします。

4

1 に答える 1

0

ここで imgDisplayImage は 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);
    // . . . 
于 2012-09-11T11:51:23.623 に答える