Graphics.ScaleTransform 方法  
定义
重要
一些信息与预发行产品相关,相应产品在发行之前可能会进行重大修改。 对于此处提供的信息,Microsoft 不作任何明示或暗示的担保。
通过将指定的缩放操作追加到对象的转换矩阵之前,将此 Graphics 的转换矩阵应用于该矩阵。
重载
| ScaleTransform(Single, Single) | 通过将指定的缩放操作追加到对象的转换矩阵之前,将此 Graphics 的转换矩阵应用于该矩阵。 | 
| ScaleTransform(Single, Single, MatrixOrder) | 
ScaleTransform(Single, Single)
- Source:
- Graphics.cs
- Source:
- Graphics.cs
- 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 -> unitPublic Sub ScaleTransform (sx As Single, sy As Single)参数
- sx
- Single
X 方向的刻度因子。
- sy
- Single
y 方向的刻度因子。
示例
下面的代码示例设计用于 Windows 窗体,它需要 PaintEventArgse,这是 Paint 事件处理程序的参数。 该代码执行以下操作:
- 将 Windows 窗体的世界转换矩阵旋转 30 度。 
- 通过追加缩放转换,该矩阵按 x 方向的 3 乘以 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,sy,1)。 此方法通过缩放矩阵追加 Graphics 的转换矩阵。
适用于
ScaleTransform(Single, Single, MatrixOrder)
- Source:
- Graphics.cs
- Source:
- Graphics.cs
- Source:
- Graphics.cs
- Source:
- Graphics.cs
- Source:
- Graphics.cs
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 -> unitPublic 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 度。 
- 通过将缩放转换与 Append 成员追加缩放转换,将该矩阵按 x 方向的 3 因子和 1 的 1 比例进行缩放。 
- 使用蓝色笔绘制旋转的缩放矩形。 
结果是一个平行四边形。
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,sy,1)。 此方法根据 order 参数通过缩放矩阵追加或追加 Graphics 的转换矩阵。