Graphics.ScaleTransform 方法

定義

透過將指定的縮放作業放置在物件的轉換矩陣之前,將作業套用至此 Graphics 的轉換矩陣。

多載

ScaleTransform(Single, Single)

透過將指定的縮放作業放置在物件的轉換矩陣之前,將作業套用至此 Graphics 的轉換矩陣。

ScaleTransform(Single, Single, MatrixOrder)

依照指定的順序,將指定之縮放作業套用至這個 Graphics 的變換矩陣。

ScaleTransform(Single, Single)

來源:
Graphics.cs
來源:
Graphics.cs
來源:
Graphics.cs

透過將指定的縮放作業放置在物件的轉換矩陣之前,將作業套用至此 Graphics 的轉換矩陣。

public:
 void ScaleTransform(float sx, float sy);
public void ScaleTransform (float sx, float sy);
member this.ScaleTransform : single * single -> unit
Public Sub ScaleTransform (sx As Single, sy As Single)

參數

sx
Single

X 方向的縮放比例。

sy
Single

Y 方向的縮放比例。

範例

下列程式代碼範例是設計來搭配 Windows Forms 使用,而且需要 PaintEventArgse,這是事件處理程序的參數Paint。 此程式碼會執行下列動作:

  • 旋轉 Windows Form 世界轉換矩陣 30 度。

  • 在縮放轉換前面加上縮放轉換,以 x 方向的 3 乘以 3 為矩陣縮放比例,並將 1 的因數調整為 1。

  • 使用藍色畫筆繪製縮放的旋轉矩形。

結果仍是矩形。

public:
   void ScaleTransformFloat( PaintEventArgs^ e )
   {
      // Set world transform of graphics object to rotate.
      e->Graphics->RotateTransform( 30.0F );

      // Then to scale, prepending to world transform.
      e->Graphics->ScaleTransform( 3.0F, 1.0F );

      // Draw scaled, rotated rectangle to screen.
      e->Graphics->DrawRectangle( gcnew Pen( Color::Blue,3.0f ), 50, 0, 100, 40 );
   }
private void ScaleTransformFloat(PaintEventArgs e)
{

    // Set world transform of graphics object to rotate.
    e.Graphics.RotateTransform(30.0F);

    // Then to scale, prepending to world transform.
    e.Graphics.ScaleTransform(3.0F, 1.0F);

    // Draw scaled, rotated rectangle to screen.
    e.Graphics.DrawRectangle(new Pen(Color.Blue, 3), 50, 0, 100, 40);
}
Private Sub ScaleTransformFloat(ByVal e As PaintEventArgs)

    ' Set world transform of graphics object to rotate.
    e.Graphics.RotateTransform(30.0F)

    ' Then to scale, prepending to world transform.
    e.Graphics.ScaleTransform(3.0F, 1.0F)

    ' Draw scaled, rotated rectangle to screen.
    e.Graphics.DrawRectangle(New Pen(Color.Blue, 3), 50, 0, 100, 40)
End Sub

備註

縮放作業包含將轉換矩陣乘以對角矩陣,其元素 (sx、、 sy1) 。 這個方法會在縮放矩陣前面加上的 Graphics 轉換矩陣。

適用於

ScaleTransform(Single, Single, MatrixOrder)

來源:
Graphics.cs
來源:
Graphics.cs
來源:
Graphics.cs

依照指定的順序,將指定之縮放作業套用至這個 Graphics 的變換矩陣。

public:
 void ScaleTransform(float sx, float sy, System::Drawing::Drawing2D::MatrixOrder order);
public void ScaleTransform (float sx, float sy, System.Drawing.Drawing2D.MatrixOrder order);
member this.ScaleTransform : single * single * System.Drawing.Drawing2D.MatrixOrder -> unit
Public Sub ScaleTransform (sx As Single, sy As Single, order As MatrixOrder)

參數

sx
Single

X 方向的縮放比例。

sy
Single

Y 方向的縮放比例。

order
MatrixOrder

MatrixOrder 列舉的成員,指定縮放作業是附加到變換矩陣之前或之後。

範例

下列程式代碼範例是設計來搭配 Windows Forms 使用,而且需要 PaintEventArgse,這是事件處理程序的參數Paint。 此程式碼會執行下列動作:

  • 旋轉 Windows Form 世界轉換矩陣 30 度。

  • 藉由將縮放轉換附加至成員,以 x 方向的 3 乘以 3 來調整該矩陣,並以 Y 方向縮放 1 的 Append 因數。

  • 使用藍色畫筆繪製旋轉的縮放矩形。

結果是平行方圖。

public:
   void ScaleTransformFloatMatrixOrder( PaintEventArgs^ e )
   {
      // Set world transform of graphics object to rotate.
      e->Graphics->RotateTransform( 30.0F );

      // Then to scale, appending to world transform.
      e->Graphics->ScaleTransform( 3.0F, 1.0F, MatrixOrder::Append );

      // Draw rotated, scaled rectangle to screen.
      e->Graphics->DrawRectangle( gcnew Pen( Color::Blue,3.0f ), 50, 0, 100, 40 );
   }
private void ScaleTransformFloatMatrixOrder(PaintEventArgs e)
{

    // Set world transform of graphics object to rotate.
    e.Graphics.RotateTransform(30.0F);

    // Then to scale, appending to world transform.
    e.Graphics.ScaleTransform(3.0F, 1.0F, MatrixOrder.Append);

    // Draw rotated, scaled rectangle to screen.
    e.Graphics.DrawRectangle(new Pen(Color.Blue, 3), 50, 0, 100, 40);
}
Private Sub ScaleTransformFloatMatrixOrder(ByVal e As PaintEventArgs)

    ' Set world transform of graphics object to rotate.
    e.Graphics.RotateTransform(30.0F)

    ' Then to scale, appending to world transform.
    e.Graphics.ScaleTransform(3.0F, 1.0F, MatrixOrder.Append)

    ' Draw rotated, scaled rectangle to screen.
    e.Graphics.DrawRectangle(New Pen(Color.Blue, 3), 50, 0, 100, 40)
End Sub

備註

縮放作業包含將轉換矩陣乘以對角矩陣,其元素 (sx、、 sy1) 。 這個方法會根據 order 參數,在縮放矩陣前面加上或附加 的Graphics轉換矩陣。

適用於