如何从CGContextRef获取UIImage? [英] How do I get UIImage from a CGContextRef?
本文介绍了如何从CGContextRef获取UIImage?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有一个CGContextRef,我用位图上下文做了我的绘图。
I have a CGContextRef and I did my drawing stuff with the bitmap context.
现在,我想要一个函数调用来获取CGContextRef的UIImage 。我怎么做?
Now, I would like to have a function call to get a UIImage for the CGContextRef. How do I do that?
推荐答案
这样的事情:
-(UIImage*)doImageOperation
{
// Do your stuff here
CGImageRef imgRef = CGBitmapContextCreateImage(context);
UIImage* img = [UIImage imageWithCGImage:imgRef];
CGImageRelease(imgRef);
CGContextRelease(context);
return img;
}
这篇关于如何从CGContextRef获取UIImage?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文