Jump to content

GIF Animation (cached)


Nine
 Share

Recommended Posts

How to restart the Gif from the first frame without recreating the control?I tried the old UDF _guictrlsetgif,but it caused flickering. Is there an idea to restart the gif from any frame we want?In some special cases,I need to restart the gif before the end of the gif ,such as countdown number.

In some other cases,for example,the countdown number is from 15 to 0,What I need is from 10 to 0.So I can start the gif from the sixth frame.

Edited by ling3882688
Link to comment
Share on other sites

@ling3882688  Add this function to your own script, see how it goes...

Func _GUICtrlSetAnimGIF($idPic, $iFrame)
  For $iIdx = 0 To UBound($aGIF_Animation) - 1
    If $aGIF_Animation[$iIdx][0] = $idPic Then
      If $iFrame > $aGIF_Animation[$iIdx][2] Then Return SetError(2, 0, 0)
      $aGIF_Animation[$iIdx][4] = $iFrame
      Return 1
    EndIf
  Next
  Return SetError(1, 0, 0)
EndFunc   ;==>_GUICtrlSetAnimGIF

 

Link to comment
Share on other sites

Is there a Resize parameter?Resize the image(gif/png/jpg/bmp) based on the controlid's dimensions.

I am trying to replace all the other UDFs  using your UDF to creat controls of my GUI.

And could you please help to add a function like _GUICtrlSetGIF()  in order to change the gif file  of a control? If possible support image file path or $hImage.

Thank you so much.

Edited by ling3882688
Link to comment
Share on other sites

Resize (crop) has been discussed previously (see page #2).  GDI+ can resize or clone area most of the images (not going be part of this UDF).  To change gif file, just delete and create a new control.

Link to comment
Share on other sites

@Nine great job !
For the record, the site you indicated on page 2 (ezgif.com) allow to upload images and they create a reworked animated gif that we can download.

Yesterday I tried it and uploaded there :
* bg.png (the background pic 1st, as indicated in their advices)
* counter.gif (the transparent animated gif)

Then they quicky split the animated gif and present you all frames (thumbnails) in case you want to alter the delay of a frame, remove a frame etc... the 1st frame being the background pic whose delay needs to be set to 0 or 1 in the present case iirc)

There were several parameters to indicate before the rework starts, one of them being :

options-for-adding-background.png.4f235868b65688c28f6604bdfdc943ac.png

You probably knew all that, though it could be interesting for a user who'd like to add a background to his animated transparent gif, then download it for his personal use. Here is the final result after downloading the reworked pic (though I did all this much too quickly and didn't read all their advices)

ezgif-1-7df25acc0c.gif.2b95f7ebb68d4a0fcd339877b8c20ac4.gif

Link to comment
Share on other sites

@pixelsearch  The problem in your example is that the whole background is copied to the GIF, while user only want the part of the background where the GIF is located.  This is why I used _GDIPlus_GraphicsDrawImageRectRect to copy only the part of the background that correspond to the occupied space of the GIF.  Hope that makes sense.

Link to comment
Share on other sites

After reviewing different options about an issue with OnEvent GUI, I went with a deletion mark.  I also included a few code optimizations and resolve a possible issue with a stack overflow.

New version available. :)

Edited by Nine
Link to comment
Share on other sites

  • 5 months later...
3 hours ago, Parsix said:

please add Support of Binary as $vSource in _GUICtrlCreateAnimGIF

Why can't you convert your binary to handle ?  I do not see the need for it unless you provide good explanation.

Link to comment
Share on other sites

 

 

#include <GUIConstants.au3>
#include <GDIPlus.au3>
#include "Cached GIF Animation.au3"

OnAutoItExitRegister(_GIF_Animation_Quit)

Local $hGUI = GUICreate("GIF Animation", 800, 600, -1, -1, $WS_POPUP, $WS_EX_CONTROLPARENT)
GUISetState()
_GUICtrlCreateAnimGIF(_BinaryDB(), 100, 100, 100, 100)

Do
Until GUIGetMsg() = $GUI_EVENT_CLOSE


Func _BinaryDB()
    Local $BIN
    
        $BIN &=     'R0lGODlhQABAANUAAAQCBISChMTCxERCROzq7GRmZLSytCQmJNTS1JSSlPT29Hx+fFxeXGxubAwODIyOjMzKzExKTLy+vDw+PNza3Pz+/AQGBISGhERGRPTy9GxqbLS2tCwqLJyenPz6/HRydMzOzNze3P///wAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACH/C05FVFNDQVBFMi4wAwEAAAAh+QQJCQAiACwAAAAAQABAAAAG/kCRcEgsGo/IpHLJbDqf0Kh0Sq1ar9isdsvter/gsHhMLpvP6LR6zW673/C4fE6v2+/wDAUiEEAoGXYVFBKFhoUUHnMVIIeOEiAVcoQSApWXl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sHkLwIhaoRMGQlHoe39t/dZo+33c19b/jeMkw4PkEROgX2WVaAW1ENdoBhByTGRRAAOw=='
    Local $bString = _WinAPI_Base64Decode_BinaryDB($BIN)
    If @error Then Return SetError(1, 0, 0)
    $bString = Binary($bString)
    Return $bString
EndFunc   ;==>_BinaryDB


Func _WinAPI_Base64Decode_BinaryDB($sB64String)
    Local $aCrypt = DllCall("Crypt32.dll", "bool", "CryptStringToBinaryA", "str", $sB64String, "dword", 0, "dword", 1, "ptr", 0, "dword*", 0, "ptr", 0, "ptr", 0)
    If @error Or Not $aCrypt[0] Then Return SetError(1, 0, "")
    Local $bBuffer = DllStructCreate("byte[" & $aCrypt[5] & "]")
    $aCrypt = DllCall("Crypt32.dll", "bool", "CryptStringToBinaryA", "str", $sB64String, "dword", 0, "dword", 1, "struct*", $bBuffer, "dword*", $aCrypt[5], "ptr", 0, "ptr", 0)
    If @error Or Not $aCrypt[0] Then Return SetError(2, 0, "")
    Return DllStructGetData($bBuffer, 1)
EndFunc   ;==>_WinAPI_Base64Decode_BinaryDB

 

Edited by Parsix
Link to comment
Share on other sites

your Code Work with GIF files only.

in _GUICtrlCreateAnimGIF func , $hImage loaded by _GDIPlus_ImageLoadFromFile

$hImage = $bHandle ? $vSource : _GDIPlus_ImageLoadFromFile($vSource)

Resize and fit gif in needed

Edited by Parsix
Link to comment
Share on other sites

7 hours ago, Parsix said:

your Code Work with GIF files only

False.  It works with file and GDI+ handle.  Try this instead :

Local $hImage = _GDIPlus_BitmapCreateFromMemory(_BinaryDB())
_GUICtrlCreateAnimGIF($hImage, 100, 100, 100, 100, -1, -1, True)

 

Link to comment
Share on other sites

3 minutes ago, Nine said:

False.  It works with file and GDI+ handle.  Try this instead :

Local $hImage = _GDIPlus_BitmapCreateFromMemory(_BinaryDB())
_GUICtrlCreateAnimGIF($hImage, 100, 100, 100, 100, -1, -1, True)

 

can be it scaled and fit to control ?

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