绘制抗锯齿电动势

发布于 2024-08-11 17:36:49 字数 652 浏览 8 评论 0原文

有没有办法在启用抗锯齿功能的情况下绘制 emf 图元文件(从绘图工具导出)?我尝试的工具无法导出抗锯齿的 emf 文件,因此我想知道在控件的 OnPaint 覆盖中绘制 emf 时是否可以手动将其重新打开。

如果任何人都可以确认在技术上可以生成抗锯齿 emf 文件,则另一种解决方案是使用可以导出到抗锯齿 emf 的绘图工具,或者让第三方转换器稍后执行此操作。如果有人知道这样的工具,请告诉我。

编辑:查看 emf 说明 emf 本身似乎实际上无法存储是否要渲染抗锯齿的信息。至少我找不到任何东西。抗锯齿更有可能是由播放引擎完成的。例如,当我在 Word 2007 中打开 emf 时,它会呈现抗锯齿效果。但当我用 GDI+“播放引擎”(Graphics.DrawImage(...))绘制它时,情况就不同了。或者当我查看它时使用标准 Windows 图像查看器。 这让我相信有些工具实际上有自己的电动势播放引擎。因此,也许有免费的 .NET 库(最好带有源代码)可以为我提供存储在解析的 emf 文件中的 emf 指令的对象模型,这样我就可以自己播放它,而不是使用 Graphics.DrawImage(... )?

Is there a way to draw an emf metafile (exported form a drawing tool) with antialiasing enabled? The tools I tried are not capable of exporting emf files antaliased so I wondered if I can turn it back on manually when drawing the emf in the OnPaint override of my Controls.

If anyone can confirm that is technically possible to generate antialiased emf files, another solution would be to use a drawing tool that can export to antialiased emf or have a 3rd party converter do this later. If anyone knowns such a tool, please let me know.

EDIT: When looking at the emf instructions it doesn't seem that emf itself can actually store the information whether it is to be rendered antialiased or not. At least I couldn't find anything. It is more likely that the antialiasing is done by the playback engine. For example when I open an emf in Word 2007 it is rendered antialiased. But not when I draw it with GDI+ "playback engine" (Graphics.DrawImage(...)). or when I view it the standard windows image viewer.
This makes me believe that some tools actually have their own emf playback engine. So maybe there is free .NET library (preferably with source code) that give me an object model of the emf instructions stored in the parsed emf file so I can play it back myself instead of using Graphics.DrawImage(...)?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

っ左 2024-08-18 17:36:49

我们在 DirectX 项目中遇到了类似的问题。放大和缩小在一定程度上是有效的,但它是假的。如果这是您需要一遍又一遍地做的事情,您也许可以解析 WMF 的记录并使用 GDI+ 抗锯齿来绘制它们。

以下线程支持这一点(但它们来自 2005 年,所以事情可能已经改变):

http://www.dotnet247.com/247reference/msgs/28/144605.aspx

[编辑:]

这三个程序可能可以为您完成这项工作:我假设您可以手动完成:

http://emf-to-vector-converter-command-line-ser.smartcode.com/info .html

http://www.verypdf.com/pdf-editor/ index.html

http://www.ivanview.com/converter /emf-batch-converter.html

[编辑 II:]

好吧,这里有一个程序,可以让您以多种方式检查 EMF:

http://download.cnet.com/windows/3055-2383_4-10558240.html?tag=pdl-redir

...这里有一个免费软件库,可以让您解析 122 个 EMF 命令并将它们输出到 GDI+ 中。这应该可以解决问题:

http://www.codeproject .com/KB/GDI-plus/emfexplorer.aspx?msg=2359423

...哦,还要注意代码项目页面上的注释#3。看来以前有人用头撞过墙。希望这能解决您的问题。

We had a similar issue in a DirectX project. Upscaling and downscaling works to a certain degree, but it's faking it. If it's something you need to do over and over, you could perhaps parse the records of the WMF and draw them with GDI+ antialiased.

The following threads back this up (but they're from 2005 so things might have changed):

http://www.dotnet247.com/247reference/msgs/28/144605.aspx

http://www.dotnetmonster.com/Uwe/Forum.aspx/dotnet-sdk/1127/Graphics-DrawImage-metafile-no-antialiasing

[Edit:]

These three programs might do the job for you: I'm assuming you're ok with doing it by hand:

http://emf-to-vector-converter-command-line-ser.smartcode.com/info.html

http://www.verypdf.com/pdf-editor/index.html

http://www.ivanview.com/converter/emf-batch-converter.html

[Edit II:]

Well, here's a program that will let you inspect an EMF in various ways:

http://download.cnet.com/windows/3055-2383_4-10558240.html?tag=pdl-redir

...and here's a freeware library that will let you parse 122 of the EMF commands and output them in GDI+. That should probably do the trick:

http://www.codeproject.com/KB/GDI-plus/emfexplorer.aspx?msg=2359423

...oh, and notice also comment #3 on the codeproject page. Looks like someone have banged their heads against the wall before. Hope this solves your problem.

终止放荡 2024-08-18 17:36:49

EMF 使用 GDI 命令,而不是 GDI+,因此它没有抗锯齿的概念。我怀疑当您要求 GDI+ 渲染文件时,它会将其发送到 GDI 并仅复制生成的位图。

在代码中复制它与重新实现 GDI 相同,因此不太可行。并非不可能,只是工作量超出了其所能带来的好处。如果有一个开源实用程序可以在 Windows 之外打开 EMF 文件,您可以查看源代码。

我的猜测是 Word 正在使用下采样技巧。

EMF is using GDI commands, not GDI+, so it has no notion of antialiasing. I suspect that when you ask GDI+ to render the file, it sends it to GDI and just copies the resulting bitmap.

Duplicating this in code would be the same as reimplementing GDI, so it's not terribly feasible. Not impossible, just a larger job than the benefit would justify. If there is an open source utility that can open EMF files outside of Windows, you might look into the source code.

My guess is that Word is using the downsampling trick.

久伴你 2024-08-18 17:36:49

EMF 文件是 GDI 命令的列表。因此,即使在 GDI+ 下,您在绘图之前调用 SmoothingMode(),它也不会消除锯齿。您必须枚举 GDI 命令,然后将其转换为 GDI+ 命令。

在 Vista/7 下,您可以使用名为 GdipConvertToEmfPlus/ConvertToEmfPlus 的 GDI+ 1.1 函数。如果您希望您的程序在 XP 下运行,您应该编写自己的枚举,然后转换为 GDI+ 命令。

GDI 枚举然后可以转换为 GDI+ 已由 emfexplorer< 完成/a>,但我已经编写了一些代码可能更容易理解,即使它是用 Delphi 编写的。

我现在才给出这个答案(我迟到了),因为我花了很多时间使用 ConvertToEmfPlus 找到解决方案,并编写了一些经过调整的开源代码,以防该方法不可用。

EMF file is a list of GDI commands. So it won't be anti-aliaised, even if under GDI+, you put a SmoothingMode() call before the drawing. You'll have to enumerate the GDI commands, then translate it into GDI+ commands.

Under Vista/Seven, you can use GDI+ 1.1 function named GdipConvertToEmfPlus/ConvertToEmfPlus. If you want your program to work with XP, you should write your own enumeration, then conversion to GDI+ commands.

The GDI enumeration then conversion to GDI+ is possible has been done by emfexplorer, but I've written some code perhaps more easy to follow, even if it's written in Delphi.

I'm putting this answer just now (I'm late), because I spent a lot of time finding out a solution using ConvertToEmfPlus, and writing some tuned open source code in case this method is not available.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文