Graphics.ScaleTransform 方法

定义

将指定的缩放操作应用于此 Graphics 的转换矩阵,方法是将该对象的转换矩阵左乘该缩放矩阵。

重载

ScaleTransform(Single, Single)

将指定的缩放操作应用于此 Graphics 的转换矩阵,方法是将该对象的转换矩阵左乘该缩放矩阵。

ScaleTransform(Single, Single, MatrixOrder)

以指定顺序将指定的缩放操作应用到此 Graphics 的转换矩阵。

ScaleTransform(Single, Single)

Source:
Graphics.cs
Source:
Graphics.cs
Source:
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 窗体 一起使用,它需要 PaintEventArgse,它是 事件处理程序的Paint一个参数。 此代码执行以下操作:

  • 将 Windows 窗体的世界转换矩阵旋转 30 度。

  • 通过在缩放转换前面添加缩放转换,在 x 方向按 3 因子缩放该矩阵,在 y 方向按 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)

Source:
Graphics.cs
Source:
Graphics.cs
Source:
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 窗体 一起使用,它需要 PaintEventArgse,它是 事件处理程序的Paint一个参数。 此代码执行以下操作:

  • 将 Windows 窗体的世界转换矩阵旋转 30 度。

  • 通过将缩放转换追加到 成员,在 x 方向按 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转换矩阵。

适用于