UIGraphicsGetImageFromCurrentImageContext,alloc版本?

时间:2011-01-10 02:49:38

标签: ios image

UIGraphicsGetImageFromCurrentImageContext返回自动释放的UIImage。

想知道是否有办法从上下文中获取“alloc”-ed图像?

我想要一些与以下代码相当的东西,也许代码是我能做的最好的?

NSAutoreleasePool * pool = [[NSAutoreleasePool alloc] init];     
UIImage* image = get image by UIGraphicsGetImageFromCurrentImageContenxt
[image retain];
[pool release];

1 个答案:

答案 0 :(得分:1)

只需在结果上调用-retain

UIImage *image = [UIGraphicsGetImageFromCurrentImageContext() retain];