I'm trying to convert wmf image file into png format with c#.net.
But, saved image is unclear.
my code:
Metafile img = new Metafile(@"test.wmf");
MetafileHeader header = img.GetMetafileHeader();
Bitmap bitmap = new Bitmap((int)(img.Width / header.DpiX * 100), (int)(img.Height / header.DpiY * 100));
using(Graphics g = Graphics.FromImage(bitmap)){
g.DrawImage(img, 0, 0);
}
bitmap.Save("test.png", ImageFormat.Png);
How could I get it clear?
The .wmf file has extremely large values for DpiX/Y. You'll need to rescale the image to make it a better fit with the resolution of your monitor. This code produced a decent looking version of the metafile. You may want to tweak the scaling to fit your need or rescale the bitmap afterwards: