# Function Reference

# _GDIPlus_BitmapCreateHBITMAPFromBitmap

Create a handle to a bitmap from a bitmap object

#include <GDIPlus.au3>
_GDIPlus_BitmapCreateHBITMAPFromBitmap ( $hBitmap [, $iARGB = 0xFF000000] )

## Parameters

$hBitmap | Handle to a bitmap object
$iARGB | [optional] Color object that specifies the background color

## Return Value

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

## Remarks

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

## Related

_WinAPI_DeleteObject

## See Also

Search GdipCreateHBITMAPFromBitmap in MSDN Library.

## Example

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

    Example()

    Func Example()
        Local $hBMP, $hImage, $iX, $iY, $hClone

        ; Initialize GDI+ library
        _GDIPlus_Startup()

        ; Capture 32 bit bitmap
        $hBMP = _ScreenCapture_Capture("")
        $hImage = _GDIPlus_BitmapCreateFromHBITMAP($hBMP)

        ; Create 24 bit bitmap clone
        $iX = _GDIPlus_ImageGetWidth($hImage)
        $iY = _GDIPlus_ImageGetHeight($hImage)
        $hClone = _GDIPlus_BitmapCloneArea($hImage, 0, 0, $iX, $iY, $GDIP_PXF24RGB)

        ; Save bitmap to file
        _GDIPlus_ImageSaveToFile($hClone, @TempDir & "\GDIPlus_Image.bmp")

        ; Clean up resources
        _GDIPlus_BitmapDispose($hClone)
        _GDIPlus_BitmapDispose($hImage)
        _WinAPI_DeleteObject($hBMP)

        ; Load image
        $hImage = _GDIPlus_ImageLoadFromFile(@TempDir & "\GDIPlus_Image.bmp")
        $hBMP = _GDIPlus_BitmapCreateHBITMAPFromBitmap($hImage)

        ; Save bitmap to file
        _ScreenCapture_SaveImage(@TempDir & "\Image.bmp", $hBMP, True) ; True -> $hBMP destroyed

        ; Clean up resource
        _GDIPlus_ImageDispose($hImage)

        ; Shut down GDI+ library
        _GDIPlus_Shutdown()
    EndFunc   ;==>Example