Crée et initialise un objet Matrix avec la matrice identité
#include <GDIPlus.au3>
_GDIPlus_MatrixCreate ( )
Succès: | Retourne le handle de l'objet Matrix. |
Échec: | Retourne 0 et définit @error <> 0, @extended contient le code erreur GPSTATUS ($GPID_ERR*). |
Lorsque vous en avez terminé avec la matrice, appelez _GDIPlus_MatrixDispose() pour libérer les ressources.
Consultez GdipCreateMatrix dans la Librairie MSDN.
#include <GDIPlus.au3> #include <ScreenCapture.au3> #include <WinAPIHObj.au3> Example() Func Example() Local $hBitmap1, $hBitmap2, $hImage1, $hImage2, $hGraphic, $iWidth, $iHeight ; 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) $iWidth = _GDIPlus_ImageGetWidth($hImage2) $iHeight = _GDIPlus_ImageGetHeight($hImage2) ; Dessine une image dans une autre $hGraphic = _GDIPlus_ImageGetGraphicsContext($hImage1) ; DrawInsert ($hGraphic, $hImage2, iX $, $iy, Fangle $, $iwidth, $iheight, $iARGB = 0xFF000000, $iPenWidth = 1) DrawInsert($hGraphic, $hImage2, 350, 100, 0, $iWidth + 2, $iHeight + 2, 0xFFFF8000, 2) DrawInsert($hGraphic, $hImage2, 340, 50, 15, 200, 150, 0xFFFF8000, 4) DrawInsert($hGraphic, $hImage2, 310, 30, 35, $iWidth + 4, $iHeight + 4, 0xFFFF00FF, 4) DrawInsert($hGraphic, $hImage2, 320, 790, -35, $iWidth, $iHeight) ; 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 ; #FUNCTION# ================================================================================================== ; Name...........: DrawInsert ; Description ...: Dessine une image dans une autre ; Syntax.........: DrawInsert($hGraphic, $hImage2, $iX, $iY, $fAngle, $iWidth, $iHeight, $iARGB = 0xFF000000, $iPenWidth = 1) ; insère le Graphics $hImage2 dans $hGraphic ; Parameters ....: $hGraphics - Handle de l'objet Graphics ; $hImage - Handle de l'objet Image à insérer ; $iX - La coordonnée X du coin supérieur gauche de l'image insérée ; $iY - La coordonnée Y du coin supérieur gauche de l'image insérée ; $iWidth - La largeur du rectangle qui encadre l'image insérée ; $iHeight - La hauteur du rectangle qui encadre l'image insérée ; $iARGB - Les composantes Alpha, Rouge, Vert et Bleu de la couleur du crayon - couleur du cadre ; $iPenWidth - La largeur du crayon mesurée dans l'unité spécifiée dans le paramètre $iUnit - Largeur du cadre ; Return values .: Succès - True ; Echec - False ; ================================================================================================== Func DrawInsert($hGraphic, $hImage2, $iX, $iY, $fAngle, $iWidth, $iHeight, $iARGB = 0xFF000000, $iPenWidth = 1) Local $hMatrix, $hPen2 ; Matrice de rotation $hMatrix = _GDIPlus_MatrixCreate() _GDIPlus_MatrixRotate($hMatrix, $fAngle, "False") _GDIPlus_GraphicsSetTransform($hGraphic, $hMatrix) _GDIPlus_GraphicsDrawImage($hGraphic, $hImage2, $iX, $iY) ; Obtient le crayon + la couleur $hPen2 = _GDIPlus_PenCreate($iARGB, $iPenWidth) ; Dessine un cadre autour de l'image insérée _GDIPlus_GraphicsDrawRect($hGraphic, $iX, $iY, $iWidth, $iHeight, $hPen2) ; Nettoie les ressources _GDIPlus_MatrixDispose($hMatrix) _GDIPlus_PenDispose($hPen2) Return 1 EndFunc ;==>DrawInsert