UDF > GDIPlus > GraphicsPath >


_GDIPlus_PathGetWorldBounds

Obtient le rectangle qui d�limite un objet GraphicsPath

#include <GDIPlus.au3>
_GDIPlus_PathGetWorldBounds ( $hPath [, $hMatrix = 0 [, $hPen = 0]] )

Param�tres

$hPath Handle de l'objet GraphicsPath
$hMatrix [optionnel] Handle de l'objet Matrix qui sp�cifie une transformation � appliquer � ce GraphicsPath avant que le rectangle de d�limitation soit calcul�. Le chemin ne se transforme pas en permanence
$hPen [optionnel] Handle de l'objet Pen qui influe sur la taille du rectangle de d�limitation.
Les limites du rectangle d�limitant seront suffisamment grandes pour englober le GraphicsPath quand il sera dessin� avec le crayon sp�cifi�.

Valeur de retour

Succ�s: Retourne un tableau contenant les coordonn�es du rectangle et ses dimensions:
    [0] - Coordonn�e X du rectangle
    [1] - Coordonn�e Y du rectangle
    [2] - Largeur du rectangle
    [3] - Hauteur du rectangle
�chec: D�finit @error <> 0, @extended contient le code erreur GPSTATUS ($GPID_ERR*).

Voir aussi

Consultez GdipGetPathWorldBounds dans la Librairie MSDN.

Exemple

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

Example()

Func Example()
    Local $iW, $iH, $hGUI, $hGraphic, $hBrush, $hPen, $hPath, $hFamily, $tLayout, $hMatrix, $aBounds

    ; Cr�e une GUI
    $iW = 640
    $iH = 220
    $hGUI = GUICreate("GDI+", $iW, $iH)
    GUISetState(@SW_SHOW)

    ; Dessine une cha�ne en utilisant un Path
    _GDIPlus_Startup()
    $hGraphic = _GDIPlus_GraphicsCreateFromHWND($hGUI) ; Cr�e un objet graphique � partir du handle de la fen�tre
    _GDIPlus_GraphicsSetSmoothingMode($hGraphic, $GDIP_SMOOTHINGMODE_HIGHQUALITY) ; D�finit pour l'objet graphique la qualit� de rendu antialiasing
    _GDIPlus_GraphicsClear($hGraphic, 0xFF000000)

    $hBrush = _GDIPlus_BrushCreateSolid(0xFFDD2200)
    $hPen = _GDIPlus_PenCreate(0xFFFFBB00, 2)

    $hPath = _GDIPlus_PathCreate() ; Cr�e un objet path

    $hFamily = _GDIPlus_FontFamilyCreate("Arial") ; Cr�e un objet FontFamily
    $tLayout = _GDIPlus_RectFCreate() ; Cr�e une cha�ne encadr�e par un rectangle de position X=0, Y=0
    _GDIPlus_PathAddString($hPath, "Fit to Window", $tLayout, $hFamily) ; Ajoute le contour de la cha�ne au Path

    ; Transforme le Path pour l'adapter � la fen�tre
    $aBounds = _GDIPlus_PathGetWorldBounds($hPath) ; Obtient le rectangle de d�limitation du Path
    $hMatrix = _GDIPlus_MatrixCreate()
    _GDIPlus_MatrixTranslate($hMatrix, -$aBounds[0], -$aBounds[1]) ; Matrice de translation pour l'offset du rectangle de d�limitation
    _GDIPlus_MatrixScale($hMatrix, $iW / $aBounds[2], $iH / $aBounds[3], True) ; Matrice de mise � l'�chelle
    _GDIPlus_PathTransform($hPath, $hMatrix) ; Translate et met � l'�chelle le Path

    _GDIPlus_GraphicsFillPath($hGraphic, $hPath, $hBrush) ; Dessine le Path avec le handle Graphic (GUI)
    _GDIPlus_GraphicsDrawPath($hGraphic, $hPath, $hPen) ; Dessine le Path avec le handle Graphic (GUI)

    ; Transforme le trac� pour le centrer
    _GDIPlus_PathReset($hPath) ; R�initialise le Path (supprime cha�ne pr�c�dente)
    _GDIPlus_PathAddString($hPath, "Center", $tLayout, $hFamily, 0, 100, 0) ; Ajoute le contour de la cha�ne au Path

    $aBounds = _GDIPlus_PathGetWorldBounds($hPath)
    _GDIPlus_MatrixSetElements($hMatrix, 1, 0, 0, 1, 0, 0) ; R�initialise la matrice
    _GDIPlus_MatrixTranslate($hMatrix, ($iW / 2) - $aBounds[0] - ($aBounds[2] / 2), ($iH / 2) - $aBounds[1] - ($aBounds[3] / 2))
    _GDIPlus_PathTransform($hPath, $hMatrix) ; Translate (offset) le Path

    _GDIPlus_BrushSetSolidColor($hBrush, 0x7F004488)
    _GDIPlus_PenSetColor($hPen, 0xFF00AAFF)
    _GDIPlus_GraphicsFillPath($hGraphic, $hPath, $hBrush) ; Dessine le Path avec le handle Graphic (GUI)
    _GDIPlus_GraphicsDrawPath($hGraphic, $hPath, $hPen) ; Dessine le Path avec le handle Graphic (GUI)

    ; Boucle jusqu'� ce que l'utilisateur quitte.
    Do
    Until GUIGetMsg() = $GUI_EVENT_CLOSE

    ; Nettoie les ressources
    _GDIPlus_MatrixDispose($hMatrix)
    _GDIPlus_FontFamilyDispose($hFamily)
    _GDIPlus_PathDispose($hPath)
    _GDIPlus_PenDispose($hPen)
    _GDIPlus_BrushDispose($hBrush)
    _GDIPlus_GraphicsDispose($hGraphic)
    _GDIPlus_Shutdown()
EndFunc   ;==>Example