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]。如何从UIImage获取CGContextRef?
任何想法?十分感谢!!
谢谢,但即使我什么都没做,我又得到了一张颠倒的图像? – 2010-12-14 15:03:22
如果您使用Core Graphics进行绘图(例如'CGContextDrawImage()'),请记住它使用翻转的坐标系。 UIImage绘图方法不需要预翻转坐标系统。 – Costique 2010-12-14 17:09:45
Noob问题:这看起来非常浪费......我只想在我的图像上追加一些数据。我讨厌为此重绘整个事情。 – Ralphleon 2011-03-19 21:59:12