Breyta

Deila með


BufferedGraphicsContext Class

Definition

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
Inheritance
BufferedGraphicsContext
Implements

Examples

The following code example demonstrates how to acquire the BufferedGraphicsContext for the current application domain. 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

Remarks

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.

Note

In .NET 6 and later versions, the System.Drawing.Common package, which includes this type, is only supported on Windows operating systems. Use of this type in cross-platform apps causes compile-time warnings and run-time exceptions. For more information, see System.Drawing.Common only supported on Windows.

Note

The simplest way to use double buffering is to set the OptimizedDoubleBuffer control style flag on a control using the SetStyle method. 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. This flag is set to true by default.

The BufferedGraphicsContext class provides methods for creating and configuring a graphics buffer. 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.

You can retrieve the BufferedGraphicsContext for the current application domain from the static BufferedGraphicsManager.Current property. 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.

Constructors

BufferedGraphicsContext()

Initializes a new instance of the BufferedGraphicsContext class.

Properties

MaximumBuffer

Gets or sets the maximum size of the buffer to use.

Methods

Allocate(Graphics, Rectangle)

Creates a graphics buffer of the specified size using the pixel format of the specified Graphics.

Allocate(IntPtr, Rectangle)

Creates a graphics buffer of the specified size using the pixel format of the specified Graphics.

Dispose()

Releases all resources used by the BufferedGraphicsContext.

Equals(Object)

Determines whether the specified object is equal to the current object.

(Inherited from 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.

(Inherited from Object)
GetType()

Gets the Type of the current instance.

(Inherited from Object)
Invalidate()

Disposes of the current graphics buffer, if a buffer has been allocated and has not yet been disposed.

MemberwiseClone()

Creates a shallow copy of the current Object.

(Inherited from Object)
ToString()

Returns a string that represents the current object.

(Inherited from Object)

Applies to

See also