W
weiruic
I am trying to create a metafile (.emf) on the harddisk, write graphics
from a graphics object to it, and then save it. I can do this
successfully except I cannot set the horizontal and vertical resolution
as those properties of my metafile object are read only and are in fact
null until the graphics object is disposed of and the file is saved.
When I examine the saved file's properties in Windows Explorer, it has
81 dpi horizontal and vertical resolution, but I did not set these. Any
suggestions? In my case, I want to set the dpi to 96 horizontal and
vertical. Thanks...
(Here is my code
Graphics g = Graphics.FromImage(new Bitmap(1, 1));
IntPtr hdc = g.GetHdc();
Metafile mf = new Metafile(@"c:\file.emf", hdc);
g.ReleaseHdc(hdc);
g.Dispose();
g = Graphics.FromImage(mf);
//init pens
//draw stuff
g.Dispose();
from a graphics object to it, and then save it. I can do this
successfully except I cannot set the horizontal and vertical resolution
as those properties of my metafile object are read only and are in fact
null until the graphics object is disposed of and the file is saved.
When I examine the saved file's properties in Windows Explorer, it has
81 dpi horizontal and vertical resolution, but I did not set these. Any
suggestions? In my case, I want to set the dpi to 96 horizontal and
vertical. Thanks...
(Here is my code

Graphics g = Graphics.FromImage(new Bitmap(1, 1));
IntPtr hdc = g.GetHdc();
Metafile mf = new Metafile(@"c:\file.emf", hdc);
g.ReleaseHdc(hdc);
g.Dispose();
g = Graphics.FromImage(mf);
//init pens
//draw stuff
g.Dispose();