Quartz 2D:从CGContext绘制到另一个CGContext

3

我有一个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);

这是最优的方法吗?有没有更好的方法呢?

1个回答

2

另一种选择似乎是创建一个子图像,我只能想象这可能不太优。


网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接