UDF > GDIPlus > Matrix >


_GDIPlus_MatrixRotate

Remplace les coefficients d'une matrice par les coefficients du produit d'elle-même avec une matrice de rotation

#include <GDIPlus.au3>
_GDIPlus_MatrixRotate ( $hMatrix, $fAngle [, $bAppend = False] )

Paramètres

$hMatrix Handle de l'objet Matrix
$fAngle L'angle de rotation en degrés. Les valeurs positives indiquent une rotation dans le sens horaire.
$bAppend [optionnel] Ordre de multiplication des matrices:
    True - Indique que la matrice de rotation est à gauche
    False - Indique que la matrice de rotation est à droite

Valeur de retour

Succès: Retourne True.
Échec: Retourne False et définit @error <> 0, @extended contient le code erreur ($GPID_ERR*).

Voir aussi

Consultez GdipRotateMatrix dans la Librairie MSDN.

Exemple

#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