# Function Reference

# _GDIPlus_BitmapCloneArea

Create a clone of a Bitmap object from the coordinates and format specified

#include <GDIPlus.au3>
_GDIPlus_BitmapCloneArea ( $hBitmap, $nLeft, $nTop, $nWidth, $nHeight [, $iFormat = $GDIP_PXF24RGB] )

## Parameters

$hBitmap | Handle to a Bitmap object
$nLeft | X coordinate of upper left corner of the rectangle to copy
$nTop | Y coordinate of upper left corner of the rectangle to copy
$nWidth | The width of the rectangle that specifies the portion of this bitmap to copy
$nHeight | The height of the rectangle that specifies the portion of this bitmap to copy
$iFormat | [optional] Pixel format for the new bitmap: $GDIP_PXF01INDEXED = 1 bit per pixel, indexed $GDIP_PXF04INDEXED = 4 bits per pixel, indexed $GDIP_PXF08INDEXED = 8 bits per pixel, indexed $GDIP_PXF16GRAYSCALE = 16 bits per pixel, grayscale $GDIP_PXF16RGB555 = 16 bits per pixel; 5 bits for each RGB component $GDIP_PXF16RGB565 = 16 bits per pixel; 5 bits for red, 6 bits for green and 5 bits blue $GDIP_PXF16ARGB1555 = 16 bits per pixel; 1 bit for alpha and 5 bits for each RGB component $GDIP_PXF24RGB = 24 bits per pixel; 8 bits for each RGB component (Default) $GDIP_PXF32RGB = 32 bits per pixel; 8 bits for each RGB component. No alpha component. $GDIP_PXF32ARGB = 32 bits per pixel; 8 bits for each RGB and alpha component $GDIP_PXF32PARGB = 32 bits per pixel; 8 bits for each RGB and alpha component, pre-multiplied $GDIP_PXF48RGB = 48 bits per pixel; 16 bits for each RGB component $GDIP_PXF64ARGB = 64 bits per pixel; 16 bits for each RGB and alpha component $GDIP_PXF64PARGB = 64 bits per pixel; 16 bits for each RGB and alpha component, pre-multiplied

## Return Value

Success: | a handle to a new Bitmap object.
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 _GDIPlus_BitmapDispose() to release the resources

## Related

_GDIPlus_BitmapDispose, _GDIPlus_ImageGetPixelFormat

## See Also

Search GdipCloneBitmapAreaI in MSDN Library.

## Example

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

    Example()

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

        ; Initialize GDI+ library
        _GDIPlus_Startup()

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

        ; 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, @MyDocumentsDir & "\GDIPlus_Image.bmp")

        ; Clean up resources
        _GDIPlus_ImageDispose($hClone)
        _GDIPlus_ImageDispose($hImage)
        _WinAPI_DeleteObject($hBitmap)

        ; Shut down GDI+ library
        _GDIPlus_Shutdown()

        ShellExecute(@MyDocumentsDir & "\GDIPlus_Image.jpg")
    EndFunc   ;==>Example