Creating a vectorized metafile (wmf)
-
Does anyone know how to construct a vectorized (not a rasterized!, i.e. not a bitmap) metafile? I've tried the code below, but all I get a rasterized picture (I suspect it to be a PNG :wtf: ).
Metafile MyMetafile = null; using (Graphics RefGraph = Graphics.FromHwnd(IntPtr.Zero)) { IntPtr RefDC = RefGraph.GetHdc(); // Make the metafile: MyMetafile = new Metafile(RefDC, new Rectangle(0, 0, MyWidth, MyHeight), MetafileFrameUnit.Pixel); RefGraph.ReleaseHdc(RefDC); } using (Graphics Graph = Graphics.FromImage(MyMetafile)) { // Draw: Brush Br = new SolidBrush(Color.Blue); Graph.FillRectangle(Br, 0, 0, MyWidth / 2, MyHeight / 2); // ... more line drawing. } MyMetafile.Save(@"c:\temp\test.wmf", ImageFormat.Wmf);
I'm using a screen device context as a basis for the metafile since a reference DC is required when recording a metafile. Maybe that's what's wrong, because this screen DC is rasterized. But I don't know how to get a vectorized DC or if such a thing even exists. Or maybe I'm on the wrong track. Any help on how to make a vectorized wmf or emf would be helpful. Thanks.