0

次のコードがあります

- (void)ComputeRotationWithRadians:(CGFloat)rad {
    CGFloat width = exportImage.size.width;
    CGFloat height = exportImage.size.height;
    UIGraphicsBeginImageContext(CGSizeMake(width, height));
    CGContextRef ctxt = UIGraphicsGetCurrentContext();
    CGContextScaleCTM(ctxt, 1.0, -1.0);
    CGContextTranslateCTM(ctxt, 0.0, -exportImage.size.height);
    CGContextRotateCTM(ctxt, rad);
    CGContextDrawImage(UIGraphicsGetCurrentContext(), CGRectMake(0, 0, width, height), exportImage.CGImage);
    exportImage = UIGraphicsGetImageFromCurrentImageContext();
    UIGraphicsEndImageContext();
    [imageView setImage:exportImage];
}

問題は、回転が中心の周りで計算されたときに、左下隅の周りで発生することです。とにかくこれを変更することはありますか?

4

1 に答える 1

1

コードは、マトリックスを回転する前に変換しています。呼び出しを反転してみて、CGContextConcatCTM最初CGContextTranslateCTMにローテーションします。それとも何か他のものを探していますか?

于 2009-11-18T07:35:53.647 に答える