How can I load an EMF file into WPF?

Is there a way to load via code (C#) an EMF or WMF file and render it within WPF

Does WPF natively support this type
Seems it should since the WMF and EMF file types are vector based.




Answer this question

How can I load an EMF file into WPF?

  • 1v1jo9sm

    I know this isn't what you were looking for, but it's an interesting tool to watch. I suppose if you could get source for it, you could do something in semi-realtime.

    http://lab.aspitalia.com/lab.aspx ID=15#eng

    This article discusses reasons why xaml is supposed to be much better then WMF:

    http://msdn.microsoft.com/library/default.asp url=/library/en-us/dnlong/html/avalongraphics.asp

    Still, good reasons aside, I'm very surprised MS didn't include their own WMF import helper.

    Jared


  • Edwin Santos

    Acrylic can open windows metafiles and convert it to xaml.

    http://www.microsoft.com/products/expression/en/graphic_designer/default.aspx


  • zbig555z

    Whenever I ask about these things the answers are:

    1) WPF does not support EMF/WMF, use WinForms interop.

    2) Office does not support XAML, use WPFHosting in your own control.

    Basically they are two separate groups that are not doing much to support interop scenarios beyond the bare minimum. For the first release using WPF for Office related work is going to take deep expertise in both environments to be sucessful.



  • Jordi

    Microsoft ought to first check what this .emf ending can do to current XP SP2 security.

    This site: http://graphic.snupigood.com/

    shows a list of files that if clicked on will begin a sequence of events that will infect your computer with a.bat using the .emf extension.

    The full file name is: Microsoft_Windows_Advanced_Upgrade_Wizard_Logo______________________________________________________________________.emfx

    and shows up in local settings under the temporary internet files where it calls svchost.exe and replaces it with its own version.

    So, the .emf file was a convenient way for some hacker and virus writer to skate right around Windows security and the multimillionaire owners of the network hosting snupigood, and his parent porn site, have figured out not only how to hijack your browser, but how to hijack it from falsely advertised link on Google - the billionaire boys who keep getting fatter in San Francisco, but won't fix their stupid network.

    And people wonder how viruses spread. I checked out the ownership of this site, the site that hosts it, and the massive network run by some freaks from Harvard, Dallas, Israel, former landgrabbers known as GI Partners with lots of fancy degrees and jobes behind their names, but either ignorant as hell, or, part of this pornography and organized crime ring in California.

    esthost and estdomains, using the New York City three country shell game to route from California, to incorporation state Delaware, to UK, to Russia, and then make it look like their scripts come from Russia. They have also developed the phpBB worm that the phpBB developers keep complaining about, but can't find the authors of; they're in California boys!

    I've had quite enough of these rich bimbos attacking smaller startups, stealing land and money from people, and now, hacking into computers by using script code, which these millionaires know quite well, without being investigated. Maybe Microsoft ought to look at who is attacking its back from California, yet again!

    What a gang; GI Partners; selling bandwidth paid for by pornography and breaking and entering into unsuspecting internet surfer's computers, with the help of false advertising on Google links.

    And you thought they were script kiddies. Sorry, PhD's from the financial industry at the NYSE; who else would do anything for money, even prostitution Their schools read like a who's who of universities: Harvard, Stanford, Princetion, and Yale. Guess what, they may not write the viruses, but you can bet they gave the orders to have them written.

    Microsoft, you had better check this out. And if you want to hire me, I'm available, I could use the reward money for catching these hackers.



  • ElvisAsaftei

    Hello Peggi,

    By writing such a Windows Imaging Component Codec for EMF format, would it be possible to preserve all vector information, or is the output always a pixel-based format

    Does such a Codec run as managed code, or do we need to use C++ / unmanaged code

    Thanks,
    Adrian



  • Bakiya

    Although you provide a "work around" method to this issue, it doesn't really answer the question about Metafile (wmf, emf) support.

    Having hundreds of emf vector based images would make this conversion a cumbersom task.

    Question: Lets say I now have the XAML conversion from Graphic expression, how do programmically read (C#) in the XAML file and render it to the canvas



  • Steeves Saillant

    WPF does not support the EMF and WMF image formats. These formats are more susceptible to security vulnerabilities than other image formats, so we do not intend to support them.

    However, the Windows Imaging Component, which is part of WPF, is extensible. A 3rd party could write a codec for EMF or WMF that's compatible with the Windows Imaging Component. Anyone who installs the codec will be able to display the corresponding image format in any WPF application or any application built on WIC. (Like any image format, if a security vulnerability is found, the codec will be disabled until a patch is released.)



  • Deepak_Sharma_f2a878

    Does anyone have an answer to this query

    I would think Microsoft would support Metafiles since I beklieve they developed the WMF format.

    Anyone at Microsoft Help!

  • cbhkenshin

    If you were to write a Windows Imaging Component codec for the EMF format, the output would be pixel based.

    All codecs written for the Windows Imaging Component are written in unmanaged code. However any Windows Imaging Component codecs installed on the system are accessible through WPF automaitcally (without any extra code) when APIs such as BitmapDecoder, BitmapFrame, BitmapImage are used.


  • How can I load an EMF file into WPF?