Επεξεργασία

Κοινή χρήση μέσω


BufferedGraphicsContext.Allocate Method

Definition

Creates a graphics buffer.

Overloads

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.

Allocate(Graphics, Rectangle)

Source:
BufferedGraphicsContext.cs
Source:
BufferedGraphicsContext.cs
Source:
BufferedGraphicsContext.cs
Source:
BufferedGraphicsContext.cs
Source:
BufferedGraphicsContext.cs

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

public:
 System::Drawing::BufferedGraphics ^ Allocate(System::Drawing::Graphics ^ targetGraphics, System::Drawing::Rectangle targetRectangle);
public System.Drawing.BufferedGraphics Allocate (System.Drawing.Graphics targetGraphics, System.Drawing.Rectangle targetRectangle);
member this.Allocate : System.Drawing.Graphics * System.Drawing.Rectangle -> System.Drawing.BufferedGraphics
Public Function Allocate (targetGraphics As Graphics, targetRectangle As Rectangle) As BufferedGraphics

Parameters

targetGraphics
Graphics

The Graphics to match the pixel format for the new buffer to.

targetRectangle
Rectangle

A Rectangle indicating the size of the buffer to create.

Returns

A BufferedGraphics that can be used to draw to a buffer of the specified dimensions.

Examples

The following code example demonstrates creating a graphics buffer using the Allocate method. This code is part of a larger example provided for the BufferedGraphics class.

// Allocates a graphics buffer using the pixel format 
// of the specified Graphics object.
grafx = appDomainBufferedGraphicsContext->Allocate( this->CreateGraphics(),
   Rectangle( 0, 0, 400, 400 ) );
// Allocates a graphics buffer using the pixel format
// of the specified Graphics object.
grafx = appDomainBufferedGraphicsContext.Allocate(this.CreateGraphics(),
     new Rectangle( 0, 0, 400, 400 ));
' Allocates a graphics buffer using the pixel format 
' of the specified Graphics object.
grafx = appDomainBufferedGraphicsContext.Allocate(Me.CreateGraphics(), New Rectangle(0, 0, 400, 400))

Remarks

When you call the Allocate method with a rectangle whose size exceeds the value of the MaximumBuffer property, a temporary BufferedGraphicsContext is created to allocate the buffer and provide a temporary context for the buffer. The new BufferedGraphicsContext is distinct from the BufferedGraphicsContext for the application domain and it is disposed automatically when the BufferedGraphics returned by the Allocate method is disposed.

See also

Applies to

Allocate(IntPtr, Rectangle)

Source:
BufferedGraphicsContext.cs
Source:
BufferedGraphicsContext.cs
Source:
BufferedGraphicsContext.cs
Source:
BufferedGraphicsContext.cs
Source:
BufferedGraphicsContext.cs

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

public:
 System::Drawing::BufferedGraphics ^ Allocate(IntPtr targetDC, System::Drawing::Rectangle targetRectangle);
public System.Drawing.BufferedGraphics Allocate (IntPtr targetDC, System.Drawing.Rectangle targetRectangle);
member this.Allocate : nativeint * System.Drawing.Rectangle -> System.Drawing.BufferedGraphics
Public Function Allocate (targetDC As IntPtr, targetRectangle As Rectangle) As BufferedGraphics

Parameters

targetDC
IntPtr

nativeint

An IntPtr to a device context to match the pixel format of the new buffer to.

targetRectangle
Rectangle

A Rectangle indicating the size of the buffer to create.

Returns

A BufferedGraphics that can be used to draw to a buffer of the specified dimensions.

Examples

The following code example demonstrates creating a graphics buffer using the Allocate method. This code is part of a larger example provided for the BufferedGraphics class.

// Allocates a graphics buffer using the pixel format 
// of the specified handle to a device context.
grafx = appDomainBufferedGraphicsContext->Allocate( this->Handle,
   Rectangle( 0, 0, 400, 400 ) );
// Allocates a graphics buffer using the pixel format
// of the specified handle to a device context.
grafx = appDomainBufferedGraphicsContext.Allocate(this.Handle,
     new Rectangle( 0, 0, 400, 400 ));
' Allocates a graphics buffer using the pixel format 
' of the specified handle to device context.
grafx = appDomainBufferedGraphicsContext.Allocate(Me.Handle, New Rectangle(0, 0, 400, 400))

Remarks

When you call the Allocate method with a rectangle whose size exceeds the value of the MaximumBuffer property, a temporary BufferedGraphicsContext is created to allocate the buffer and provide a temporary context for the buffer. The new BufferedGraphicsContext is distinct from the BufferedGraphicsContext for the application domain and it is disposed automatically when the BufferedGraphics returned by the Allocate method is disposed.

See also

Applies to