2010-06-18 79 views
0

当我绘画时下列保留字体大小:缩放绘图

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

e.Graphics.Transform = m 

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

现在,文本也成了规模。是否有可能避免它?

回答

1

为了只改变一点coordonates,而不是使用:

e.Graphics.Transform = m 

这一个:

m.TransformPoints(points) 
1
  • 尝试绘制时
+0

好......也许,但我有'zoomX'和'zoomY'但字体只有'Size' ... – serhio 2010-06-18 15:35:41

1

与图像矩阵的工作,不区分是否文本或形状调整字体大小/ _zoom。 如果文本位置是不相关的,你可以重置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); 
+1

我要用'e.Graphics.ResetTransform()'然后'p = New PointF(_ZoomX * oldp.X,oldp.Y * _ZoomY)' – serhio 2010-06-18 15:54:05

1

你必须撤消图形变换,并与身份绘制文本(或至少非缩放)转换。

+0

文本位置很重要。 .. – serhio 2010-06-18 15:46:52

+0

是的,你必须自己做数学转换文本插入位置到缩放矩阵。但是你不能绘制缩放矩阵激活的文本。 – 2010-06-18 18:49:11