Jump to content

GIF Effect


Recommended Posts

Hello

How would I go about making a GIF effect using jpg's in my GUI, my method isn't working so well and the odd time it flashes and how can I update my GIF effect without using sleep.

I know I could be using a real GIF but I want to try and avoid that, I even had to make my own Update function since for some reason GUICtrlSetImage refuses to update my picture control.

#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>

$Includes = @ScriptDir & "\Test\"


$CenL = 0
$CenT = 0
$Nary = GUICreate("Form1", 500, 500)
$Rc = GUICtrlCreatePic($Includes & "Rc_0.jpg", $CenL , $CenT, 280 , 127)
$Ox = GUICtrlCreatePic($Includes & "Ox_0.jpg", $CenL + 15, $CenT + 18, 64, 94)
$Ox = GUICtrlCreatePic($Test , $CenL + 15, $CenT + 18, 64, 94)
GUISetState(@SW_SHOW)

$i = 0
While 1
    $Msg = GUIGetMsg()
    Switch $Msg
        Case $GUI_EVENT_CLOSE
            Exit
    EndSwitch
    If $i = 9 Then $i = 1
    Sleep(500)
    _UpdateImageControl($Ox , $Includes & "Ox_" & $i & ".jpg" , $CenL + 15, $CenT + 18 , 64 , 94)
    $i = $i +1
WEnd

Func _UpdateImageControl($Control , $ImageSource , $ImageX , $ImageY , $ImageWidth , $ImageHeight)
    GUICtrlDelete($Control)
    GUICtrlCreatePic($ImageSource , $ImageX , $ImageY , $ImageWidth , $ImageHeight)
EndFunc
Edited by LithiumLi
Link to comment
Share on other sites

ya.. the screen flashes once with the image and vanishes..

What kind of gif effect do u want? i mean i didn't understand. AutoIT help file clearly mentions, that it doesn't suppport animated gif..

[font="Garamond"]Manjish Naik[/font]Engineer, Global Services - QPSHoneywell Automation India LimitedE-mail - Manjish.Naik@honeywell.com
Link to comment
Share on other sites

AutoIT help file clearly mentions, that it doesn't suppport animated gif..

I know the Autoit help file says it doesn't support animated GIF's but that doesn't mean it's impossible, I would just use _IECreateEmbedded() which could display a animated GIF but thats not what I want.

ya.. the screen flashes once with the image and vanishes..

I was kind of hoping I could get rid of that problem or even mask it, I was sort of hoping there was a way to not delete the control until the other image has taken effect.

What kind of gif effect do u want?

I want a GUI effect that doesn't flicker and may be a better coding style than the one I chose to make.

#cs 
I Think I got an idea could this possibly work, right now I am going to school so I cant test it but what if I had a control behind another control and the one that overlaps the back control is the first part of the so called GIF and when I want to change it Deletes/Hides the first layer.

Hopefully it works.
#CE
#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>

GUICreate("Idea", 250 , 250)
$Pic1 = GUICtrlCreatePic("GIF_2.jpg", 0, 0, 250, 250)
$Pic2 = GUICtrlCreatePic("GIF_1.jpg", 0, 0, 250, 250)
;If I am correct $Pic2 will be overlapping $Pic1 

;GUICtrlDelete($Pic2) If I do this I would have to keep recreating another control so...No!
;GUICtrlSetState($Pic2 , $GUI_HIDE) May be this command will serve more of a purpose 
GUISetState(@SW_SHOW)
$Pic = 1
While 1
    $Msg = GUIGetMsg()
    Switch $Msg
        Case $GUI_EVENT_CLOSE
            Exit
    EndSwitch
    _HideShow($Pic)
WEnd

Func _HideShow($Switch)
    If $Pic = 1 Then
        $Pic = 2
        GUICtrlSetState($Pic1 , $GUI_SHOW)
        GUICtrlSetState($Pic2 , $GUI_HIDE)
    ElseIf $Pic = 2
        $Pic = 1
        GUICtrlSetState($Pic2 , $GUI_SHOW)
        GUICtrlSetState($Pic1 , $GUI_HIDE)
    Else
        Exit
    EndIf
EndFunc
Edited by LithiumLi
Link to comment
Share on other sites

I know the Autoit help file says it doesn't support animated GIF's but that doesn't mean it's impossible, I would just use _IECreateEmbedded() which could display a animated GIF but thats not what I want.

ya.. the screen flashes once with the image and vanishes..

I was kind of hoping I could get rid of that problem or even mask it, I was sort of hoping there was a way to not delete the control until the other image has taken effect.

What kind of gif effect do u want?

I want a GUI effect that doesn't flicker and may be a better coding style than the one I chose to make.

#cs 
I Think I got an idea could this possibly work, right now I am going to school so I cant test it but what if I had a control behind another control and the one that overlaps the back control is the first part of the so called GIF and when I want to change it Deletes/Hides the first layer.

Hopefully it works.
#CE
#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>

GUICreate("Idea", 250 , 250)
$Pic1 = GUICtrlCreatePic("GIF_2.jpg", 0, 0, 250, 250)
$Pic2 = GUICtrlCreatePic("GIF_1.jpg", 0, 0, 250, 250)
;If I am correct $Pic2 will be overlapping $Pic1 

;GUICtrlDelete($Pic2) If I do this I would have to keep recreating another control so...No!
;GUICtrlSetState($Pic2 , $GUI_HIDE) May be this command will serve more of a purpose 
GUISetState(@SW_SHOW)
$Pic = 1
While 1
    $Msg = GUIGetMsg()
    Switch $Msg
        Case $GUI_EVENT_CLOSE
            Exit
    EndSwitch
    _HideShow($Pic)
WEnd

Func _HideShow($Switch)
    If $Pic = 1 Then
        $Pic = 2
        GUICtrlSetState($Pic1 , $GUI_SHOW)
        GUICtrlSetState($Pic2 , $GUI_HIDE)
    ElseIf $Pic = 2
        $Pic = 1
        GUICtrlSetState($Pic2 , $GUI_SHOW)
        GUICtrlSetState($Pic1 , $GUI_HIDE)
    Else
        Exit
    EndIf
EndFunc
If I were you I would do it like this:

GUICreate("", 250, 250)
$BMP1 = "GIF_2.jpg"
$BMP2 = "GIF_1.jpg"
$Pic = GUICtrlCreatePic("", 0, 0, 250, 250)

GUISetState(@SW_SHOW)
$timer = TimerInit()
$x = 0


While 1
    If GUIGetMsg() = -3 Then Exit
    _HideShow()
WEnd



Func _HideShow()
    If Mod(Floor(TimerDiff($timer) / 200), 2) Then
        If $x = 1 Then
            GUICtrlSetImage($Pic, $BMP1)
            $x = 0
        EndIf
    Else
        If Not $x Then
            GUICtrlSetImage($Pic, $BMP2)
            $x = 1
        EndIf
    EndIf
EndFunc

But, I'm not.

♡♡♡

.

eMyvnE

Link to comment
Share on other sites

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...