Bitmap.GetHbitmap 方法

定義

從 GDI+ Bitmap建立一個 GDI 點陣物件。

多載

名稱 Description
GetHbitmap()

從此 Bitmap建立一個 GDI 位圖物件。

GetHbitmap(Color)

從此 Bitmap建立一個 GDI 位圖物件。

GetHbitmap()

來源:
Bitmap.cs
來源:
Bitmap.cs
來源:
Bitmap.cs
來源:
Bitmap.cs
來源:
Bitmap.cs
來源:
Bitmap.cs
來源:
Bitmap.cs
來源:
Bitmap.cs

從此 Bitmap建立一個 GDI 位圖物件。

public:
 IntPtr GetHbitmap();
public IntPtr GetHbitmap();
member this.GetHbitmap : unit -> nativeint
Public Function GetHbitmap () As IntPtr

傳回

IntPtr

nativeint

這個方法所建立的 GDI 點陣物件的代言人。

例外狀況

位圖的高度或寬度大於 Int16.MaxValue

作業失敗。

範例

以下程式碼範例示範如何使用此 GetHbitmap 方法。

   [System::Runtime::InteropServices::DllImportAttribute("gdi32.dll")]
   static bool DeleteObject( IntPtr hObject );

private:
   void DemonstrateGetHbitmap()
   {
      Bitmap^ bm = gcnew Bitmap( "Picture.jpg" );
      IntPtr hBitmap = bm->GetHbitmap();
      
      // Do something with hBitmap.
      DeleteObject( hBitmap );
   }
[System.Runtime.InteropServices.DllImport("gdi32.dll")]
public static extern bool DeleteObject(IntPtr hObject);

private void DemonstrateGetHbitmap()
{
    Bitmap bm = new Bitmap("Picture.jpg");
    IntPtr hBitmap = bm.GetHbitmap();

    // Do something with hBitmap.
    DeleteObject(hBitmap);
}
<System.Runtime.InteropServices.DllImportAttribute("gdi32.dll")> _
    Private Shared Function DeleteObject (ByVal hObject As IntPtr) As Boolean
    End Function
   


    Private Sub DemonstrateGetHbitmap()
        Dim bm As New Bitmap("Picture.jpg")
        Dim hBitmap As IntPtr
        hBitmap = bm.GetHbitmap()

        ' Do something with hBitmap.
        DeleteObject(hBitmap)
    End Sub

備註

你負責呼叫 GDI DeleteObject 方法,釋放 GDI 點陣物件所使用的記憶體。 欲了解更多關於 GDI 位圖的資訊,請參閱 Windows GDI 文件中的 位圖

適用於

GetHbitmap(Color)

來源:
Bitmap.cs
來源:
Bitmap.cs
來源:
Bitmap.cs
來源:
Bitmap.cs
來源:
Bitmap.cs
來源:
Bitmap.cs
來源:
Bitmap.cs
來源:
Bitmap.cs

從此 Bitmap建立一個 GDI 位圖物件。

public:
 IntPtr GetHbitmap(System::Drawing::Color background);
public IntPtr GetHbitmap(System.Drawing.Color background);
member this.GetHbitmap : System.Drawing.Color -> nativeint
Public Function GetHbitmap (background As Color) As IntPtr

參數

background
Color

一個 Color 指定背景顏色的結構。 若位圖完全不透明,此參數會被忽略。

傳回

IntPtr

nativeint

這個方法所建立的 GDI 點陣物件的代言人。

例外狀況

位圖的高度或寬度大於 Int16.MaxValue

作業失敗。

範例

以下程式碼範例示範如何使用 GetHbitmap.method 。

void DemonstrateGetHbitmapWithColor()
{
   Bitmap^ bm = gcnew Bitmap( "Picture.jpg" );
   IntPtr hBitmap = bm->GetHbitmap( Color::Blue );
   
   // Do something with hBitmap.
   DeleteObject( hBitmap );
}

private void DemonstrateGetHbitmapWithColor()
{
    Bitmap bm = new Bitmap("Picture.jpg");
    IntPtr hBitmap = bm.GetHbitmap(Color.Blue);

    // Do something with hBitmap.
    DeleteObject(hBitmap);
}

Private Sub DemonstrateGetHbitmapWithColor()
    Dim bm As New Bitmap("Picture.jpg")
    Dim hBitmap As IntPtr
    hBitmap = bm.GetHbitmap(Color.Blue)

    ' Do something with hBitmap.
    DeleteObject(hBitmap)
End Sub

備註

你負責呼叫 GDI DeleteObject 方法,釋放 GDI 點陣物件所使用的記憶體。 欲了解更多關於 GDI 位圖的資訊,請參閱 Windows GDI 文件中的 位圖

適用於