Graphics.ResetTransform 메서드

정의

Graphics의 전역 변환 매트릭스를 항등 매트릭스로 다시 설정합니다.

public:
 void ResetTransform();
public void ResetTransform ();
member this.ResetTransform : unit -> unit
Public Sub ResetTransform ()

예제

다음 코드 예제는 Windows Forms 사용하도록 설계되었으며 이벤트 처리기의 Paint 매개 변수인 가 필요합니다.PaintEventArgse 코드는 다음 작업을 수행합니다.

  • Windows Form의 월드 변환을 벡터(100, 0)로 변환합니다.

  • 폼의 그래픽 상태를 저장합니다.

  • 폼의 월드 변환을 ID로 다시 설정하고 사각형을 단색 빨간색 브러시로 채웁니다.

  • 변환된 그래픽 상태를 복원하고 사각형을 단색 파란색 브러시로 채웁니다.

그 결과 변환되지 않은 빨간색으로 채워진 사각형과 변환된 파란색으로 채워진 사각형이 생성됩니다.

public:
   void SaveRestore1( PaintEventArgs^ e )
   {
      // Translate transformation matrix.
      e->Graphics->TranslateTransform( 100, 0 );

      // Save translated graphics state.
      GraphicsState^ transState = e->Graphics->Save();

      // Reset transformation matrix to identity and fill rectangle.
      e->Graphics->ResetTransform();
      e->Graphics->FillRectangle( gcnew SolidBrush( Color::Red ), 0, 0, 100, 100 );

      // Restore graphics state to translated state and fill second
      // rectangle.
      e->Graphics->Restore( transState );
      e->Graphics->FillRectangle( gcnew SolidBrush( Color::Blue ), 0, 0, 100, 100 );
   }
private void SaveRestore1(PaintEventArgs e)
{

    // Translate transformation matrix.
    e.Graphics.TranslateTransform(100, 0);

    // Save translated graphics state.
    GraphicsState transState = e.Graphics.Save();

    // Reset transformation matrix to identity and fill rectangle.
    e.Graphics.ResetTransform();
    e.Graphics.FillRectangle(new SolidBrush(Color.Red), 0, 0, 100, 100);

    // Restore graphics state to translated state and fill second

    // rectangle.
    e.Graphics.Restore(transState);
    e.Graphics.FillRectangle(new SolidBrush(Color.Blue), 0, 0, 100, 100);
}
Private Sub SaveRestore1(ByVal e As PaintEventArgs)

    ' Translate transformation matrix.
    e.Graphics.TranslateTransform(100, 0)

    ' Save translated graphics state.
    Dim transState As GraphicsState = e.Graphics.Save()

    ' Reset transformation matrix to identity and fill rectangle.
    e.Graphics.ResetTransform()
    e.Graphics.FillRectangle(New SolidBrush(Color.Red), 0, 0, 100, 100)

    ' Restore graphics state to translated state and fill second

    ' rectangle.
    e.Graphics.Restore(transState)
    e.Graphics.FillRectangle(New SolidBrush(Color.Blue), 0, 0, _
    100, 100)
End Sub

설명

ID 행렬은 크기 조정, 회전 또는 변환이 없는 변환을 나타냅니다. 이 Graphics 월드 변환을 ID 행렬로 다시 설정하면 월드 변환이 변환된 항목의 기하 도형을 변경하지 않습니다.

적용 대상