UDF > GDIPlus > Bitmap >


_GDIPlus_BitmapUnlockBits

D�verrouille la partie rectangulaire d'un bitmap qui a �t� verrouill�e par _GDIPlus_BitmapLockBits

#include <GDIPlus.au3>
_GDIPlus_BitmapUnlockBits ( $hBitmap, $tBitmapData )

Param�tres

$hBitmap Handle de l'objet Bitmap
$tBitmapData Structure $tagGDIPBITMAPDATA pr�c�demment transmise � _GDIPlus_BitmapLockBits

Valeur de retour

Succ�s: Retourne True
�chec: Rztourne False et @error <> 0, @extended contient le code erreur GPSTATUS ($GPID_ERR*).

Remarque

Lorsque vous en avez termin� avec la partie verrouill�e, appelez _GDIPlus_BitmapUnlockBits() pour copier les pixels dans la m�moire du bitmap, puis lib�rer le verrouillage de la partie de l'image.

En relation

_WinAPI_DeleteObject

Voir aussi

Consultez GdipBitmapUnlockBits dans la Librairie MSDN.

Exemple

#include <GDIPlus.au3>
#include <GUIConstantsEx.au3>
#include <MsgBoxConstants.au3>

Example()

Func Example()
    ; Support d'ex�cution X64
    Local $sWow64 = ""
    If @AutoItX64 Then $sWow64 = "\Wow6432Node"

    ; Obtient le r�pertoire d'installation  d'AutoIt
    Local $sRegPath = "HKLM\SOFTWARE" & $sWow64 & "\AutoIt v3\AutoIt"

    Local $sFile = RegRead($sRegPath, "InstallDir") & "\Examples\GUI\logo4.gif"
    If Not FileExists($sFile) Then
        MsgBox(BitOR($MB_SYSTEMMODAL, $MB_ICONHAND), "", $sFile & " not found!", 30)
        Return False
    EndIf

    _GDIPlus_Startup()
    Local $hImage = _GDIPlus_ImageLoadFromFile($sFile) ; Cr�e un objet image � partir d'un fichier
    If @error Then
        _GDIPlus_Shutdown()
        MsgBox(BitOR($MB_SYSTEMMODAL, $MB_ICONHAND), "", "Une erreur est survenue - impossible de charger l'image!", 30)
        Return False
    EndIf

    Local $iW = _GDIPlus_ImageGetWidth($hImage), $iH = _GDIPlus_ImageGetHeight($hImage) ; Obtient la largeur et la hauteur de l'image
    Local $hBitmap = _GDIPlus_BitmapCreateFromScan0($iW, $iH)
    Local $hContext = _GDIPlus_ImageGetGraphicsContext($hBitmap)
    _GDIPlus_GraphicsDrawImageRect($hContext, $hImage, 0, 0, $iW, $iH)

    Local $tBitmapData = _GDIPlus_BitmapLockBits($hBitmap, 0, 0, $iW, $iH, BitOR($GDIP_ILMWRITE, $GDIP_ILMREAD), $GDIP_PXF32ARGB) ; Verrouille une partie d'une image bitmap pour la lecture et l'�criture. Plus d'info � http://msdn.microsoft.com/en- us/library/windows/desktop/ms536298(v=vs.85).aspx
    Local $iScan0 = DllStructGetData($tBitmapData, "Scan0") ; Obtieni scan0 (donn�es de pixels) du bitmap verrouill�
    Local $iSearchPixel = Int(0xFF000080), $iReplaceColor = 0xFF000000 ; format de couleur 0xAARRVVBB
    Local $tPixel = DllStructCreate("int[" & $iW * $iH & "];", $iScan0)
    Local $iPixel, $iRowOffset

    For $iY = 0 To $iH - 1
        $iRowOffset = $iY * $iW + 1
        For $iX = 0 To $iW - 1 ; Obtient chaque pixel de chaque ligne et de chaque colonne
            $iPixel = DllStructGetData($tPixel, 1, $iRowOffset + $iX) ; Obtient la couleur des pixels
            If $iPixel = $iSearchPixel Then DllStructSetData($tPixel, 1, $iReplaceColor, $iRowOffset + $iX) ; Compare et remplace la couleur des pixels (bleu avec la couleur noire)
        Next
    Next
    _GDIPlus_BitmapUnlockBits($hBitmap, $tBitmapData) ; D�verrouille une partie d'une image bitmap qui a �t� verrouill�e par _GDIPlus_BitmapLockBits

    ; Pour enregistrer l'image manipul�e il suffit d'utiliser _GDIPlus_ImageSaveToFile ()

    ShellExecute($sFile) ; Affiche l'image originale pour la comparer avec celle manipul�e

    ; Affiche l'image manipul�e
    Local $hGUI = GUICreate("_GDIPlus_BitmapLockBits Demo", $iW, $iH)
    GUISetState(@SW_SHOW)

    Local $hGraphic = _GDIPlus_GraphicsCreateFromHWND($hGUI) ; Cr�e un objet Graphics � partir d'un handle fen�tre
    _GDIPlus_GraphicsDrawImageRect($hGraphic, $hBitmap, 0, 0, $iW, $iH) ; Copie l'image manipul�e dans le handle graphique

    Do
    Until GUIGetMsg() = $GUI_EVENT_CLOSE

    ; Nettoie
    _GDIPlus_ImageDispose($hImage)
    _GDIPlus_GraphicsDispose($hContext)
    _GDIPlus_BitmapDispose($hBitmap)
    _GDIPlus_GraphicsDispose($hGraphic)
    _GDIPlus_Shutdown()
    GUIDelete($hGUI)
EndFunc   ;==>Example