BufferedGraphicsContext::Allocate Method (IntPtr, Rectangle)
Creates a graphics buffer of the specified size using the pixel format of the specified Graphics.
Assembly: System.Drawing (in System.Drawing.dll)
public:
[SecurityPermissionAttribute(SecurityAction::LinkDemand, Flags = SecurityPermissionFlag::UnmanagedCode)]
BufferedGraphics^ Allocate(
IntPtr targetDC,
Rectangle targetRectangle
)
Parameters
- targetDC
-
Type:
System::IntPtr
An IntPtr to a device context to match the pixel format of the new buffer to.
- targetRectangle
-
Type:
System.Drawing::Rectangle
A Rectangle indicating the size of the buffer to create.
Return Value
Type: System.Drawing::BufferedGraphics^A BufferedGraphics that can be used to draw to a buffer of the specified dimensions.
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.
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.
for access to unmanaged code. Related enumeration: UnmanagedCode
Available since 2.0