How to copy one CGContextRef to another?

房东的猫 提交于 2019-12-24 19:07:06

问题


in -drawRect:, I created a secondary CGContextRef using CGBitmapContextCreate().

When I'm done with this context, I need to copy it's contents over to the "original" context of -drawRect:. How can I do that?

Reason why I create an additional context: I hope to get CGContextClipToMask() to work in a view that has a transparent background. My idea is to do all the mask-drawing and clipping in another context that has the appropriate color (non-transparent, no alpha), and then somehow paste that result back to the original context.


回答1:


you can use memcpy function. Read on google for how to use it.




回答2:


just use CGBitmapContextCreateImage, and the actual physical copy of the bits occur only if the underlying data in the bitmap graphics context is modified.



来源:https://stackoverflow.com/questions/6315961/how-to-copy-one-cgcontextref-to-another

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!