BufferedGraphicsContext 類別


提供建立圖形緩衝區的方法,該緩衝區可用於雙重緩衝 (Double Buffering)。Provides methods for creating graphics buffers that can be used for double buffering.

public ref class BufferedGraphicsContext sealed : IDisposable
public sealed class BufferedGraphicsContext : IDisposable
type BufferedGraphicsContext = class
    interface IDisposable
Public NotInheritable Class BufferedGraphicsContext
Implements IDisposable


下列程式碼範例示範如何取得目前應用BufferedGraphicsContext程式域的。The following code example demonstrates how to acquire the BufferedGraphicsContext for the current application domain. 此程式碼是針對BufferedGraphics類別提供的較大範例的一部分。This code is part of a larger example provided for the BufferedGraphics class.

// Retrieves the BufferedGraphicsContext for the 
// current application domain.
BufferedGraphicsContext^ appDomainGraphicsContext =
// Retrieves the BufferedGraphicsContext for the 
// current application domain.
BufferedGraphicsContext appDomainGraphicsContext = 
' Retrieves the BufferedGraphicsContext for the 
' current application domain.
Dim appDomainGraphicsContext As BufferedGraphicsContext = BufferedGraphicsManager.Current


BufferedGraphicsContext類別可讓您針對圖形執行自訂雙重緩衝。The BufferedGraphicsContext class allows you to implement custom double buffering for your graphics. 使用雙重緩衝的圖形可以減少或消除因重新繪製顯示介面而造成的閃爍。Graphics that use double buffering can reduce or eliminate flicker that is caused by redrawing a display surface.


使用雙重緩衝最簡單的方式, 就是OptimizedDoubleBuffer SetStyle使用方法, 在控制項上設定控制項樣式旗標。The simplest way to use double buffering is to set the OptimizedDoubleBuffer control style flag on a control using the SetStyle method. 設定控制項OptimizedDoubleBuffer的控制項樣式旗標會透過預設圖形緩衝區重新導向控制項的所有繪製, 而不需要任何額外的程式碼。Setting the OptimizedDoubleBuffer control styles flag for a control redirects all painting for the control through a default graphics buffer, without requiring any additional code. 預設會將此旗true標設為。This flag is set to true by default.

BufferedGraphicsContext類別提供建立和設定圖形緩衝區的方法。The BufferedGraphicsContext class provides methods for creating and configuring a graphics buffer. Allocate方法會BufferedGraphics建立, 這是圖形緩衝區的包裝函式, 也提供可用來寫入緩衝區的方法, 並將其內容轉譯到輸出裝置。The Allocate method creates a BufferedGraphics, which is a wrapper for a graphics buffer that also provides methods you can use to write to the buffer and render its contents to an output device.

您可以從靜態BufferedGraphicsContext BufferedGraphicsManager.Current屬性取得目前應用程式域的。You can retrieve the BufferedGraphicsContext for the current application domain from the static BufferedGraphicsManager.Current property. 對於以圖形化密集型的應用程式 (例如動畫), BufferedGraphicsContext您可以使用此函式來建立專用BufferedGraphicsManager.Current的, 但對於大部分的應用程式而言, 屬性就已足夠。For graphically intensive applications such as animation, you can create a dedicated BufferedGraphicsContext using the constructor, but for most applications the BufferedGraphicsManager.Current property will be sufficient.

如需有關繪製緩衝的圖形和自訂緩衝處理的詳細資訊, 請[參閱雙重緩衝的圖形和如何:手動管理已緩衝](~/docs/framework/winforms/advanced/how-to-manually-manage-buffered-graphics.md)處理的圖形。For more information on drawing buffered graphics and custom buffering implementations, see Double Buffered Graphics and How to: Manually Manage Buffered Graphics.



初始化 BufferedGraphicsContext 類別的新執行個體。Initializes a new instance of the BufferedGraphicsContext class.



取得或設定要使用之緩衝區的大小上限。Gets or sets the maximum size of the buffer to use.


Allocate(Graphics, Rectangle)

使用指定 Graphics 的像素格式,建立指定大小的圖形緩衝區。Creates a graphics buffer of the specified size using the pixel format of the specified Graphics.

Allocate(IntPtr, Rectangle)

使用指定 Graphics 的像素格式,建立指定大小的圖形緩衝區。Creates a graphics buffer of the specified size using the pixel format of the specified Graphics.


釋放 BufferedGraphicsContext 所使用的所有資源。Releases all resources used by the BufferedGraphicsContext.


判斷指定的物件是否等於目前的物件。Determines whether the specified object is equal to the current object.

(繼承來源 Object)

允許物件在記憶體回收進行回收之前,嘗試釋放資源並執行其他清除作業。Allows an object to try to free resources and perform other cleanup operations before it is reclaimed by garbage collection.


做為預設雜湊函式。Serves as the default hash function.

(繼承來源 Object)

取得目前執行個體的 TypeGets the Type of the current instance.

(繼承來源 Object)

處置目前的圖形緩衝區,如果已配置緩衝區但尚未處置的話。Disposes of the current graphics buffer, if a buffer has been allocated and has not yet been disposed.


建立目前 Object 的淺層複本 (Shallow Copy)。Creates a shallow copy of the current Object.

(繼承來源 Object)

傳回代表目前物件的字串。Returns a string that represents the current object.

(繼承來源 Object)