using(System.Drawing.Imaging.Metafile img = new System.Drawing.Imaging.Metafile(@fileCollection[i].FilePath))
{
System.Drawing.Imaging.MetafileHeader header = img.GetMetafileHeader();
float scale = header.DpiX / 96f;
using (System.Drawing.Bitmap bitmap = new System.Drawing.Bitmap((int)(scale * img.Width / header.DpiX * 100), (int)(scale * img.Height / header.DpiY * 100)))
{
using (System.Drawing.Graphics g = System.Drawing.Graphics.FromImage(bitmap))
{
g.Clear(System.Drawing.Color.White);
g.ScaleTransform(scale, scale);
g.DrawImage(img, 0, 0);
}
bitmap.Save(@"C:\Users\Public\Pictures\Sample Pictures\test.png", System.Drawing.Imaging.ImageFormat.Png);
}
}
Image img = new Image();
img.Source = new BitmapImage(new Uri(fileCollection[i].FilePath));
list_pic.Items.Add(img);
wmf转为png
最新推荐文章于 2023-11-13 17:24:44 发布