[英]How to copy a System.Drawing.Graphics over another Graphics?
We got some code that implement printing using Printdocument
and it does all the drawing directly on the Graphics
object received in the PrintEventArgs
. 我们得到了一些使用
Printdocument
实现打印的代码,它直接在PrintEventArgs
接收的Graphics
对象上完成所有绘图。 It would be more convenient if the code doing the drawing used another canvas and we would add this canvas to the PrintEventArgs
Graphics
after. 如果进行绘图的代码使用了另一个画布,这将更加方便,然后我们将该画布添加到
PrintEventArgs
Graphics
。 Since the code already depends on the Graphics
object I need a canvas with this object. 由于代码已经取决于
Graphics
对象,因此我需要一个带有此对象的画布。 I also need a way to copy the canvas onto the PrintEventArgs
Graphics
. 我还需要一种将画布复制到
PrintEventArgs
Graphics
。 I can create a Graphics
from an Image
but as far as I know it needs to be stored on the disk. 我可以从
Image
创建Graphics
,但据我所知它需要存储在磁盘上。 Any suggestions? 有什么建议么?
Create an empty bitmap, get the bitmap's graphics object, and do your painting on that. 创建一个空的位图,获取位图的图形对象,然后在该对象上绘画。 You can save the bitmap to disk or wherever if you need to retrieve it later.
您可以将位图保存到磁盘或以后需要的任何位置。 Then paint the bitmap on top of your graphics object whenever you need that layer to be added.
然后,每当需要添加该图层时,将位图绘制在图形对象的顶部。 Should be pretty straightforward.
应该很简单。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.