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