arcker Posted October 18, 2007 Posted October 18, 2007 In my last proof of concept script, i attempt to display an animated gif in AutoIt using GDI+but i need to get the delay between framesthe problem is that i've no idea how to translate it in autoithere is the vbcode ReDim mxnFramesDelay(mnFrameCount - 1) CopyMemory mxnFramesDelay(0), ByVal xlpProperties(0).Value, xlpProperties(0).Length Private Declare Sub CopyMemory Lib "kernel32" Alias _ "RtlMoveMemory" (pDst As Any, pSrc As Any, _ ByVal ByteLen As Long)the whole source code in vb could be found here Linkfor those who are interested, here is my current work. The animation works but the delay are not respected. You have to replace the point to gif to point yours.expandcollapse popup=============================================================================================================================== ; Description ...: Shows how to animate a gif using GDI+ ; Author ........: Yoan Roblet (Arcker) using Auto3Lib ; Notes .........: You must specify your gif path ; Credits .......: ; =============================================================================================================================== #include<A3LGdiPlus.au3> Global Const $tagColorPalette = "uint Flags;uint Count;ptr Entries[4]" Global Const $tagPropertyItem = "short PROPID;long id;int lenght;ptr value" Global Const $PropertyTagFrameDelay = 0x5100 _GDIP_Startup () Const $lFrameDimensionTime = "{6AEDBD6D-3FB5-418A-83A6-7F45229DC872}" Dim $gif = _GDIP_EncodersGetCLSID ("gif") ConsoleWrite($gif & @CRLF) $mhImage = _GDIP_ImageLoadFromFile (@ScriptDir & "\peer.gif") ;ConsoleWrite("$mhImage " & $mhImage & @CRLF) $mnFrameCount = _GDIP_ImageGetFrameCount($mhImage, $lFrameDimensionTime) ConsoleWrite("$mnFrameCount " & $mnFrameCount & @CRLF) ;$nSize = _GDIP_GetImagePaletteSize($mhImage) ;ConsoleWrite("$nSize " & $nSize & @CRLF) ;Dim $tColorPalette = DllStructCreate($tagColorPalette) ;$lpPal = _GDIP_GetImagePalette($mhImage, $tColorPalette, $nSize) ;ConsoleWrite("$lpPal " & $lpPal & @CRLF) $propSize = _GDIP_GetPropertyItemSize($mhImage, $PropertyTagFrameDelay) ConsoleWrite("Prop Size => " & $propSize & @CRLF) ;ReDim xlpProperties(nSize / 14) ;# 14 => taille d'une property Dim $tPropertyItem = DllStructCreate($tagPropertyItem) _GDIP_GetPropertyItem($mhImage, $PropertyTagFrameDelay, $propSize, $tPropertyItem) ConsoleWrite("Lenght => " & DllStructGetData($tPropertyItem,"value") & @crlf) #region -- vb code -- ; ReDim mxnFramesDelay(mnFrameCount - 1) ; CopyMemory mxnFramesDelay(0), ByVal xlpProperties(0).Value, xlpProperties(0).Length #endregion Dim $mnFrameDelay[$mnFrameCount - 1] ;ConsoleWrite("ok") $b = DLLCall("kernel32.dll", "none", "RtlMoveMemory", "wchar", $mnFrameDelay, "ptr", DllStructGetData($tPropertyItem,"value"), "int", DllStructGetData($tPropertyItem,"lenght")) ;ConsoleWrite($B) _GDIP_ImageSelectActiveFrame($mhImage, $lFrameDimensionTime, 10) Global $hGui = GUICreate("") GUISetState() $hGraphic = _GDIP_GraphicsCreateFromHWND ($hGui) ConsoleWrite("ok") _GDIP_GraphicsDrawImage ($hGraphic, $mhImage, 0, 0) For $Frame = 0 To $mnFrameCount - 1 _GDIP_ImageSelectActiveFrame($mhImage, $lFrameDimensionTime, $Frame) _GDIP_GraphicsDrawImage ($hGraphic, $mhImage, 0, 0) Sleep(100) Next ;_GDIP_GraphicsDrawImage($hGraphic, $mhImage, 0, 0) While GUIGetMsg() <> $GUI_EVENT_CLOSE WEnd _GDIP_ImageDispose ($mhImage) _GDIP_Shutdown () Exit Func _GDIP_ImageGetFrameDimensionsCount($hImage) Local $aResult $aResult = DllCall($ghA3LGDIPDll, "int", "GdipImageGetFrameDimensionsCount", "hwnd", $hImage, "int_ptr", 0) _Lib_Check ("_GDIP_ImageGetFrameDimensionsCount ", $aResult[0] <> 0, 3, True) Return $aResult[2] EndFunc ;==>_GDIP_ImageGetFrameDimensionsCount Func _GDIP_ImageGetFrameDimensionsList($hImage, $sFrameCount) Local $aResult, $tFrame $tFrame = DllStructCreate("long") $aResult = DllCall($ghA3LGDIPDll, "int", "GdipImageGetFrameDimensionsList", "hwnd", $hImage, "ptr", DllStructGetPtr($tFrame), "int", $sFrameCount) ConsoleWrite("TFrame " & DllStructGetData($tFrame, 1) & @CRLF) _Lib_Check ("_GDIP_ImageGetFrameDimensionsList ", $aResult[0] <> 0, 3, True) Return DllStructGetData($tFrame, 1) EndFunc ;==>_GDIP_ImageGetFrameDimensionsList Func _GDIP_ImageSelectActiveFrame(ByRef $hImage, $sEncoder, $IndexFrame) ConsoleWrite($hImage & @TAB & $sEncoder & @TAB & $IndexFrame & @CRLF) Local $aResult, $pGUID, $tGUID $tGUID = _API_GUIDFromString ($sEncoder) $pGUID = DllStructGetPtr($tGUID) ConsoleWrite("hImage 0x" & Hex($hImage) & @CRLF) $aResult = DllCall($ghA3LGDIPDll, "int", "GdipImageSelectActiveFrame", "hwnd", $hImage, "ptr", $pGUID, "int", $IndexFrame) _Lib_Check ("_GDIP_ImageSelectActiveFrame ", $aResult[0] <> 0, 3, True) ;ConsoleWrite(_API_GetLastError() & @crlf) ConsoleWrite("hImage " & $aResult[1] & @CRLF) Return $aResult[3] EndFunc ;==>_GDIP_ImageSelectActiveFrame Func _GDIP_GetPropertyItem($hImage, $propId, $propSize, ByRef $tPropertyItem) Local $aResult $aResult = DllCall($ghA3LGDIPDll, "int", "GdipGetPropertyItem", "hwnd", $hImage, "int", $propId, "int", $propSize, "ptr", DllStructGetPtr($tPropertyItem)) _Lib_Check ("_GDIP_GetPropertyItem ", $aResult[0] <> 0, 4, True) Return $aResult[4] EndFunc ;==>_GDIP_GetPropertyItem Func _GDIP_GetPropertyItemSize($hImage, $propId) Local $aResult $aResult = DllCall($ghA3LGDIPDll, "int", "GdipGetPropertyItemSize", "hwnd", $hImage, "int", $propId, "int_ptr", 0) _Lib_Check ("_GDIP_GetPropertyItemSize ", $aResult[0] <> 0, 3, True) Return $aResult[3] EndFunc ;==>_GDIP_GetPropertyItemSize Func _GDIP_ImageGetFrameCount($hImage, $sEncoder) Local $aResult, $pGUID, $tGUID $tGUID = _API_GUIDFromString ($sEncoder) $pGUID = DllStructGetPtr($tGUID) $aResult = DllCall($ghA3LGDIPDll, "int", "GdipImageGetFrameCount", "hwnd", $hImage, "ptr", $pGUID, "int_ptr", 0) _Lib_Check ("_GDIP_ImageGetFrameCount ", $aResult[0] <> 0, 2, True) Return $aResult[3] EndFunc ;==>_GDIP_ImageGetFrameCount Func _GDIP_GetImagePaletteSize($hImage) Local $aResult $aResult = DllCall($ghA3LGDIPDll, "int", "GdipGetImagePaletteSize", "hwnd", $hImage, "int_ptr", 0) _Lib_Check ("_GDIP_GetImagePaletteSize ", $aResult[0] <> 0, 3, True) Return $aResult[2] EndFunc ;==>_GDIP_GetImagePaletteSize Func _GDIP_GetImagePalette($hImage, ByRef $ColorPalette, $Size) Local $aResult $aResult = DllCall($ghA3LGDIPDll, "int", "GdipGetImagePalette", "hwnd", $hImage, "ptr", DllStructGetPtr($ColorPalette), "int", $Size) _Lib_Check ("_GDIP_GetImagePalette ", $aResult[0] <> 0, 3, True) Return $aResult[2] EndFunc ;==>_GDIP_GetImagePalette -- Arck System _ Soon -- Ideas make everything "La critique est facile, l'art est difficile" Projects :[list] [*]Au3Service : Run your exe as service V3 / Updated 29/07/2013 Get it Here [/list]
GaryFrost Posted October 18, 2007 Posted October 18, 2007 _MemMoveMemory in the Beta help SciTE for AutoItDirections for Submitting Standard UDFs Don't argue with an idiot; people watching may not be able to tell the difference.
arcker Posted October 19, 2007 Author Posted October 19, 2007 thanx, but even with this function i don't understand those byte array. When i use this function, autoit just crash. -- Arck System _ Soon -- Ideas make everything "La critique est facile, l'art est difficile" Projects :[list] [*]Au3Service : Run your exe as service V3 / Updated 29/07/2013 Get it Here [/list]
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now