简体   繁体   English

如何将System.Drawing.Graphics复制到另一个图形?

[英]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.

相关问题 如何删除System.Drawing.Graphics的默认构造函数? - How is the default constructor of System.Drawing.Graphics removed? 使用System.Drawing.Graphics时如何防止InvalidOperationException? - How to prevent InvalidOperationException when using System.Drawing.Graphics? 有关使用System.Drawing.Graphics的问题 - question about working with System.Drawing.Graphics MonoMac:NsView和System.Drawing.Graphics - MonoMac: NsView and System.Drawing.Graphics IntPtr.Zero在System.Drawing.Graphics中是什么意思 - What does IntPtr.Zero mean in System.Drawing.Graphics 有没有办法从C#编写System.Drawing.Graphics到PDF? - Is there a way to write System.Drawing.Graphics to PDF from C#? Windows Phone 8.1是否有任何System.Drawing.Graphics? - Is there any System.Drawing.Graphics for Windows Phone 8.1? 无法使System.Drawing.Graphics在窗体中工作 - Trouble Getting System.Drawing.Graphics to work in Form 克服 32 位限制,使用由数百万单位转换的 System.Drawing.Graphics 表面 - Overcoming 32-bit limitations, when using a System.Drawing.Graphics surface translated by millions of units 是否有任何围绕UnityEngine.GL命名空间的开源包装程序都可以提供System.Drawing.Graphics接口? - Is there any open source wrapper around UnityEngine.GL namespace that would provide System.Drawing.Graphics alike intereface?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM