Dessine un rectangle
#include <GDIPlus.au3>
_GDIPlus_GraphicsDrawRect ( $hGraphics, $nX, $nY, $nWidth, $nHeight [, $hPen = 0] )
$hGraphics | Handle de l'objet Graphics |
$nX | La coordonnée X du coin supérieur gauche du rectangle |
$nY | La coordonnée Y du coin supérieur gauche du rectangle, |
$nWidth | La largeur du rectangle |
$nHeight | La hauteur du rectangle |
$hPen | [optionnel] Handle de l'objet Pen qui est utilisé pour dessiner le rectangle. Si 0, un crayon noir qui trace des traits continus de largeur de 1 sera utilisé |
Succès: | Retourne True. |
Échec: | Retourne False et définit @error <> 0, @extended contient le code erreur GPSTATUS ($GPID_ERR*). |
Consultez GdipDrawRectangle dans la Librairie MSDN.
#include <GDIPlus.au3> #include <ScreenCapture.au3> #include <WinAPIHObj.au3> Example() Func Example() Local $hBitmap1, $hBitmap2, $hImage1, $hImage2, $hGraphics ; Initialise la bibliothèque GDI+ _GDIPlus_Startup() ; Capture l'écran complet $hBitmap1 = _ScreenCapture_Capture("") $hImage1 = _GDIPlus_BitmapCreateFromHBITMAP($hBitmap1) ; Capture une région d'écran $hBitmap2 = _ScreenCapture_Capture("", 0, 0, 400, 300) $hImage2 = _GDIPlus_BitmapCreateFromHBITMAP($hBitmap2) ; Dessine une image dans une autre $hGraphics = _GDIPlus_ImageGetGraphicsContext($hImage1) _GDIPlus_GraphicsDrawImage($hGraphics, $hImage2, 100, 100) ; Dessine un cadre autour de l'image insérée _GDIPlus_GraphicsDrawRect($hGraphics, 100, 100, 400, 300) ; Enregistre l'image résultante _GDIPlus_ImageSaveToFile($hImage1, @MyDocumentsDir & "\GDIPlus_Image.jpg") ; Nettoie les ressources _GDIPlus_ImageDispose($hImage1) _GDIPlus_ImageDispose($hImage2) _WinAPI_DeleteObject($hBitmap1) _WinAPI_DeleteObject($hBitmap2) ; Arrête la bibliothèque GDI+ _GDIPlus_Shutdown() ShellExecute(@MyDocumentsDir & "\GDIPlus_Image.jpg") EndFunc ;==>Example
#include <GDIPlus.au3> #include <GUIConstantsEx.au3> Example() Func Example() _GDIPlus_Startup() ; Initialise GDI+ Local Const $iWidth = 600, $iHeight = 600, $iBgColor = 0x303030 ; $iBGColor est au format RRGGBB Local $hGUI = GUICreate("GDI+ example", $iWidth, $iHeight) ; Crée une fenêtre de test GUISetBkColor($iBgColor, $hGUI) ; Définit la couleur de fond de la GUI GUISetState(@SW_SHOW) Local $hGraphics = _GDIPlus_GraphicsCreateFromHWND($hGUI) ; Crée un objet Graphics à partir du handle de la fenêtre _GDIPlus_GraphicsSetSmoothingMode($hGraphics, $GDIP_SMOOTHINGMODE_HIGHQUALITY) ; Définit pour l'objet graphique la qualité de rendu antialiasing Local $hPen = _GDIPlus_PenCreate(0xFFFEDCBA, 4) ; Format de couleur AARRGGBB (hex) _GDIPlus_GraphicsDrawRect($hGraphics, 150.5, 50.1, 280.25, 500.75, $hPen) Do Until GUIGetMsg() = $GUI_EVENT_CLOSE ; Nettoie les ressources GDI+ _GDIPlus_PenDispose($hPen) _GDIPlus_GraphicsDispose($hGraphics) _GDIPlus_Shutdown() GUIDelete($hGUI) EndFunc ;==>Example