Dessine un objet Image
#include <GDIPlus.au3>
_GDIPlus_GraphicsDrawImageRectRect ( $hGraphics, $hImage, $nSrcX, $nSrcY, $nSrcWidth, $nSrcHeight, $nDstX, $nDstY, $nDstWidth, $nDstHeight [, $pAttributes = 0 [, $iUnit = 2]] )
$hGraphics | Handle de l'objet Graphics |
$hImage | Handle de l'objet l'image |
$nSrcX | La coordonn�e X du coin sup�rieur gauche de l'image source |
$nSrcY | La coordonn�e Y du coin sup�rieur gauche de l'image source |
$nSrcWidth | Largeur de l'image source |
$nSrcHeight | Hauteur de l'image source |
$nDstX | La coordonn�e X du coin sup�rieur gauche de l'image de destination |
$nDstY | La coordonn�e Y du coin sup�rieur gauche de l'image de destination |
$nDstWidth | Largeur de l'image de destination |
$nDstHeight | Hauteur de l'image de destination |
$pAttributes | [optionnel] handle sur une structure ImageAttributes qui sp�cifie les attributs couleur et taille de l'image qui doit �tre dessin�e. La valeur par d�faut est NULL. |
$iUnit | [optionnel] Sp�cifie l'unit� de mesure de l'image |
Succ�s: | Retourne True |
�chec: | Retourne False et d�finit @error <> 0, @extended contient le code erreur GPSTATUS ($GPID_ERR*). |
Consultez GdipDrawImageRectRect dans la Librairie MSDN.
#include <GDIPlus.au3> #include <GUIConstantsEx.au3> #include <ScreenCapture.au3> #include <WinAPIHObj.au3> Example() Func Example() _GDIPlus_Startup() ; Initialise GDI+ Local Const $iWidth = 600, $iHeight = 600 Local $hGUI = GUICreate("GDI+ example", $iWidth, $iHeight) ; Cr�e une fen�tre de test GUISetState(@SW_SHOW) Local $hGraphics = _GDIPlus_GraphicsCreateFromHWND($hGUI) ; Cr�e un objet Graphics � partir du handle de la fen�tre Local $hIA = _GDIPlus_ImageAttributesCreate() ; Cr�e un objet ImageAttribute ; Cr�e la matrice des couleurs utilis�e pour ajuster les couleurs de l'image Local $tColorMatrix = _GDIPlus_ColorMatrixCreateTranslate(-1, -1, 0) ; Utilise la traduction matricielle des couleurs pour cr�er une image bleu �caill�e _GDIPlus_ImageAttributesSetColorMatrix($hIA, 0, True, $tColorMatrix) ; R�gle la couleur-cl� de la matrice des couleurs ImageAttribute Local $hHBmp = _ScreenCapture_Capture("", 0, 0, $iWidth, $iHeight) ; Cr�e un bitmap GDI en capturant une r�gion du bureau Local $hBitmap = _GDIPlus_BitmapCreateFromHBITMAP($hHBmp) ; Convertit le bitmap GDI en GDI+ _WinAPI_DeleteObject($hHBmp) ; Lib�re la ressource du bitmap GDI car elle n'est plus utile _GDIPlus_GraphicsDrawImageRectRect($hGraphics, $hBitmap, 0, 0, $iWidth, $iHeight, 0, 0, $iWidth, $iHeight, $hIA) ; Dessine le bitmap tout en appliquant le r�glage de la couleur Do Until GUIGetMsg() = $GUI_EVENT_CLOSE ; Nettoie les ressources GDI+ _GDIPlus_ImageAttributesDispose($hIA) _GDIPlus_GraphicsDispose($hGraphics) _GDIPlus_BitmapDispose($hBitmap) _GDIPlus_Shutdown() GUIDelete($hGUI) EndFunc ;==>Example
#include <GDIPlus.au3> #include <GUIConstantsEx.au3> #include <ScreenCapture.au3> #include <WinAPIHObj.au3> Global $g_hGUI, $g_hGfxCtxt, $g_hBitmap, $g_hBMP, $g_hGraphics Example() Func Example() AutoItSetOption("GUIOnEventMode", 1) _GDIPlus_Startup() ; Initialise GDI+ Local Const $iWidth = 600, $iHeight = 600, $iBgColor = 0x303030 ; $iBGColor est au format RRGGBB $g_hGUI = GUICreate("GDI+ example", $iWidth, $iHeight) ; Cr�e une fen�tre de test GUISetBkColor($iBgColor, $g_hGUI) ; D�finit la couleur de fond de la GUI GUISetState(@SW_SHOW) ; Cr�e un buffer graphique pour fluidifier les d�placements de l'objet gfx $g_hGraphics = _GDIPlus_GraphicsCreateFromHWND($g_hGUI) ; Cr�e un objet Graphics � partir du handle de la fen�tre $g_hBitmap = _GDIPlus_BitmapCreateFromGraphics($iWidth, $iHeight, $g_hGraphics) $g_hGfxCtxt = _GDIPlus_ImageGetGraphicsContext($g_hBitmap) Local Const $iW = 300, $iH = 300 Local $hHBmp = _ScreenCapture_Capture("", 4, @DesktopHeight - $iH, $iW + 4, @DesktopHeight) ; Cr�e un bitmap GDI en capturant une r�gion du bureau $g_hBMP = _GDIPlus_BitmapCreateFromHBITMAP($hHBmp) ; Convertit le bitmap GDI en GDI+ _WinAPI_DeleteObject($hHBmp) ; Lib�re la ressource du bitmap GDI car elle n'est plus utile Local $iVectorX = Random(1.5, 2.5), $iVectorY = Random(1.5, 2.5) ; D�finit les composantes du vecteur direction Local $iX = 0.0, $iY = 0.0 ; D�finit les coordonn�es de d�part GUISetOnEvent($GUI_EVENT_CLOSE, "_Exit") Do _GDIPlus_GraphicsClear($g_hGfxCtxt, 0xFF000000 + $iBgColor) ; Efface le bitmap pour le repeindre _GDIPlus_GraphicsDrawImageRectRect($g_hGfxCtxt, $g_hBMP, 0, 0, $iW, $iH, $iX, $iY, $iW / 2, $iH) ; Dessine le bitmap dans le buffer en r�duisant de moiti� la largeur _GDIPlus_GraphicsDrawImageRect($g_hGraphics, $g_hBitmap, 0, 0, $iWidth, $iHeight) ; Copie le bitmap dessin� dans le handle graphics (GUI) $iX += $iVectorX ; Ajoute le x du vecteur au x de la position actuelle $iY += $iVectorY ; Ajoute le y du vecteur au y de la position actuelle If $iX < 0 Or $iX > ($iWidth - $iW / 2) Then $iVectorX *= -1 ; Quand l'abscisse de la bordure est atteinte, l'abscisse du vecteur change de signe If $iY < 0 Or $iY > ($iHeight - $iH) Then $iVectorY *= -1 ; Quand l'ordonn�e de la bordure est atteinte, l'ordonn�es du vecteur change de signe Until Not Sleep(20) ; Pause 20 ms pour �viter une utilisation �lev�e du processeur EndFunc ;==>Example Func _Exit() ; Nettoie les ressources GDI+ _GDIPlus_GraphicsDispose($g_hGfxCtxt) _GDIPlus_GraphicsDispose($g_hGraphics) _GDIPlus_BitmapDispose($g_hBitmap) _GDIPlus_BitmapDispose($g_hBMP) _GDIPlus_Shutdown() GUIDelete($g_hGUI) Exit EndFunc ;==>_Exit