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]。
有什么想法吗?非常感谢!!
答案 0 :(得分:8)
我认为你需要的是:
UIGraphicsBeginImageContextWithOptions(newImageSize, YES, 0);
CGContextRef context = UIGraphicsGetCurrentContext();
// drawing commands go here
UIImage *newImage = UIGraphicsGetImageFromCurrentImageContext();
UIGraphicsEndImageContext();
请注意UIGraphicsGetImageFromCurrentImageContext()
返回一个自动释放的UIImage实例。