WMF / EMF文件格式转换C# [英] WMF / EMF File Format conversion C#

查看:2003
本文介绍了WMF / EMF文件格式转换C#的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在我的计划,我有一个要求,播放或分析Windows图元(WMF和EMF)。我已经通过MSDN和谷歌挖,我也来最接近的是图形。 EnumerateMetafile方法。我可以得到它的工作,在我的EnumerateMetafileProc回调被调用,然后我可以叫PlayRecord。现在缺少的,是如何得到有用的数据指出,回调

In my program, I have a requirement to "playback" or "parse" windows metafiles (WMF and EMF). I have dug through MSDN and Google, and the closest I have come is the Graphics. EnumerateMetafile method. I can get it to work, in that my EnumerateMetafileProc callback is called, and I can then call PlayRecord. What is missing, is how to get usefull data out of that callback.

例我看了看:的 http://msdn.microsoft.com/en-us/library/ms142060.aspx

回调有RECORDTYPE参数,它是一个枚举。嗯,这看起来是有用的,但他们似乎没有办法将数据转换成任何有用的类型。

The callback has a recordType parameter, which is an ENUM. Well this looks useful, except their seems to be no way to cast the data into any useful type.

我的目标是要回放的WMF / EMF的建立,这样我就可以进行函数调用其中有像(DrawLine的,DrawPoint,DrawArc)方法专业图形类。从某种意义上说,我重新创建WMF / EMF在一个完全不同的格式(转换)拉。

My goal is to play back the creation of the WMF/EMF, so that I can make function calls to a specialized graphics class which has methods like (DrawLine, DrawPoint, DrawArc). In a sense, I am re-creating the WMF/EMF drawing in a completely different format (Converting).

在任何帮助,这是非常赞赏。

Any help in this is extremely appreciated.

推荐答案

Graphics.EnumerateMetafile ,不幸的是围绕Win32 API的一个非常,非常薄的一层。在EMF的每条记录,你会得到一个非托管内存地址记录专用结构。什么它可能不包含文档 - !不过呢,也没有太多的在Win32世界要么去上

Graphics.EnumerateMetafile, is unfortunately a very, very thin layer around the Win32 APIs. For each record in the EMF, you get an unmanaged memory address for the record-specific struct. No documentation about what it might contain - but then, there isn't much to go on in the Win32 world either.

所以,你需要查阅古籍

本书以一个代码示例来CD- ROM 包括使用EMF播放API示例程序。

This book came with a code sample CD-ROM that includes sample programs to use the EMF playback API.

这让你有两个问题。


  1. 这本书显然是绝版,所以请确保任何使用复制你购买包括工作CD-ROM。

  1. The book is apparently out of print, so make sure that any used copy you buy includes a working CD-ROM.

的示例代码都是用C / C ++,这将是一个不平凡的任务申报必要的互操作为用于描述所有的EMF记录的100个左右结构。

The sample code is all in C/C++ and it will be a non-trivial task to declare the necessary interop for the 100 or so structures that are used to describe all the EMF records.

所以,另一种办法是,在申报.NET一个巨大的接口,具有每GDI的方法叫你需要拦截,然后用C ++ / CLI适应例如C ++代码,以便它调用到你的每个记录巨大的接口。

So another approach might be to declare a huge interface in .NET that has a method for every GDI call you need to intercept, and then use C++/CLI to adapt the example C++ code so it calls onto your huge interface for each record.

更新

虽然EMF播放MSDN文档不包括具体的EMF记录的详细信息,微软已经分别出版的完整规范截至2006年:

Although the MSDN documentation for EMF playback doesn't include details of specific EMF records, Microsoft has separately published the complete specification as of 2006:

MS-EMF:增强型图元文件格式

此外,我联系到上述本书的作者已经提供下载CDROM样本的源代码:

Also the author of the book I linked to above has made the source code of the CDROM samples available to download:

对于Windows图形编程的源代码

这篇关于WMF / EMF文件格式转换C#的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆