Quartz 2D:从一个 CGContext 绘制到另一个 CGContext
我有一个 CGBitmapContext (bitmapContext),我想将它的一些矩形部分 (rect) 绘制到当前 CGContext (context)。
现在我这样做:
CGContextRef context = UIGraphicsGetCurrentContext();
CGImageRef cgImage = CGBitmapContextCreateImage(bitmapContext);
CGContextClipToRect(context, rect);
CGContextDrawImage(context, CGRectMake(0, 0, width, height), cgImage);
CGImageRelease(cgImage);
这是最佳的吗?最好的方法是什么?
I have a CGBitmapContext (bitmapContext) and I would like to draw some rectangle part (rect) of it to the current CGContext (context).
Right now I do that way:
CGContextRef context = UIGraphicsGetCurrentContext();
CGImageRef cgImage = CGBitmapContextCreateImage(bitmapContext);
CGContextClipToRect(context, rect);
CGContextDrawImage(context, CGRectMake(0, 0, width, height), cgImage);
CGImageRelease(cgImage);
Is it optimal? What is the best way to do it?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
另一种选择似乎是创建一个子图像,我只能想象这不太理想。
The alternative seems to be to create a sub-image, which I can only imagine to be less optimal.