Funktionreferenz


_GDIPlus_BitmapDispose

Beschreibung anzeigen in

Abfrage nach einem Bitmap-Objekt

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

Parameter

$hBitmap Handle zu dem Bitmap-Objekt

Rückgabewert

Erfolg: True
Fehler: False und setzt das @error Flag auf ungleich null. @extended kann den GPSTATUS Fehlercode ($GPID_ERR* siehe GDIPlusConstants.au3) enthalten.

Siehe auch

Suche nach GdipDisposeImage in der MSDN Bibliothek.

Beispiel

Beispiel 1

#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() ;initialize GDI+

    $g_hBitmap = _GDIPlus_BitmapCreateFromFile($sFile) ;create a bitmap object from file
    If @error Then
        _GDIPlus_Shutdown()
        MsgBox(($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(($MB_YESNO + $MB_ICONQUESTION + $MB_SYSTEMMODAL), "", '"' & $sNewJPGFile & '" already exists. Overwrite?')
        If $iAnswer <> $IDYES Then
            _ReleaseResources()
            Return False
        EndIf
    EndIf

    _GDIPlus_ImageSaveToFile($g_hBitmap, $sNewJPGFile) ;save image in JPG format
    If @error Then
        MsgBox(($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) ;release a bitmap object
    _GDIPlus_Shutdown()
EndFunc   ;==>_ReleaseResources

Beispiel 2

#include <GuiConstantsEx.au3>
#include <GDIPlus.au3>
#include <ScreenCapture.au3>

_Main()

Func _Main()
    Local $hGUI, $hBMP, $hBitmap, $hGraphic

    ; Erstellt vom oberen, linken Bereich des Bildschirms einen Screenshot
    $hBMP = _ScreenCapture_Capture("", 0, 0, 400, 300)

    ; Erstellt eine GUI
    $hGUI = GUICreate("GDI+", 400, 300)
    GUISetState()

    ; Initialisiert (startet) Microsoft Windows GDI+
    _GDIPlus_Startup()

    ; Zeichnet ein Bitmap auf die GUI
    $hBitmap = _GDIPlus_BitmapCreateFromHBITMAP($hBMP)
    $hGraphic = _GDIPlus_GraphicsCreateFromHWND($hGUI)
    _GDIPlus_GraphicsDrawImage($hGraphic, $hBitmap, 0, 0)

    ; Ressourcen freigeben
    _GDIPlus_GraphicsDispose($hGraphic)
    _GDIPlus_BitmapDispose($hBitmap)
    _WinAPI_DeleteObject($hBMP)

    ; Gibt die durch Microsoft Windows GDI+ verwendeten Ressourcen wieder frei
    _GDIPlus_Shutdown()

    ; Die Schleife wiederholt sich, bis der Benutzer die Beenden-Aktion der GUI auslöst
    Do
    Until GUIGetMsg() = $GUI_EVENT_CLOSE


EndFunc   ;==>_Main