D�finit le mode de d�calage des pixels d'un objet Graphics
#include <GDIPlus.au3>
_GDIPlus_GraphicsSetPixelOffsetMode ( $hGraphics, $iPixelOffsetMode )
$hGraphics | Handle de l'objet Graphics |
$iPixelOffsetMode | Mode de d�calage des pixels: 0,1,3 - les centres des pixels ont des coordonn�es enti�res 2,4 - Les centres de pixels ont des coordonn�es qui sont � mi-chemin entre les valeurs enti�res (soit 0,5, 20, 105.5, etc... ) |
Succ�s: | Retourne True. |
�chec: | Retourne False et d�finit @error <> 0, @extended contient le code erreur GPSTATUS ($GPID_ERR*). |
Consultez GdipSetPixelOffsetMode dans la Librairie MSDN.
#include <GDIPlus.au3> #include <GUIConstantsEx.au3> Global $g_hGUI, $g_hGraphics, $g_hBitmap, $g_hGfxCtxt, $g_hPen Example() Func Example() AutoItSetOption("GUIOnEventMode", 1) _GDIPlus_Startup() ; Initialise GDI+ Local Const $iWidth = 600, $iHeight = 600, $iBgColor = 0x303030 ; Le format de $iBGColor est RRGGBB $g_hGUI = GUICreate("GDI+ example", $iWidth, $iHeight) ; Cr�e une GUI de test GUISetBkColor($iBgColor, $g_hGUI) ; D�finit la couleur de fond de la GUI GUISetState(@SW_SHOW) ; Cr�e un graphique dans un buffer pour lisser les mouvements des objets gfx $g_hGraphics = _GDIPlus_GraphicsCreateFromHWND($g_hGUI) ; Cr�e un objet graphique � partir d'un handle fen�tre $g_hBitmap = _GDIPlus_BitmapCreateFromGraphics($iWidth, $iHeight, $g_hGraphics) $g_hGfxCtxt = _GDIPlus_ImageGetGraphicsContext($g_hBitmap) _GDIPlus_GraphicsSetSmoothingMode($g_hGfxCtxt, $GDIP_SMOOTHINGMODE_HIGHQUALITY) ; D�finit pour l'objet graphique la qualit� de rendu antialiasing $g_hPen = _GDIPlus_PenCreate(0xFFFF8060, 2) _GDIPlus_GraphicsSetPixelOffsetMode($g_hGfxCtxt, $GDIP_PIXELOFFSETMODE_HIGHQUALITY) Local $aPoints[11][4], $x, $y $aPoints[0][0] = 10 For $y = 0 To 1 For $x = 1 To 5 $aPoints[$y * 5 + $x][0] = 100 + 300 * $y + 50 ; Coordonn�e x du point $aPoints[$y * 5 + $x][1] = 150 + $x * 50 ; Coordonn�e y du point $aPoints[$y * 5 + $x][2] = Random(-2, 2) ; x vecteur du point $aPoints[$y * 5 + $x][3] = Random(-2, 2) ; y vecteur du point Next Next GUISetOnEvent($GUI_EVENT_CLOSE, "_Exit") Do _GDIPlus_GraphicsClear($g_hGfxCtxt, 0xFF000000 + $iBgColor) ; Efface bitmap pour repeindre _GDIPlus_GraphicsDrawClosedCurve2($g_hGfxCtxt, $aPoints, 1.25, $g_hPen) ; Dessine la courbe ferm�e _GDIPlus_GraphicsDrawImage($g_hGraphics, $g_hBitmap, 0, 0) ; Copie le bitmap sur le handle graphique (GUI) For $y = 1 To $aPoints[0][0] $aPoints[$y][0] += $aPoints[$y][2] ; Calcule la nouvelle position x If $aPoints[$y][0] < 0 Or $aPoints[$y][0] > $iWidth Then $aPoints[$y][2] *= -1 ; si bordure verticale est atteinte inverser vecteur x $aPoints[$y][1] += $aPoints[$y][3] ; Calcule la nouvelle position y If $aPoints[$y][1] < 0 Or $aPoints[$y][1] > $iHeight Then $aPoints[$y][3] *= -1 ; si la bordure horizontale est atteinte inverser y vecteur Next Until Not Sleep(30) ; Pause 30 ms pour �viter une utilisation �lev�e du processeur EndFunc ;==>Example Func _Exit() ; Nettoie les ressources GDI+ _GDIPlus_PenDispose($g_hPen) _GDIPlus_GraphicsDispose($g_hGfxCtxt) _GDIPlus_GraphicsDispose($g_hGraphics) _GDIPlus_BitmapDispose($g_hBitmap) _GDIPlus_Shutdown() GUIDelete($g_hGUI) Exit EndFunc ;==>_Exit