Search code examples
c#wmf.emf

Save metafile in C#


If I have a wmf or emf image in System.Drawing.Image, is there a way to save the metafile data with c# without rendering it as a bitmap? Calling Image.Save will render it to a bitmap and I want to keep the original data so that it would still be a valid .wmf or .emf format file.


Solution

  • It seems you can not.

    On this MSDN page, it is stated:

    Remarks

    When you use the Save method to save a graphic image as a Windows Metafile Format (WMF) or Enhanced Metafile Format (EMF) file, the resulting file is saved as a Portable Network Graphics (PNG) file instead. This behavior occurs because the GDI+ component of the .NET Framework does not have an encoder that you can use to save files as .wmf or .emf files.