2010-06-18 86 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