Graphics.ResetTransform メソッド

定義

対象の Graphics のワールド変換行列を単位行列にリセットします。

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

次のコード例は、Windows フォームで使用するように設計されており、イベント ハンドラーのPaintパラメーターである が必要PaintEventArgseです。 コードは、次のアクションを実行します。

  • Windows フォームのワールド変換をベクター (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 マトリックスにリセットすると、ワールド変換によって変換されたアイテムのジオメトリが変更されないことを意味します。

適用対象