Funktionreferenz


_GDIPlus_GraphicsDrawRect

Beschreibung anzeigen in

Zeichnet ein Rechteck

#include <GDIPlus.au3>
_GDIPlus_GraphicsDrawRect ( $hGraphics, $nX, $nY, $nWidth, $nHeight [, $hPen = 0] )

Parameter

$hGraphics Handle zu dem Grafik-Objekt
$nX Die X-Koordinate der oberen-linken Ecke des Rechtecks
$nY Die Y-Koordinate der oberen-linken Ecke des Rechtecks
$nWidth Die Breite des Rechtecks
$nHeight Die Höhe des Rechtecks
$hPen [optional] Handle zu dem Zeichenstift-Objekt, welches verwendet wird, um das Rechteck zu zeichnen. Falls 0, wird ein vollfarbig schwarz gefüllter Zeichenstift mit einer Breite von 1 verwendet.

Rückgabewert

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

Siehe auch

Suche nach GdipDrawRectangle in der MSDN Bibliothek.

Beispiel

Beispiel 1

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

Example()

Func Example()
    Local $hBitmap1, $hBitmap2, $hImage1, $hImage2, $hGraphics

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

    ; Erstellt vom kompletten Bildschirm einen Screenshot
    $hBitmap1 = _ScreenCapture_Capture("")
    $hImage1 = _GDIPlus_BitmapCreateFromHBITMAP($hBitmap1)

    ; Erstellt von einem Bereich einen Screenshot
    $hBitmap2 = _ScreenCapture_Capture("", 0, 0, 400, 300)
    $hImage2 = _GDIPlus_BitmapCreateFromHBITMAP($hBitmap2)

    ; Zeichnet ein Bild in ein anderes
    $hGraphics = _GDIPlus_ImageGetGraphicsContext($hImage1)
    _GDIPlus_GraphicsDrawImage($hGraphics, $hImage2, 100, 100)

    ; Zeichnet einen Rahmen um das eingefügte Bild
    _GDIPlus_GraphicsDrawRect($hGraphics, 100, 100, 400, 300)

    ; Speichert das neue Bild
    _GDIPlus_ImageSaveToFile($hImage1, @MyDocumentsDir & "\GDIPlus_Image.jpg")

    ; Ressourcen freigeben
    _GDIPlus_ImageDispose($hImage1)
    _GDIPlus_ImageDispose($hImage2)
    _WinAPI_DeleteObject($hBitmap1)
    _WinAPI_DeleteObject($hBitmap2)

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

    ShellExecute(@MyDocumentsDir & "\GDIPlus_Image.jpg")
EndFunc   ;==>Example

Beispiel 2

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

Example()

Func Example()
    _GDIPlus_Startup() ;initialize GDI+
    Local Const $iWidth = 600, $iHeight = 600, $iBgColor = 0x303030 ;$iBgColor format RRGGBB

    Local $hGUI = GUICreate("GDI+ Example (" & @ScriptName & ")", $iWidth, $iHeight) ;create a test GUI
    GUISetBkColor($iBgColor, $hGUI) ;set GUI background color
    GUISetState(@SW_SHOW)

    Local $hGraphics = _GDIPlus_GraphicsCreateFromHWND($hGUI) ;create a graphics object from a window handle
    _GDIPlus_GraphicsSetSmoothingMode($hGraphics, $GDIP_SMOOTHINGMODE_HIGHQUALITY) ;sets the graphics object rendering quality (antialiasing)
    Local $hPen = _GDIPlus_PenCreate(0xFFFEDCBA, 4) ;color format AARRGGBB (hex)

    _GDIPlus_GraphicsDrawRect($hGraphics, 150.5, 50.1, 280.25, 500.75, $hPen)

    Do
    Until GUIGetMsg() = $GUI_EVENT_CLOSE

    ;cleanup GDI+ resources
    _GDIPlus_PenDispose($hPen)
    _GDIPlus_GraphicsDispose($hGraphics)
    _GDIPlus_Shutdown()
    GUIDelete($hGUI)
EndFunc   ;==>Example