BufferedGraphicsContext 类

定义

提供创建图形缓冲区的方法,该缓冲区可用于双缓冲。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
实现

示例

下面的代码示例演示如何获取当前应用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 =
   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类允许您为图形实现自定义双缓冲。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. 如果为控件设置控件样式标志,则会通过默认图形缓冲区重定向控件的所有绘制,无需任何其他代码。OptimizedDoubleBufferSetting 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. 方法创建一个BufferedGraphics, 它是图形缓冲区的包装, 它还提供可用于写入缓冲区并将其内容呈现给输出设备的方法。 AllocateThe 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.

可以从静态BufferedGraphicsManager.Current属性BufferedGraphicsContext中检索当前应用程序域的。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.

有关绘制缓冲图形和自定义缓冲实现的详细信息, 请参阅双缓冲图形如何:手动管理缓冲图形For more information on drawing buffered graphics and custom buffering implementations, see Double Buffered Graphics and How to: Manually Manage Buffered Graphics.

构造函数

BufferedGraphicsContext()

初始化 BufferedGraphicsContext 类的新实例。Initializes a new instance of the BufferedGraphicsContext class.

属性

MaximumBuffer

获取或设置要使用的缓冲区的最大大小。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.

Dispose()

释放由 BufferedGraphicsContext 使用的所有资源。Releases all resources used by the BufferedGraphicsContext.

Equals(Object)

确定指定的对象是否等于当前对象。Determines whether the specified object is equal to the current object.

(继承自 Object)
Finalize()

在垃圾回收将某一对象回收前允许该对象尝试释放资源并执行其他清理操作。Allows an object to try to free resources and perform other cleanup operations before it is reclaimed by garbage collection.

GetHashCode()

用作默认哈希函数。Serves as the default hash function.

(继承自 Object)
GetType()

获取当前实例的 TypeGets the Type of the current instance.

(继承自 Object)
Invalidate()

如果某个缓冲区已被分配但尚未释放,则释放当前的图形缓冲区。Disposes of the current graphics buffer, if a buffer has been allocated and has not yet been disposed.

MemberwiseClone()

创建当前 Object 的浅表副本。Creates a shallow copy of the current Object.

(继承自 Object)
ToString()

返回一个表示当前对象的 string。Returns a string that represents the current object.

(继承自 Object)

适用于

另请参阅