Jump to content

GIF Animation


trancexx
 Share

Recommended Posts

  • 4 weeks later...

How to release the resources from the GIF animation properly to avoid memory leak when calling animation several times from same application?

Because each time I'm calling the animation it will not release approx. 8 mb of memory.

I used:

_GIF_DeleteGIF($hAnim)

_GIF_ExitAnimation($hAnim)

whereas $hAnim is the handle to the animated GIF!

Br,

UEZ

Edited by UEZ

Please don't send me any personal message and ask for support! I will not reply!

Selection of finest graphical examples at Codepen.io

The own fart smells best!
Her 'sikim hıyar' diyene bir avuç tuz alıp koşma!
¯\_(ツ)_/¯  ٩(●̮̮̃•̃)۶ ٩(-̮̮̃-̃)۶ૐ

Link to comment
Share on other sites

How to release the resources from the GIF animation properly to avoid memory leak when calling animation several times from same application?

Because each time I'm calling the animation it will not release approx. 8 mb of memory.

I used:

_GIF_DeleteGIF($hAnim)

_GIF_ExitAnimation($hAnim)

whereas $hAnim is the handle to the animated GIF!

Br,

UEZ

It's related to stream object used for inline/variable images. I'm not releasing it. If you have the latest AutoIt beta then you can add this line:

; Call Release on stream object
    DllCallAddress("dword", DllStructGetData(DllStructCreate("ptr QueryInterface; ptr AddRef; ptr Release;", DllStructGetData(DllStructCreate("ptr pObj;", $pStream), "pObj")), "Release"), "ptr", $pStream)

... before returning $pBitmap in _GIF_CreateBitmapFromBinaryImage.

edit: and $pStream should now be:

Local $pStream = _GIF_CreateStreamOnHGlobal($pMemory, 0)

Sorry for late reply. I'll rewrite this UDF when new AutoIt release happens to handle streams as they should be (as objects).

Edited by trancexx

♡♡♡

.

eMyvnE

Link to comment
Share on other sites

Yes, it is working with the beta version - the memory is released properly when calling the animation again. :graduated:

No way to get it work without using DllCallAddress()? Because beta is beta and not final.

THANKS!

Br,

UEZ

Edited by UEZ

Please don't send me any personal message and ask for support! I will not reply!

Selection of finest graphical examples at Codepen.io

The own fart smells best!
Her 'sikim hıyar' diyene bir avuç tuz alıp koşma!
¯\_(ツ)_/¯  ٩(●̮̮̃•̃)۶ ٩(-̮̮̃-̃)۶ૐ

Link to comment
Share on other sites

This is also working:

; Call Release on stream object
Local $pStream = _GIF_CreateStreamOnHGlobal($pMemory, 0)
;~     DllCallAddress("dword", DllStructGetData(DllStructCreate("ptr QueryInterface; ptr AddRef; ptr Release;", DllStructGetData(DllStructCreate("ptr pObj;", $pStream), "pObj")), "Release"), "ptr", $pStream)
    Local $tVARIANT = DllStructCreate("word vt;word r1;word r2;word r3;ptr data; ptr")
    DllCall("oleaut32.dll", "long", "DispCallFunc", "ptr", $pStream, "dword", 8 + 8 * @AutoItX64, _
  "dword", 4, "dword", 23, "dword", 0, "ptr", 0, "ptr", 0, "ptr", DllStructGetPtr($tVARIANT))

Code by ProgAndy!

Br,

UEZ

Please don't send me any personal message and ask for support! I will not reply!

Selection of finest graphical examples at Codepen.io

The own fart smells best!
Her 'sikim hıyar' diyene bir avuç tuz alıp koşma!
¯\_(ツ)_/¯  ٩(●̮̮̃•̃)۶ ٩(-̮̮̃-̃)۶ૐ

Link to comment
Share on other sites

No way to get it work without using DllCallAddress()? Because beta is beta and not final.

That's what I thought too :graduated:, thanks to you and ProgAndy for another solution... btw, the UDF looks really nice too ;)!
Link to comment
Share on other sites

Both of those work for me. Are you sure you are using the function right?

#include <WindowsConstants.au3>
#include "GIFAnimation.au3"
 
Opt("GUICloseOnESC", 1); ESC to exit
Opt("MustDeclareVars", 1)
 
Global $bGif = InetRead("http://k.minus.com/i8VVTsnKNtfHo.gif")
Global $aGIFDimension = _GIF_GetDimension($bGif)
Global $hGui = GUICreate("GIF Animation", 4 * $aGIFDimension[0], 4 * $aGIFDimension[1], -1, -1, $WS_POPUP, $WS_EX_TOPMOST)
 
Global $hGIF = _GUICtrlCreateGIF($bGif , "", 10, 10, 4 * $aGIFDimension[0], 4 * $aGIFDimension[1])
GUICtrlSetTip($hGIF, "Esc to Exit...")
GUICtrlSetPos($hGIF, 0, 0)
GUISetState()
 
While 1
    Switch GUIGetMsg()
      Case -3
       Exit
    EndSwitch
WEnd
Edited by trancexx

♡♡♡

.

eMyvnE

Link to comment
Share on other sites

Both of those work for me. Are you sure you are using the function right?

I used the example code of post #1

Then I found some types of gif not to be shown.

The following gif could be shown on my computer

http://min.us/mbn1rs4ZOm

-------------------------

System: WinXP-SP3

Link to comment
Share on other sites

I used the example code of post #1

Then I found some types of gif not to be shown.

The following gif could be shown on my computer

http://min.us/mbn1rs4ZOm

-------------------------

System: WinXP-SP3

This works for you?

#include "GIFAnimation.au3"
 
Global $hGUI = GUICreate("Example", 500, 500)
Global $hImage = _GUICtrlCreateGIF(_Img(), "", 100, 100, Default, Default)
GUICtrlSetTip($hImage, "I'm on server")
 
GUISetState()
While 1
    Switch GUIGetMsg()
        Case -3
            Exit
        Case $hImage
            If $hImage Then MsgBox(0, 'Aha!', 'Clicked!', 0, $hGUI)
    EndSwitch
WEnd
 
Func _Img()
    Return InetRead("http://k.minus.com/i1wrAFXCYSSOF.gif")
EndFunc
Edited by trancexx

♡♡♡

.

eMyvnE

Link to comment
Share on other sites

This works for you?

#include "GIFAnimation.au3"
 
Global $hGUI = GUICreate("Example", 500, 500)
Global $hImage = _GUICtrlCreateGIF(_Img(), "", 100, 100, Default, Default)
GUICtrlSetTip($hImage, "I'm on server")
 
GUISetState()
While 1
    Switch GUIGetMsg()
        Case -3
            Exit
        Case $hImage
            If $hImage Then MsgBox(0, 'Aha!', 'Clicked!', 0, $hGUI)
    EndSwitch
WEnd
 
Func _Img()
    Return InetRead("http://k.minus.com/i1wrAFXCYSSOF.gif")
EndFunc

Yeah, it's work fine!

what's different?

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...