Function Reference


_GDIPlus_BitmapCreateFromHBITMAP

Create a Bitmap object from a bitmap handle

#include <GDIPlus.au3>
_GDIPlus_BitmapCreateFromHBITMAP ( $hBitmap [, $hPal = 0] )

Parameters

$hBitmap Handle to a HBITMAP
$hPal [optional] Handle to a HPALETTE

Return Value

Success: a handle to a Bitmap object.
Failure: 0 and sets the @error flag to non-zero, @extended may contain GPSTATUS error code ($GPIP_ERR* see GPIPlusConstants.au3).

Remarks

When you are done with the Bitmap object, call _GDIPlus_BitmapDispose() to release the resources.

Related

_GDIPlus_BitmapDispose

See Also

Search GdipCreateBitmapFromHBITMAP in MSDN Library.

Example

#include <GDIPlus.au3>
#include <GUIConstantsEx.au3>
#include <ScreenCapture.au3>
#include <WinAPIHObj.au3>

Example()

Func Example()
        Local $hGUI, $hBMP, $hBitmap, $hGraphic

        ; Capture upper left corner of screen
        $hBMP = _ScreenCapture_Capture("", 0, 0, 400, 300)

        ; Create GUI
        $hGUI = GUICreate("GDI+", 400, 300)
        GUISetState(@SW_SHOW)

        ; Initialize GDI+ library
        _GDIPlus_Startup()

        ; Draw bitmap to GUI
        $hBitmap = _GDIPlus_BitmapCreateFromHBITMAP($hBMP)
        $hGraphic = _GDIPlus_GraphicsCreateFromHWND($hGUI)
        _GDIPlus_GraphicsDrawImage($hGraphic, $hBitmap, 0, 0)

        ; Clean up resources
        _GDIPlus_GraphicsDispose($hGraphic)
        _GDIPlus_BitmapDispose($hBitmap)
        _WinAPI_DeleteObject($hBMP)

        ; Shut down GDI+ library
        _GDIPlus_Shutdown()

        ; Loop until the user exits.
        Do
        Until GUIGetMsg() = $GUI_EVENT_CLOSE
EndFunc   ;==>Example