Function Reference


Get the graphics context of the image

#include <GDIPlus.au3>
_GDIPlus_ImageGetGraphicsContext ( $hImage )


$hImage Handle to an image object

Return Value

Success: a handle to a Graphics object.
Failure: -1 and sets the @error flag to non-zero, @extended may contain GPSTATUS error code ($GPID_ERR*).

See Also

Search GdipGetImageGraphicsContext in MSDN Library.


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


Func Example()
    Local $hBitmap1, $hBitmap2, $hImage1, $hImage2, $hGraphics

    ; Initialize GDI+ library

    ; Capture full screen
    $hBitmap1 = _ScreenCapture_Capture("")
    $hImage1 = _GDIPlus_BitmapCreateFromHBITMAP($hBitmap1)

    ; Capture screen region
    $hBitmap2 = _ScreenCapture_Capture("", 0, 0, 400, 300)
    $hImage2 = _GDIPlus_BitmapCreateFromHBITMAP($hBitmap2)

    ; Draw one image in another
    $hGraphics = _GDIPlus_ImageGetGraphicsContext($hImage1)
    _GDIPlus_GraphicsDrawImage($hGraphics, $hImage2, 100, 100)

    ; Draw a frame around the inserted image
    _GDIPlus_GraphicsDrawRect($hGraphics, 100, 100, 400, 300)

    ; Save resultant image
    _GDIPlus_ImageSaveToFile($hImage1, @MyDocumentsDir & "\GDIPlus_Image.jpg")

    ; Clean up resources

    ; Shut down GDI+ library

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