Draw emf smoothing

Is there a way to create an emf metafile (exported form of a paint tool) with anti-aliasing enabled? The tools I tried are not able to export the emf files that were displayed, so I wondered if I could turn it on manually when drawing emf in the OnPaint override of my controls.

If anyone can confirm that it is technically possible to create anti-aliased emf files, another solution would be to use a drawing tool that can export to anti-aliased emf or have a third-party converter do this later. If anyone knows such a tool, please let me know.

EDIT: If you look at the emf instructions , it seems that the emf itself actually cannot store information about whether it should be displayed smoothed or not. At least I could not find anything. It is more likely that anti-aliasing is performed by the playback engine. For example, when I open emf in Word 2007, it becomes smoothed. But not when I draw it using GDI + "playback engine" ( Graphics.DrawImage(...) ). or when I view it as a standard Windows image viewer. This leads me to believe that some tools do have their own emf playback engine. So maybe there is a free .NET library (preferably with source code) that gives me an object model of emf instructions stored in the analyzed emf file, so I can play it myself instead of using Graphics.DrawImage(...) ?

+7
c # gdi + antialiasing
source share
3 answers

We had a similar problem in the DirectX project. Scaling and scaling work to some extent, but it pretends to be. If you need to do something over and over again, you can parse the WMF records and draw them using GDI + smoothing.

The following streams are listed below (but they have been since 2005, so everything could 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 can do the job for you: I assume that you are fine with this:

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 is a program that will allow you to test EMF in various ways:

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

... and here is a free library that allows you to parse 122 EMF commands and output them to GDI +. This should probably do the trick:

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

... oh, as well as comment # 3 on the codeproject page. Looks like someone used to hit their head on the wall. Hope this solves your problem.

+9
source share

EMF uses GDI commands, not GDI +, so it has no concept of smoothing. I suspect that when you request GDI + to render a file, it sends it to GDI and simply copies the resulting bitmap.

Duplication of this code will be the same as re-executing GDI, so this is not very possible. Not impossible, just more work than it would justify the benefit. If there is an open source utility that can open EMF files outside of Windows, you can look at the source code.

I guess Word uses a downsampling trick.

+4
source share

EMF file is a list of GDI commands. Thus, it will not be anti-aliased, even if under GDI + you place a call to SmoothingMode () before drawing. You will need to list the GDI commands and then translate them into the GDI + commands.

In Vista / Seven, you can use the GDI + 1.1 function named GdipConvertToEmfPlus / ConvertToEmfPlus. If you want your program to work with XP, you must write your own enumeration, and then convert it to GDI + commands.

Enumerating GDI and then converting to GDI + may have been done by emfexplorer , but I wrote some code, maybe easier to use , even if it is written in Delphi.

I leave this answer only now (I'm late) because I spent a lot of time finding a solution using ConvertToEmfPlus and writing some customized open source code if this method is not available.

+3
source share

All Articles