System.Drawing.Graphics.FromHdc Method

Creates a new System.Drawing.Graphics from the specified handle to a device context.

Syntax

[System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Advanced)]
public static Graphics FromHdc (IntPtr hdc)

Parameters

hdc
Handle to a device context.

Returns

This method returns a new System.Drawing.Graphics for the specified device context.

Remarks

You should always call the Graphics.Dispose method to release the System.Drawing.Graphics and related resources created by the Graphics.FromHdc(IntPtr) method.

Even if the display device has an associated ICM color profile, ndptecgdiplus will not use that profile by default. To enable ICM for a System.Drawing.Graphics, construct the System.Drawing.Graphics from an HDC after you pass the HDC (and ICM_ON) to the SetICMMode function. Then any drawing done by the System.Drawing.Graphics will be adjusted according to the ICM profile associated with the display device. Enabling ICM will result in slower performance.

The state of the device context (mapping mode, logical unit, and the like) at the time you call Graphics.FromHdc(IntPtr) can affect rendering done by the System.Drawing.Graphics.

Requirements

Namespace: System.Drawing
Assembly: System.Drawing (in System.Drawing.dll)
Assembly Versions: 1.0.5000.0, 2.0.0.0