G
Guest
Can someone at Microsoft please tell me if this is a bug with the metafile support in the framework or am I doing something wrong
I can't get Metafiles to appear in the correct size or position
Example
Assuming a Graphics object "G" with PageUnit set to mm, this C# code wil
draw a circle of radius 20mm, with an "X" on top
G.DrawEllipse(Pen, -20, -20, +40, +40)
G.DrawLine(Pen, -20, -20, +20, +20)
G.DrawLine(Pen, -20, +20, +20, -20)
I want to store this figure in a metafile to play later, so I create
metafile "M" (allowing a frame margin of 10mm)
DC := G.GetHdc()
R := new RectangleF(-30.0F, -30.0F, +60.0F, +60.0F)
M := new Metafile(DC, R, MetafileFrameUnit.Millimeter)
G.ReleaseHdc(DC)
then create a new Graphics object based on this metafile, set its PageUni
to mm, run the preceding 3 draw instructions on this new Graphics object
and discard then discard it
Graphics G2 = Graphics.FromImage(M)
G2.PageUnit = GraphicsUnit.Millimeter
<Execute the same 3 drawing instructions as before on G2
G2.Dispose()
Finally I try playing the metafile, usin
G.DrawImage(M, -30, -30)
This works fine when using UnitPixel everywhere, but with UnitMillimeter (o
UnitPoint) the image appears slightly the wrong size, and very much in th
wrong place. Looking into the metafile header, I find values for DPI an
LogicalDPI. Scaling X and Y by the ratio (DPI / LogicalDPI ) seems almost t
move the image to the correct location; but it is still very slightly out o
position, and still slightly the wrong size (readily seen by drawing bot
"direct" and metafile versions together)
What could explain the inconsistency of the two drawing methods
How can I more accurately "correct" the figure's size and position? (usin
pixels instead of mm is not an option
Craig Hynd
I can't get Metafiles to appear in the correct size or position
Example
Assuming a Graphics object "G" with PageUnit set to mm, this C# code wil
draw a circle of radius 20mm, with an "X" on top
G.DrawEllipse(Pen, -20, -20, +40, +40)
G.DrawLine(Pen, -20, -20, +20, +20)
G.DrawLine(Pen, -20, +20, +20, -20)
I want to store this figure in a metafile to play later, so I create
metafile "M" (allowing a frame margin of 10mm)
DC := G.GetHdc()
R := new RectangleF(-30.0F, -30.0F, +60.0F, +60.0F)
M := new Metafile(DC, R, MetafileFrameUnit.Millimeter)
G.ReleaseHdc(DC)
then create a new Graphics object based on this metafile, set its PageUni
to mm, run the preceding 3 draw instructions on this new Graphics object
and discard then discard it
Graphics G2 = Graphics.FromImage(M)
G2.PageUnit = GraphicsUnit.Millimeter
<Execute the same 3 drawing instructions as before on G2
G2.Dispose()
Finally I try playing the metafile, usin
G.DrawImage(M, -30, -30)
This works fine when using UnitPixel everywhere, but with UnitMillimeter (o
UnitPoint) the image appears slightly the wrong size, and very much in th
wrong place. Looking into the metafile header, I find values for DPI an
LogicalDPI. Scaling X and Y by the ratio (DPI / LogicalDPI ) seems almost t
move the image to the correct location; but it is still very slightly out o
position, and still slightly the wrong size (readily seen by drawing bot
"direct" and metafile versions together)
What could explain the inconsistency of the two drawing methods
How can I more accurately "correct" the figure's size and position? (usin
pixels instead of mm is not an option
Craig Hynd