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