方法: バッファリングされたグラフィックスを手動で管理する
より高度なダブル バッファリング シナリオでは、.NET Framework クラスを使用して独自のダブル バッファリング ロジックを実装できます。 個々のグラフィックス バッファーの割り当てと管理を担当するクラスは、BufferedGraphicsContext クラスです。 すべてのアプリケーションには、そのアプリケーションのすべての既定のダブル バッファリングを管理する独自の既定の BufferedGraphicsContext があります。 このインスタンスへの参照を取得するには、Currentを呼び出します。
既定の BufferedGraphicsContext への参照を取得するには
次のコード例に示すように、Current プロパティを設定します。
BufferedGraphicsContext myContext; myContext = BufferedGraphicsManager.Current;
Dim myContext As BufferedGraphicsContext myContext = BufferedGraphicsManager.Current
手記
BufferedGraphicsManager クラスから受け取った BufferedGraphicsContext 参照で、
Dispose
メソッドを呼び出す必要はありません。 BufferedGraphicsManager は、既定の BufferedGraphicsContext インスタンスのすべてのメモリ割り当てと分散を処理します。アニメーションなどのグラフィカルに集中的なアプリケーションでは、BufferedGraphicsManagerによって提供される BufferedGraphicsContext ではなく、専用の BufferedGraphicsContext を使用してパフォーマンスを向上させることができます。 これにより、アプリケーションに関連付けられている他のすべてのバッファーグラフィックスを管理するパフォーマンス オーバーヘッドを発生させることなく、グラフィックス バッファーを個別に作成および管理できます。ただし、アプリケーションで消費されるメモリの方が大きくなります。
専用の BufferedGraphicsContext を作成するには
次のコード例に示すように、BufferedGraphicsContext クラスの新しいインスタンスを宣言して作成します。
BufferedGraphicsContext myContext; myContext = new BufferedGraphicsContext(); // Insert code to create graphics here. // On a non-default BufferedGraphicsContext instance, you should always // call Dispose when finished. myContext.Dispose();
Dim myContext As BufferedGraphicsContext myContext = New BufferedGraphicsContext ' Insert code to create graphics here. ' On a nondefault BufferedGraphicsContext instance, you should always ' call Dispose when finished. myContext.Dispose()
関連項目
.NET Desktop feedback