UDF > GDIPlus > Bitmap >


_GDIPlus_BitmapGetPixel

Obtient la couleur d'un pixel d'un bitmap

#include <GDIPlus.au3>
_GDIPlus_BitmapGetPixel ( $hBitmap, $iX, $iY )

Paramètres

$hBitmap Handle de l'objet Bitmap
$iX La coordonnée X du pixel
$iY La coordonnée Y du pixel

Valeur de retour

Succès: Retourne la couleur du pixel du bitmap.
Échec: Retourne 0 et définit @error <> 0, @extended contient le code erreur GPSTATUS ($GPID_ERR*).

En relation

_GDIPlus_BitmapSetPixel

Voir aussi

Consultez GdipBitmapGetPixel dans la Librairie MSDN.

Exemple

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

Example()

Func Example()
    _GDIPlus_Startup() ; Initialise GDI+
    Local Const $iWidth = 150, $iHeight = 150
    Local $iColor = 0
    Local $hHBmp = _ScreenCapture_Capture("", 0, 0, $iWidth, $iHeight) ; Crée un bitmap GDI par la capture d'une zone du bureau
    Local $hBitmap = _GDIPlus_BitmapCreateFromHBITMAP($hHBmp) ; Convertit le bitmap GDI en GDI+
    _WinAPI_DeleteObject($hHBmp) ; Libére le bitmap GDI car n'est plus nécessaire

    For $iY = 0 To $iHeight - 1
        For $iX = 0 To $iWidth - 1
            $iColor = _GDIPlus_BitmapGetPixel($hBitmap, $iX, $iY) ; Obtient la couleur de pixel courant
            _GDIPlus_BitmapSetPixel($hBitmap, $iX, $iY, BitXOR(0x00FFFFFF, $iColor)) ; XOR avec la couleur du pixel
        Next
    Next
    Local $hGUI = GUICreate("GDI+ example", $iWidth, $iHeight) ; Crée une GUI de test
    GUISetState(@SW_SHOW)

    Local $hGraphics = _GDIPlus_GraphicsCreateFromHWND($hGUI) ; Crée un objet graphique à partir d'un handle fenêtre
    _GDIPlus_GraphicsDrawImage($hGraphics, $hBitmap, 0, 0) ; Copie le bitmap dans l'objet graphique (GUI)

    Do
    Until GUIGetMsg() = $GUI_EVENT_CLOSE

    ; Nettoie les ressources GDI+
    _GDIPlus_GraphicsDispose($hGraphics)
    _GDIPlus_Shutdown()
    GUIDelete($hGUI)
EndFunc   ;==>Example