Save metafile in C#
Asked Answered
K

3

6

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.

Karns answered 9/4, 2009 at 4:35 Comment(1)
possible duplicate of GDI+ / C#: How to save an image as EMF?Braddock
I
2

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.

Isothere answered 9/4, 2009 at 7:58 Comment(1)
How to save it as PNG?Renunciation
W
4

Despite this MSDN page, it is possible to save a true EMF file. See this question: gdi-c-how-to-save-an-image-as-emf

Walther answered 21/5, 2009 at 21:19 Comment(1)
see the answer of user120789 in the link mentioned aboveFlabby
I
2

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.

Isothere answered 9/4, 2009 at 7:58 Comment(1)
How to save it as PNG?Renunciation
A
2

It is possible to save a metafile in its orignal format if you use the gdi32.dll.

I am using the method described here and it works fine.

Abstriction answered 6/4, 2010 at 9:43 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.