将矢量图像(例如,emf)文件转换为图形路径 [英] converting a vector image (eg emf) file into a graphics path

查看:123
本文介绍了将矢量图像(例如,emf)文件转换为图形路径的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

你好,
问题的简短版本:
有什么方法可以从EMF(或类似文件)文件创建GraphicsPath?


问题的长版:

我有一种方法,可以在绘制图像之前安排图像的位置,以使它们不重叠.目前,为每个图像分配一个RectangleF,该矩形与图像的大小和当前位置相匹配.如果两个矩形重叠,则移动其中一个(例如向上),以使它们不重叠.安排完成后,图像将绘制到画布"上.
(这些经过整理的图像将作为EMF文件保存到硬盘中.)
我需要从使用矩形更改为使用GraphicsPaths,以便这种自动排列更加紧凑".我无法弄清楚如何从EMF文件或图元文件生成图形路径...
有什么办法可以从EMF文件创建图形路径?

谢谢!
Lee

Hi there,
Short version of the question:
Is there any way to create a GraphicsPath from an EMF (or similar) file?


Long version of the question:

I have a method which arranges the position of images, before they are drawn, such that they do not overlap. At present, each image is assigned a RectangleF which matches the size and current location of the image. If two rectangles overlap, one of them is moved (eg up), so that they do not overlap. Once arranging has taken place, the images are drawn onto the ''canvas''.
(These images which get arranged are saved to the hard disc as EMF files.)
I need to change from using rectangles to using GraphicsPaths, so that this auto arranging is much ''tighter''. I can''t figure out how to generate a graphics path from an EMF file or metafile though...
is there any way to create a graphics path from an EMF file?

Thanks!
Lee

推荐答案

我之前做过类似的事情.就我而言,我创建了一个转换器,将记录从WMF,EMF和EMF +图元文件转换为矢量图形对象.

没有GDI +方法或方法集可将图元文件转换为图形路径.我发现我必须使用Graphics.EnumerateMetafile(),并在回调中手动从每个记录中提取数据并分别解释每个记录类型.这是相当多的工作,但是效果非常好.

有3种不同的图元文件格式:

  • WMF:从16位Windows天开始-不支持曲线(贝塞尔曲线,基数等)和其他各种GDI功能
  • EMF:GDI32的图元文件格式.支持曲线和GDI允许的几乎所有其他功能
  • EMF +:GDI +的图元文件格式. GDI +工程图记录的格式与常规EMF记录完全不同,但具有更多功能.
I have done something similar before. In my case, I created a converter to convert records from WMF, EMF, and EMF+ metafiles to vector graphics objects.

There is no GDI+ method or set of methods to turn a metafile into a graphics path. I found that I had to use Graphics.EnumerateMetafile(), and in the callback I manually extracted the data from each record and interpreted each record type individually. It was quite a bit of work but the results were very good.

There are 3 different metafile formats:

  • WMF: from the 16-bit windows days - doesn''t support curves (bezier, cardinal, etc) and various other GDI features
  • EMF: GDI32''s metafile format. Supports curves and (almost) everything else GDI allows
  • EMF+: GDI+''s metafile format. GDI+ drawing records are entirely different in format than normal EMF records, but allow a lot more features.


**免责声明* *
我不知道这是否可以解决您的问题.
****************************************************** **********

有一个MetaFile类,它具有一个PropertyItems集合.

PropertyItem类具有Len(值数组的长度),Type(描述数组包含的内容)和Value(实际数组)的属性.
是否可以解密PropertyItem来提供信息以构建GraphicsPath,我不知道,但是,如果其他所有方法都失败了,则可能值得研究.
**Disclaimer**
I do not know if this will lead to a solution to your problem.
************************************************************

There is a MetaFile class which has a PropertyItems collection.

The PropertyItem class has properties for Len (length of the array of values), Type (describes what the array contains) and Value (the actual array).

Whether a PropertyItem can be deciphered to provide information to build a GraphicsPath I have no idea but, if all else fails, it might be worth looking at.


这篇关于将矢量图像(例如,emf)文件转换为图形路径的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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