TanerJames Posted July 16, 2010 Share Posted July 16, 2010 Hi, My problem, animated GIF. I want to animated GIF for GUI & from resource. Example 1: use: resources.au3 expandcollapse popup#Region ;**** Directives created by AutoIt3Wrapper_GUI **** #AutoIt3Wrapper_Res_File_Add=loading.gif, rt_rcdata, ANI_GIF_1 #EndRegion ;**** Directives created by AutoIt3Wrapper_GUI **** #include <GUIConstantsEx.au3> #include <WindowsConstants.au3> #include <GDIPlus.au3> #include <Misc.au3> #include <WinAPI.au3> #include <Timers.au3> #include "resources.au3" HotKeySet("{Esc}", "Quit") Global $GIF_TimerID, $hImage, $IMG_Ctrl, $GFC, $GFDC, $pDimensionIDs, $tDL Global $Pause, $i = 0 $hGUI = GUICreate("GIF Animation", 300, 200) $IMG_Ctrl = GUICtrlCreateLabel("", 10, 10, 10, 10) ; For Drawing GUICtrlSetBkColor(-1, $GUI_BKCOLOR_TRANSPARENT) ; Transparency's working GUISetState(@SW_SHOW) GifInit() ; Start Animation: instead of using the time delays between frames given from GIF we use 100ms for simplicity _Timer_SetTimer($hGUI, 100, "_Draw_Timer") While 1 If GUIGetMsg() = -3 Then Quit() WEnd Func _Draw_Timer($hWnd, $Msg, $iIDTimer, $dwTime) If Not $Pause Then If $i = $GFC Then $i = 0 ; If $i = the frame count then reset $i to 0 GifDrawFrame($i) $i += 1 EndIf EndFunc Func Quit() _Timer_KillAllTimers($hGUI) _GDIPlus_ImageDispose($hImage) _GDIPlus_Shutdown() HotKeySet("{Esc}") Exit EndFunc Func GifInit() _GDIPlus_Startup() ; Load your animated GIF (from file or from resources) ;~ $hImage = _GDIPlus_ImageLoadFromFile(@ScriptDir & "\gif-Green-UFO.gif") $hImage = _ResourceGetAsImage("ANI_GIF_1") $tDL = DllStructCreate($tagGUID) ; Create a struct to hold the GUID. $pDimensionIDs = DllStructGetPtr($tDL) ; Get a pointer to the GUID struct. ; Get the FrameDimensionsCount of the loaded gif $GFDC = DllCall($ghGDIPDll, "int", "GdipImageGetFrameDimensionsCount", "ptr", $hImage, "int*", 0) ; Get the FrameDimensionsList , which fills the GUID struct by passing the GUID pointer and the FrameDimensionsCount. DllCall($ghGDIPDll, "int", "GdipImageGetFrameDimensionsList", "ptr", $hImage, "ptr", $pDimensionIDs, "int", $GFDC[2]) ; Get the FrameCount of the loaded gif by passing the GUID pointer $GFC = DllCall($ghGDIPDll, "int", "GdipImageGetFrameCount", "int", $hImage, "ptr", $pDimensionIDs, "int*", 0) $GFC = $GFC[3] EndFunc Func GifDrawFrame($i) ; Select the ActiveFrame in the loaded GIF by telling it. The frame starts at 0 ($i) DllCall($ghGDIPDll, "int", "GdipImageSelectActiveFrame", "ptr", $hImage, "ptr", $pDimensionIDs, "int", $i) ; get current frame from GIF and draw it on the control $hBitmap = _GDIPlus_BitmapCreateHBITMAPFromBitmap($hImage) _SetBitmapToCtrl($IMG_Ctrl, $hBitmap) _WinAPI_DeleteObject($hBitmap) EndFunc problem: Animated GIF not correctly show. (maybe not frame refresh) ------------------------------- example 2: use: GIFAnimation.au3 expandcollapse popup#include <WindowsConstants.au3> #include "GIFAnimation.au3" #include "resources.au3" Opt("MustDeclareVars", 1) Global $hGui = GUICreate("example resource ani gif - 2", 400, 65) Global $aGIFArrayOfIconHandles Global $hGIFThread Global $iGIFTransparent Global $tFrameCurrent Global $pic1 Global $hGIF = _GUICtrlCreateGIF("loading.gif", 10, 10, $aGIFArrayOfIconHandles, $hGIFThread, $iGIFTransparent, $tFrameCurrent) GUIRegisterMsg(15, "_Refresh"); WM_PAINT GUISetState() While 1 Switch GUIGetMsg() Case - 3 Exit EndSwitch WEnd Func _Refresh($hWnd, $iMsg, $wParam, $lParam) #forceref $hWnd, $iMsg, $wParam, $lParam _RefreshGIF($hGIF, $aGIFArrayOfIconHandles, $hGIFThread, $iGIFTransparent, $tFrameCurrent) EndFunc ;==>_Refresh GIF correctly show but problem GIFAnimation.au3 not support resource. Please check to attachment files. Thanks Ps: sorry bad english.GIF example.zip Link to comment Share on other sites More sharing options...
trancexx Posted July 16, 2010 Share Posted July 16, 2010 (edited) If you want to use GIFAnimation.au3 with resources then you could use resources.au3 to get raw binary data of it and pass that to _CreateArrayHIconsFromGIFBinaryImage() function.ptrex's GifAnimations_Form_Binary.au3 from the same thread. It can be nicely wrapped. Edited July 16, 2010 by trancexx ♡♡♡ . eMyvnE Link to comment Share on other sites More sharing options...
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