UDF > GDIPlus > Bitmap >


_GDIPlus_BitmapDispose

Libère un objet Bitmap

#include <GDIPlus.au3>
_GDIPlus_BitmapDispose ( $hBitmap )

Paramètre

$hBitmap Handle de l'objet Bitmap

Valeur de retour

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

Voir aussi

Consultez GdipDisposeImage dans la Librairie MSDN.

Exemple

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

Global $g_hBitmap

Example()

Func Example()
    Local $sFile = FileOpenDialog("Select an image (non JPG)", "", "Images (*.bmp;*.png;*. gif;*.tif)")
    If @error Then
        MsgBox($MB_SYSTEMMODAL, "", "Aborted", 30)
        Return False
    EndIf

    _GDIPlus_Startup() ; Initialise GDI+

    $g_hBitmap = _GDIPlus_BitmapCreateFromFile($sFile) ; Crée un objet bitmap à partir du fichier
    If @error Then
        _GDIPlus_Shutdown()
        MsgBox(BitOR($MB_SYSTEMMODAL, $MB_ICONHAND), "", "An error has occured - unable to load image!", 30)
        Return False
    EndIf

    Local $sNewJPGFile = StringTrimRight($sFile, 3) & "jpg", $iAnswer = 0

    If FileExists($sNewJPGFile) Then
        $iAnswer = MsgBox(BitOR($MB_SYSTEMMODAL, $MB_YESNO, $MB_ICONQUESTION), "", '"'& $sNewJPGFile & '" already exists. Overwrite?')
        If $iAnswer <> $IDYES Then
            _ReleaseResources()
            Return False
        EndIf
    EndIf

    _GDIPlus_ImageSaveToFile($g_hBitmap, $sNewJPGFile) ; Enregistre l'image au format JPG
    If @error Then
        MsgBox(BitOR($MB_SYSTEMMODAL, $MB_ICONHAND), "", "An error has occured - unable to save image!", 30)
    Else
        ShellExecute($sNewJPGFile)
    EndIf

    _ReleaseResources()
EndFunc   ;==>Example

Func _ReleaseResources()
    _GDIPlus_BitmapDispose($g_hBitmap) ; Libére un objet bitmap
    _GDIPlus_Shutdown()
EndFunc   ;==>_ReleaseResources