Image.FromHbitmap Method

Definition

Creates a Bitmap from a Windows handle.

Overloads

FromHbitmap(IntPtr)

Creates a Bitmap from a handle to a GDI bitmap.

FromHbitmap(IntPtr, IntPtr)

Creates a Bitmap from a handle to a GDI bitmap and a handle to a GDI palette.

FromHbitmap(IntPtr)

Creates a Bitmap from a handle to a GDI bitmap.

public:
 static System::Drawing::Bitmap ^ FromHbitmap(IntPtr hbitmap);
public static System.Drawing.Bitmap FromHbitmap (IntPtr hbitmap);
static member FromHbitmap : nativeint -> System.Drawing.Bitmap
Public Shared Function FromHbitmap (hbitmap As IntPtr) As Bitmap

Parameters

hbitmap
IntPtr

nativeint

The GDI bitmap handle from which to create the Bitmap.

Returns

The Bitmap this method creates.

Remarks

The FromHbitmap method makes a copy of the GDI bitmap; so you can release the incoming GDI bitmap using the GDI DeleteObject method immediately after creating the new Image.

Applies to

FromHbitmap(IntPtr, IntPtr)

Creates a Bitmap from a handle to a GDI bitmap and a handle to a GDI palette.

public:
 static System::Drawing::Bitmap ^ FromHbitmap(IntPtr hbitmap, IntPtr hpalette);
public static System.Drawing.Bitmap FromHbitmap (IntPtr hbitmap, IntPtr hpalette);
static member FromHbitmap : nativeint * nativeint -> System.Drawing.Bitmap
Public Shared Function FromHbitmap (hbitmap As IntPtr, hpalette As IntPtr) As Bitmap

Parameters

hbitmap
IntPtr

nativeint

The GDI bitmap handle from which to create the Bitmap.

hpalette
IntPtr

nativeint

A handle to a GDI palette used to define the bitmap colors if the bitmap specified in the hbitmap parameter is not a device-independent bitmap (DIB).

Returns

The Bitmap this method creates.

Remarks

The FromHbitmap method makes a copy of the GDI bitmap; so you can release the incoming GDI bitmap using the GDI DeleteObject method immediately after creating the new Image.

Applies to