Code : Tout sélectionner
#include <WinAPI.au3>
#include <GDIPlus.au3>
#include <Memory.au3>
#include <Array.au3>
#include <GUIConstantsEx.au3>
Opt("GUIOnEventMode", 1)
Global $width, $height
$img = Load_BMP_From_Mem(ecgNB_bmp(), true)
_Coords($img)
$iW = 500
$iH = 300
$gui = GuiCreate("Dr House", $iW, $iH, 300, 50)
GuiSetBkColor(0x000000)
GUISetOnEvent( -3, "_Exit")
GuiSetState()
_GDIPlus_Startup()
$hGraphic = _GDIPlus_GraphicsCreateFromHWND($gui)
$hMatrix = _GDIPlus_MatrixCreate()
$hBitmap = _GDIPlus_BitmapCreateFromGraphics($iW*3, $iH, $hGraphic)
$hBackbuffer = _GDIPlus_ImageGetGraphicsContext($hBitmap)
_GDIPlus_GraphicsSetSmoothingMode($hBackbuffer, 2)
_GDIPlus_GraphicsClear($hBackbuffer) ;, 0xFFFFFFFF)
$hPen = _GDIPlus_PenCreate(0xFF00FF00, 3)
$k = 0
$horiz = 0
$vert = 100
AdlibRegister("Draw", 100)
While Sleep(10000)
WEnd
;-----------------------------------------------
Func Draw()
_GDIPlus_GraphicsClear($hBackbuffer)
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) >=3*$width 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 _Coords($hBitmap1)
_GDIPlus_Startup()
$hImage = _GDIPlus_BitmapCreateFromHBITMAP ($hBitmap1)
$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 ")
Global $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
;_ArrayDisplay($aTemp)
For $y = 0 To UBound($aTemp)-1 ; 192
$pix[$x][$y] = $aTemp[$y]
Next
Next
_WinAPI_DeleteObject($hBmp)
_GDIPlus_ImageDispose($hImage)
_GDIPlus_Shutdown()
EndIf
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
Func Load_BMP_From_Mem($bImage, $hHBITMAP = False)
If Not IsBinary($bImage) Then Return SetError(1, 0, 0)
Local $declared = True
If Not $ghGDIPDll Then
_GDIPlus_Startup()
$declared = False
EndIf
Local Const $memBitmap = Binary($bImage) ;load image saved in variable (memory) and convert it to binary
Local Const $len = BinaryLen($memBitmap) ;get length of image
Local Const $hData = _MemGlobalAlloc($len, $GMEM_MOVEABLE) ;allocates movable memory ($GMEM_MOVEABLE = 0x0002)
Local Const $pData = _MemGlobalLock($hData) ;translate the handle into a pointer
Local $tMem = DllStructCreate("byte[" & $len & "]", $pData) ;create struct
DllStructSetData($tMem, 1, $memBitmap) ;fill struct with image data
_MemGlobalUnlock($hData) ;decrements the lock count associated with a memory object that was allocated with GMEM_MOVEABLE
Local $hStream = DllCall("ole32.dll", "int", "CreateStreamOnHGlobal", "handle", $pData, "int", True, "ptr*", 0)
$hStream = $hStream[3]
Local $hBitmap = DllCall($ghGDIPDll, "uint", "GdipCreateBitmapFromStream", "ptr", $hStream, "int*", 0) ;Creates a Bitmap object based on an IStream COM interface
$hBitmap = $hBitmap[2]
Local Const $tVARIANT = DllStructCreate("word vt;word r1;word r2;word r3;ptr data; ptr")
DllCall("oleaut32.dll", "long", "DispCallFunc", "ptr", $hStream, "dword", 8 + 8 * @AutoItX64, _
"dword", 4, "dword", 23, "dword", 0, "ptr", 0, "ptr", 0, "ptr", DllStructGetPtr($tVARIANT)) ;release memory from $hStream to avoid memory leak
$tMem = 0
If $hHBITMAP Then
Local Const $hHBmp = _GDIPlus_BitmapCreateHBITMAPFromBitmap($hBitmap)
_GDIPlus_BitmapDispose($hBitmap)
If Not $declared Then _GDIPlus_Shutdown()
Return $hHBmp
EndIf
If Not $declared Then _GDIPlus_Shutdown()
Return $hBitmap
EndFunc ;==>Load_BMP_From_Mem
Func ecgNB_bmp()
Local _
$FileBin = "0x424D3E0C0000000000003E000000280000007B000000C00000000100010000000000000C0000330B0000330B0000020000000200000000000000FFFFFF000000000000000000000000000000000000000000000006000000000000000000000000000000060000000000000000000000000000000F000000000000000000000000000000090000000000000000000000000000000900000000000000000000000000000009000000000000000000000000000000090000000000000000000000000000000900000000000000000000000000000009800000000000000000000000000000098000000000000000000000000000000980000000000000000000"
$FileBin &= "00000000001880000000000000000000000000000018800000000000000000000000000000188000000000000000000000000000001080000000000000000000000000000010800000000000000000000000000000108000000000000000000000000000001080000000000000000100000000000010800000000000000000000000000000108000000000000000000000000000001080000000000000000000000000000010800000000000000000000000000000108000000000000000000000000000001080000000000000000000000000000030C0000000000000000000000000000030C0000000000000000000000000000030C0000000000000000000"
$FileBin &= "000000000020C0000000000000000000000000000020400000000000000000000000000000204000000000000000000000000000002040000000000000000000000000000020400000000000000000000000000000204000000000000000000000000000002040000000000000000000000000000020400000000000000000000000000000204000000000000000000000000000002040000000000000000000000000000020400000000000000000000000000000204000000000000000000000000000002040000000000000000000000000000020400000000000000000000000000000204000000000000000000000000000002040000000000000000000"
$FileBin &= "00000000006040000000000000000000000000000060400000000000000000000000000000404000000000000000000000000000004040000000000000000000000000000040400000000000000000000000000000404000000000000000000000000000004040000000000000000000000000000040600000000000000000000000000000406000000000000000000000000000004060000000000000000000000000000040600000000000000000000000000000402000000000000000000000000000004020000000000000000000000000700040200000000000000000000000007000402000000000000000000000000050004020000000000000000000"
$FileBin &= "00000050004020000000000000000000000000D00040200000000000000000000000009000402000000000000000000000000090004020000000000000000000000000980040300000000000000000000000009800C0100000000000000000000000018800C0100000000000000000FFC0007F0800C01FFFFC0000003FFFE000200080080080000006000000C000000010018008008000000180000180000100100100080080000000C00003000000001801000800800000006000060000000008030008008000000030000C000000000802000800800000001C0038000000000C02000800800000000700E00000000004060008008000000001FF8000000000"
$FileBin &= "040400080080000000000000000000000404000800800000000000000000000006040008008000000000000000000000020C0008008000000000000000000000020800080080000000000000000000000308000800800000000000000000000001180008008000000000000000000000011000080080000000000000000000000190000800800000000000000000000000B0000800800000000000000000000000E000080080000000000000000000000000000C0180000000000000000000000000000C018000000000000000000000000000040180000000000000000000000000000401800000000000000000000000000004018000000000000000000000"
$FileBin &= "00000004010000000000000000000000000000040100000000000000000000000000000401000000000000000000000000000004010000000000000000000000000000040100000000000000000000000000000401000000000000000000000000000004010000000000000000000000000000040100000000000000000000000000000401000000000000000000000000000004010000000000000000000000000000040100000000000000000000000000000401000000000000000000000000000004010000000000000000000000000000040100000000000000000000000000000401000000000000000000000000000004010000000000000000000000"
$FileBin &= "00000004010000000000000000000000000000040100000000000000000000000000000401000000000000000000000000000004010000000000000000000000000000040100000000000000000000000000000403000000000000000000000000000004030000000000000000000000000000040300000000000000000000000000000402000000000000000000000000000004020000000000000000000000000000040200000000000000000000000000000402000000000000000000000000000004020000000000000000000000000000060200000000000000000000000000000602000000000000000000000000000006020000000000000000000000"
$FileBin &= "00000002020000000000000000000000000000020200000000000000000000000000000202000000000000000000000000000002020000000000000000000000000000020200000000000000000000000000000202000000000000000000000000000002020000000000000000000000000000020200000000000000000000000000000202000000000000000000000000000002020000000000000000000000000000020200000000000000000000000000000202000000000000000000000000000002060000000000000000000000000000020600000000000000000000000000000206000000000000000000000000000002060000000000000000000000"
$FileBin &= "00000002040000000000000000000000000000020400000000000000000000000000000204000000000000000000000000000002040000000000000000000000000000020400000000000000000000000000000204000000000000000000000000000002040000000000000000000000000000020400000000000000000000000000000204000000000000000000000000000002040000000000000000000000000000020400000000000000000000000000000204000000000000000000000000000002040000000000000000000000000000030400000000000000000000000000000304000000000000000000000000000003040000000000000000000000"
$FileBin &= "000000010C0000000000000000000000000000010C0000000000000000000000000000010C0000000000000000000000000000010C0000000000000000000000000000010800000000000000000000000000000108000000000000000000000000000001080000000000000000000000000000010800000000000000000000000000000108000000000000000000000000000001080000000000000000000000000000010800000000000000000000000000000108000000000000000000000000000001080000000000000000000000000000010800000000000000000000000000000108000000000000000000000000000001080000000000000000000000"
$FileBin &= "0000000118000000000000000000000000000001180000000000000000000000000000019800000000000000000000000000000198000000000000000000000000000001980000000000000000000000000000009000000000000000000000000000000090000000000000000000000000000000900000000000000000000000000000009000000000000000000000000000000090000000000000000000000000000000900000000000000000000000000000009000000000000000000000000000000090000000000000000000000000000000B0000000000000000000000000000000E0000000000000000000000000000000600000000000000000000000"
$FileBin &= "000000006000000000000000000000000000000060000000000000000000000000000000000000000000000000000000000000000000000000000000000000"
Return Binary($FileBin)
EndFunc