I try to create a vector graphic with c# Metafile class.
The following code produces only raster graphics.
How a vector graphic can be created?
using System;
using System.Drawing;
using System.Drawing.Imaging;
using System.IO;
using System.Windows.Forms;
class CreateMetafileMemory : Form
{
MemoryStream ms = new MemoryStream();
Graphics g;
public static void Main()
{
Application.Run(new CreateMetafileMemory());
}
public CreateMetafileMemory()
{
Graphics grfx = CreateGraphics();
MemoryStream ms = new MemoryStream();
IntPtr ipHdc = grfx.GetHdc();
Metafile mf = new Metafile(ms, ipHdc);
grfx.ReleaseHdc(ipHdc);
grfx.Dispose();
grfx = Graphics.FromImage(mf);
grfx.FillEllipse(Brushes.Gray, 0, 0, 100, 100);
grfx.DrawEllipse(Pens.Black, 0, 0, 100, 100);
grfx.DrawArc(new Pen(Color.Red, 10), 20, 20, 60, 60, 30, 120);
grfx.Dispose();
mf.Save(@"C:\file.emf", ImageFormat.Emf);
mf.Save(@"C:\file.wmf", ImageFormat.Wmf);
}
}
All the two files which will be produced are PNG-Files. You can verify this by an Hex-Editor.