Page 1 sur 1
[..] Défilement de graphique
Posté : mar. 05 juil. 2011 13:44
par mikell
Bonjour
J'essaie de faire tracer sur un graphique une courbe qui défile ensuite vers la gauche, un peu comme un électrocardiogramme
Avec les fonctions natives graphiques d'AutoIt pas de problème, mais le GUICtrlSetGraphic($graphic, $GUI_GR_REFRESH) provoque un clignotement important
Avec les fonctions GDI+ et un double buffer le tracé est parfait, mais là je n'arrive pas à avoir le défilement
J'ai essayé avec MatrixTranslate, ça marche mais ça bug au bout d'un moment...
Quelqu'un n'aurait pas un petit exemple avec GDI+ ou WinAPI qui me mettrait sur la voie ?
Merci
Re: [..] Défilement de graphique
Posté : mar. 05 juil. 2011 13:56
par TT22
Re: [..] Défilement de graphique
Posté : mar. 05 juil. 2011 14:26
par ZDS
Bonjour,
Pour pouvoir t'aider un peu plus efficacement, pense à fournir un code source d'exemple (c'est toujours plus facile que de partir from scratch).
A bientôt.
Re: [..] Défilement de graphique
Posté : mar. 05 juil. 2011 15:57
par zeshrek
Re: [..] Défilement de graphique
Posté : mar. 05 juil. 2011 20:20
par mikell
@zeshrek
c'est gentil de me renvoyer sur Google et j'apprécie la délicate attention, bien que l'ayant (bien évidemment) déjà essayé et ayant aussi écumé le site US
@TT22
Avant de me rabattre sur une UDF je préfèrerais essayer de résoudre le pb avec les fonctions simples gdi+ et winapi
@ZDS
voilà le code, il est un peu fouillis mais c'est un chantier
le code est à utiliser avec l'image ci-jointe
► Afficher le texte
Code : Tout sélectionner
#include <WinAPI.au3>
#include <GDIPlus.au3>
#include <Array.au3>
#include <GUIConstantsEx.au3>
Opt("GUIOnEventMode", 1)
$iW = 500
$iH = 300
$gui = GuiCreate("dd", $iW, $iH, 300, 50)
GuiSetBkColor(0x000000)
GUISetOnEvent( -3, "_Exit")
GuiSetState()
_GDIPlus_Startup()
$hGraphic = _GDIPlus_GraphicsCreateFromHWND($gui)
$hMatrix = _GDIPlus_MatrixCreate()
$hBitmap = _GDIPlus_BitmapCreateFromGraphics($iW*5, $iH, $hGraphic)
$hBackbuffer = _GDIPlus_ImageGetGraphicsContext($hBitmap)
_GDIPlus_GraphicsSetSmoothingMode($hBackbuffer, 2)
_GDIPlus_GraphicsClear($hBackbuffer) ;, 0xFFFFFFFF)
$hPen = _GDIPlus_PenCreate(0xFF00FF00, 3)
Dim $pixels, $iTotalReplace, $Count = 0
;_GDIPlus_Startup()
$hImage = _GDIPlus_ImageLoadFromFile("ecgNB.bmp")
$width = _GDIPlus_ImageGetWidth($hImage)
$height = _GDIPlus_ImageGetHeight($hImage)
$hBmp = _GDIPlus_BitmapCreateHBITMAPFromBitmap($hImage)
$aSize = DllCall('gdi32.dll', 'int', 'GetBitmapBits', 'ptr', $hBmp, 'int', 0, 'ptr', 0)
If $aSize[0] Then
$tBits = DllStructCreate('byte[' & $aSize[0] & ']')
DllCall('gdi32.dll', 'int', 'GetBitmapBits', 'ptr', $hBmp, 'int', $aSize[0], 'ptr', DllStructGetPtr($tBits))
$sHex = Hex(DllStructGetData($tBits, 1))
$sHex = StringRegExpReplace($sHex, "([[:xdigit:]]{6})(FF)", "\1 ")
Local $pix[$height][$width], $aTemp
Local $aArr = StringRegExp($sHex, "(.{" & ($width * 7) & "})", 3)
; _ArrayDisplay($aArr) ; array à 123 lignes et 1 col de 193 caract
For $x = 0 To UBound($aArr)-1 ; pour chacune des 123 lignes
$aTemp = StringRegExp($aArr[$x] & " ", "(.{6}) ", 3) ; array à 123 lignes et 1 col
For $y = 0 To UBound($aTemp) - 1 ; 192
$pix[$x][$y] = $aTemp[$y]
Next
Next
_WinAPI_DeleteObject($hBmp)
_GDIPlus_ImageDispose($hImage)
; _GDIPlus_Shutdown()
EndIf
$k = 0
$horiz = 0
$vert = 100
AdlibRegister("Draw", 100)
While Sleep(10000)
WEnd
Func Draw()
_GDIPlus_GraphicsClear($hBackbuffer) ; , 0xFFFFFFFF)
While 1
For $i = 0 to UBound($pix, 2)-1
For $j = 0 to UBound($pix)-1
If StringLeft($pix[$j][$i], 1) = "F" Then
Sleep(1)
If $i+($k*$width) >=400 Then
_GDIPlus_MatrixTranslate($hMatrix, -1, 0)
_GDIPlus_GraphicsSetTransform($hGraphic, $hMatrix)
EndIf
_GDIPlus_GraphicsDrawLine($hBackbuffer, $horiz , $vert+50 , $i+($k*$width), $j+50, $hPen)
$horiz = $i+($k*$width)
$vert = $j
Exitloop
EndIf
Next
_GDIPlus_GraphicsDrawImage($hGraphic, $hBitmap, 0, 0)
Next
$k += 1
Wend
EndFunc
;--------------------------------------------------------
Func _Exit()
AdlibUnRegister("Draw")
_GDIPlus_PenDispose($hPen)
_GDIPlus_GraphicsDispose($hBackbuffer)
_GDIPlus_BitmapDispose ($hBitmap)
_GDIPlus_GraphicsDispose($hGraphic)
_GDIPlus_MatrixDispose($hMatrix)
_GDIPlus_Shutdown()
GUIDelete($gui)
Exit
EndFunc
Re: [..] Défilement de graphique
Posté : mer. 06 juil. 2011 00:22
par TT22
@ mikell :
Ok, bonne chance

Re: [..] Défilement de graphique
Posté : sam. 09 juil. 2011 10:11
par overflow
ca fonctionne bien non ?
chez moi j ai un beau trait vert bien fluide
Re: [..] Défilement de graphique
Posté : sam. 09 juil. 2011 10:28
par mikell
J'ai sans doute mal formulé ma question
C'est vrai que ça marche, mais la courbe s'affiche sur une largeur définie par
$hBitmap = _GDIPlus_BitmapCreateFromGraphics($iW*5, $iH, $hGraphic)
et une fois cette largeur atteinte, elle ne s'affiche plus
Je cherche un moyen de la faire défiler indéfiniment (faire une boucle, mais où ?)
Re: [..] Défilement de graphique
Posté : lun. 11 juil. 2011 21:07
par overflow
Dans ce cas la ne reprend pas ce code
tu te fait un scroll simple
tu affiche un point a droite et tu décale l écran sur la gauche et ainsi de suite