BufferedGraphicsContext 類別

定義

提供建立圖形緩衝區的方法,該緩衝區可用於雙重緩衝 (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
實作

範例

下列程式代碼範例示範如何取得 BufferedGraphicsContext 目前應用程式域的 。 此程式代碼是類別所提供較大範例的 BufferedGraphics 一部分。

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

備註

類別 BufferedGraphicsContext 可讓您實作圖形的自定義雙精度緩衝。 使用雙緩衝的圖形可以減少或消除重繪顯示介面所造成的閃爍。

注意

在 .NET 6 和更新版本中,只有 Windows 作業系統才支援包含此類型的 System.Drawing.Common 套件。 在跨平臺應用程式中使用此類型會導致編譯時間警告和運行時間例外狀況。 如需詳細資訊,請參閱 僅限 Windows 上支援的 System.Drawing.Common

注意

使用雙緩衝的最簡單方式是使用 SetStyle 方法在控件上設定OptimizedDoubleBuffer控件樣式旗標。 設定控件的控件樣式旗標會 OptimizedDoubleBuffer 透過預設圖形緩衝區重新導向控件的所有繪製,而不需要任何其他程序代碼。 此旗標預設會設定為 true

類別 BufferedGraphicsContext 提供建立和設定圖形緩衝區的方法。 方法 Allocate 會建立 , BufferedGraphics這是圖形緩衝區的包裝函式,也提供可用來寫入緩衝區的方法,並將其內容轉譯至輸出裝置。

您可以從靜態BufferedGraphicsManager.Current屬性擷取BufferedGraphicsContext應用程式域的 。 對於圖形密集的應用程式,例如動畫,您可以使用建構函式建立專用 BufferedGraphicsContext 的應用程式,但對於大部分的應用程式而言 BufferedGraphicsManager.Current ,屬性就已足夠。

如需繪圖緩衝圖形和自定義緩衝實作的詳細資訊,請參閱 雙緩衝圖形如何:手動管理緩衝圖形

建構函式

BufferedGraphicsContext()

初始化 BufferedGraphicsContext 類別的新執行個體。

屬性

MaximumBuffer

取得或設定要使用之緩衝區的大小上限。

方法

Allocate(Graphics, Rectangle)

使用指定 Graphics 的像素格式,建立指定大小的圖形緩衝區。

Allocate(IntPtr, Rectangle)

使用指定 Graphics 的像素格式,建立指定大小的圖形緩衝區。

Dispose()

釋放 BufferedGraphicsContext 所使用的所有資源。

Equals(Object)

判斷指定的物件是否等於目前的物件。

(繼承來源 Object)
Finalize()

允許物件在記憶體回收進行回收之前,嘗試釋放資源並執行其他清除作業。

GetHashCode()

做為預設雜湊函式。

(繼承來源 Object)
GetType()

取得目前執行個體的 Type

(繼承來源 Object)
Invalidate()

處置目前的圖形緩衝區,如果已配置緩衝區但尚未處置的話。

MemberwiseClone()

建立目前 Object 的淺層複製。

(繼承來源 Object)
ToString()

傳回代表目前物件的字串。

(繼承來源 Object)

適用於

另請參閱