Export (0) Print
Expand All

Bitmap.GetHbitmap Method

Creates a GDI bitmap object from a GDI+ Bitmap object.

Overload List

Creates a GDI bitmap object from this Bitmap object.

[Visual Basic] Overloads Public Function GetHbitmap() As IntPtr
[C#] public IntPtr GetHbitmap();
[C++] public: IntPtr GetHbitmap();
[JScript] public function GetHbitmap() : IntPtr;

Creates a GDI bitmap object from this Bitmap object.

[Visual Basic] Overloads Public Function GetHbitmap(Color) As IntPtr
[C#] public IntPtr GetHbitmap(Color);
[C++] public: IntPtr GetHbitmap(Color);
[JScript] public function GetHbitmap(Color) : IntPtr;

Example

[Visual Basic, C#] Note   This example shows how to use one of the overloaded versions of GetHbitmap. For other examples that might be available, see the individual overload topics.
[Visual Basic] 
Imports System.Runtime.InteropServices
...
Declare Function DeleteObject Lib "gdi32.dll" (ByVal hObject As IntPtr) As Boolean
...
Dim bm As New Bitmap("Picture.jpg")
Dim hBitmap As IntPtr
hBitmap = bm.GetHbitmap(Color.Blue)
' Do something with hBitmap.
DeleteObject(hBitmap)
        
[C#] 
using System.Runtime.InteropServices;
...
[DllImport("gdi32.dll")]
public static extern bool DeleteObject(IntPtr hObject);
...
Bitmap bm = new Bitmap("Picture.jpg");
IntPtr hBitmap = bm.GetHbitmap(Color.Blue);
// Do something with hBitmap.
DeleteObject(hBitmap);
        

[C++, JScript] No example is available for C++ or JScript. To view a Visual Basic or C# example, click the Language Filter button Language Filter in the upper-left corner of the page.

See Also

Bitmap Class | Bitmap Members | System.Drawing Namespace

Show:
© 2014 Microsoft