简体   繁体   English

如何处理混合模式项目中的打印?

[英]How to deal with printing in a mixed-mode project?

I have a mixed-mode project C#(WPF) -> C++/Cli -> unmanaged C++. 我有一个混合模式项目C#(WPF)-> C ++ / Cli->非托管C ++。

The graphics is dealt with in c++. 图形用c ++处理。 Some things are drawn and then transferred to c# thru a c++/cli interface object. 绘制一些东西,然后通过c ++ / cli接口对象将其转移到c#。 In c# this interface is put on a xaml form and shown. 在C#中,此接口以xaml形式显示。

Now I need to send this picture to a printpreview and then to a printer. 现在,我需要将此图片发送到打印预览,然后再发送到打印机。

How can it possibly be done? 怎么可能呢?

I thought about serializing, but couldn't find anything about serializing c++/cli interfaces. 我考虑过序列化,但是找不到有关序列化c ++ / cli接口的任何信息。

Any ideas? 有任何想法吗? Thanks! 谢谢!

EDIT Ok, so I have to explain further on. 编辑好的,所以我必须进一步解释。

In my c# project I have a c++/cli object, through which I can communicate to my graphics in c++, and this object has many methods, like f.ex: 在我的c#项目中,我有一个c ++ / cli对象,通过它可以与c ++中的图形进行通信,并且该对象有很多方法,例如f.ex:

object.DrawLine
object.DrawSmthElse
object.UpdateImage

etc. etc. 等等等

So, when in WPF I show a xaml form, the filling of this form is happening through this object, like I call all these methods to draw all the things I need. 因此,当在WPF中显示xaml表单时,该表单的填充正在通过该对象进行,就像我调用所有这些方法来绘制所需的所有东西一样。

Now the question is: I need to send to printer exactly this graphics part (which is done in c++). 现在的问题是:我需要把这个图形部分准确地发送到打印机(在c ++中完成)。 In what form should I do it? 我应该以什么形式来做? How can I pass this object to a DocumentViewer in c# for example? 例如,如何将该对象传递给c#中的DocumentViewer?

I hope that would be enough to put the question off hold. 我希望这足以解决这个问题。

Try sending the raw bytes of the bitmap to/from managed code and unmanaged code. 尝试向托管代码和非托管代码发送位图的原始字节。

On the managed side, you can create a bitmap object with a Stream . 在托管方面,您可以使用Stream创建一个位图对象。 You can also save an existing bitmap out to a stream . 您还可以将现有位图保存到流中 You can use a MemoryStream to easily read and write bytes to/from managed and unmanaged code within your C++/CLI objects. 您可以使用MemoryStream轻松地在C ++ / CLI对象中的托管代码和非托管代码中读写字节。

-- -

If the image is already on the Managed side (i couldn't tell if it is or not), then you can use the PrintPreviewDialog and PrintDialog ( example ) 如果该图像已经在Managed一侧(我无法确定它是否存在),则可以使用PrintPreviewDialog和PrintDialog( 示例

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 Azure功能引用混合模式程序集 - Azure Function referencing mixed-mode assembly 如何从C#调用混合模式C ++ / CLI程序集? - How can I call a mixed-mode C++/CLI assembly from C#? 混合模式.NET程序集有更好的性能吗? - Do mixed-mode .NET Assembly have better performance? 解决插件中混合模式DLL的引用程序集 - Resolving referenced Assemblies for mixed-mode DLL in a plugin IIS 7.5和混合模式身份验证(单点登录) - IIS 7.5 and mixed-mode authentication (single sign on) 用于在混合模式应用程序中检测内存损坏的工具 - Tool for detecting memory corruption in a mixed-mode application 混合模式调试(C++、C#、VB) - Debugging in mixed-mode (C++, C#, VB) 混合模式C ++ / CLI崩溃:atexit中的堆损坏(静态析构函数注册) - Mixed-mode C++/CLI crashing: heap corruption in atexit (static destructor registration) 在Visual Studio 2013中对托管单元测试使用混合模式调试 - Using mixed-mode debugging on a managed unit test in Visual Studio 2013 混合模式程序集是使用运行时版本'v1.1.4322'创建的,如果没有更多配置信息,则无法将其加载到运行时4.0中 - The mixed-mode assembly is created with runtime version'v1.1.4322' and cannot be loaded into runtime 4.0 without further configuration information
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM