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.
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.
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
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.
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.
© 2022 - 2024 — McMap. All rights reserved.