6
    CGContextRef context = ??; // get from UIImage *oldImage

    CGContextSaveGState(context);   
    CGRect drawRect = CGRectMake(0, 0, 320, 480);
    CGContextConcatCTM(context, transform);
    UIImage *newImage = [[UIImage alloc] init];
    CGContextDrawImage(context, drawRect, newImage.CGImage);
    [newImage drawInRect:CGRectMake(0, 0, 320, 480)];

    CGContextRestoreGState(context);

要するに、私がやりたいのは[UIImage->いくつかの変換を行う->変換されたUIImage]です。

何か案は?本当にありがとう!!

4

1 に答える 1

8

私はあなたが必要としているのはこれだと思います:

UIGraphicsBeginImageContextWithOptions(newImageSize, YES, 0);
CGContextRef context = UIGraphicsGetCurrentContext();
// drawing commands go here
UIImage *newImage = UIGraphicsGetImageFromCurrentImageContext();
UIGraphicsEndImageContext();

UIGraphicsGetImageFromCurrentImageContext()自動リリースされたUIImageインスタンスを返すことに注意してください。

于 2010-12-14T09:40:58.947 に答える