缩放绘图时保留字体大小

时间:2010-06-18 15:20:01

标签: .net gdi+

我在绘图时执行以下操作:

Matrix m = new Matrix()
m.Scale(_zoomX, _zoomY)

e.Graphics.Transform = m

e.Graphics.DrawLine(...) ' line representation '
e.Graphics.DrawString(...) ' line text '

现在,文本也缩放了。有可能避免它吗?

4 个答案:

答案 0 :(得分:1)

  • 尝试在绘制时将字体调整为大小/ _zoom

答案 1 :(得分:1)

矩阵使用图像,不区分文本或形状。 如果文本位置不相关,您可以重置e.Graphics.Transform

 Matrix oldMAtrix = e.Graphics.Transform;
 e.Graphics.Transform = m;
 e.Graphics.DrawEllipse(new Pen(Color.Black), 20, 20, 20, 20);
 e.Graphics.Transform = oldMAtrix;
 e.Graphics.DrawString("text", this.Font, SystemBrushes.ControlText, 10, 10);

答案 2 :(得分:1)

您必须撤消图形转换并使用Identity(或至少非缩放)转换绘制文本。

答案 3 :(得分:1)

要仅更改点坐标,请使用而不是:

e.Graphics.Transform = m

这一个:

m.TransformPoints(points)
相关问题