UDF > GDIPlus > Image >


_GDIPlus_ImageGetGraphicsContext

Obtient le contexte graphique de l'image

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

Paramètre

$hImage Handle de l'objet image

Valeur de retour

Succès: Retourne le handle de l'objet Graphics.
Échec: Retourne -1 et définit @error <> 0, @extended contient le code erreur GPSTATUS ($GPID_ERR*).

Voir aussi

Consultez GdipGetImageGraphicsContext dans la Librairie MSDN.

Exemple

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

Example()

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

    ; Initialise la bibliothèque GDI+
    _GDIPlus_Startup()

    ; Capture l'écran complet
    $hBitmap1 = _ScreenCapture_Capture("")
    $hImage1 = _GDIPlus_BitmapCreateFromHBITMAP($hBitmap1)

    ; Capture une région d'écran
    $hBitmap2 = _ScreenCapture_Capture("", 0, 0, 400, 300)
    $hImage2 = _GDIPlus_BitmapCreateFromHBITMAP($hBitmap2)

    ; Dessine une image dans une autre
    $hGraphics = _GDIPlus_ImageGetGraphicsContext($hImage1)
    _GDIPlus_GraphicsDrawImage($hGraphics, $hImage2, 100, 100)

    ; Dessine un cadre autour de l'image insérée
    _GDIPlus_GraphicsDrawRect($hGraphics, 100, 100, 400, 300)

    ; Enregistre l'image résultante
    _GDIPlus_ImageSaveToFile($hImage1, @MyDocumentsDir & "\GDIPlus_Image.jpg")

    ; Nettoie les ressources
    _GDIPlus_GraphicsDispose($hGraphics)
    _GDIPlus_ImageDispose($hImage1)
    _GDIPlus_ImageDispose($hImage2)
    _WinAPI_DeleteObject($hBitmap1)
    _WinAPI_DeleteObject($hBitmap2)

    ; Arrête la bibliothèque GDI+
    _GDIPlus_Shutdown()

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