# HOW TO：手動管理已緩衝的圖形How to: Manually Manage Buffered Graphics

### 若要取得預設 BufferedGraphicsContext 的參考To obtain a reference to the default BufferedGraphicsContext

• 設定Current屬性，如下列程式碼範例所示。Set the Current property, as shown in the following code example.

BufferedGraphicsContext myContext;
myContext = BufferedGraphicsManager.Current;

Dim myContext As BufferedGraphicsContext
myContext = BufferedGraphicsManager.Current



注意

您不需要呼叫Dispose方法BufferedGraphicsContext參考，您會收到BufferedGraphicsManager類別。You do not need to call the Dispose method on the BufferedGraphicsContext reference that you receive from the BufferedGraphicsManager class. BufferedGraphicsManager會處理所有的記憶體配置和預設值的分佈BufferedGraphicsContext執行個體。The BufferedGraphicsManager handles all of the memory allocation and distribution for default BufferedGraphicsContext instances.

大量繪圖應用程式，例如動畫，您有時可以改善效能使用專用BufferedGraphicsContext而非BufferedGraphicsContext所提供BufferedGraphicsManagerFor graphically intensive applications such as animation, you can sometimes improve performance by using a dedicated BufferedGraphicsContext instead of the BufferedGraphicsContext provided by the BufferedGraphicsManager. 這可讓您建立和個別管理圖形緩衝區，而不會產生管理所有其他已緩衝的圖形與您的應用程式相關聯，但應用程式所耗用的記憶體將會更高的效能負擔。This enables you to create and manage graphics buffers individually, without incurring the performance overhead of managing all the other buffered graphics associated with your application, though the memory consumed by the application will be greater.

### 若要建立專用的 BufferedGraphicsContextTo create a dedicated BufferedGraphicsContext

• 宣告和建立的新執行個體BufferedGraphicsContext類別，如下列程式碼範例所示。Declare and create a new instance of the BufferedGraphicsContext class, as shown in the following code example.

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()