AnimatedGIFSprite
Re: AnimatedGIFSprite
Can someone check with my small tool if on macOS the PB GIFDecoder returns correct results for the FrameDelay?
Re: AnimatedGIFSprite
This Mac is crazy, and very limited for use with PB... I removed the Invisibility Flag on the Window, trying to figure why the image become only a black frame and why I don't see the real frame with the dog. UAU...: - The Mac completedly Frozed!!! I had to cold boot it from Power button. It was a completely crash out, no ESC, no Task Kill, no Force Quit, nothing... Power-OFF, Power-ON.
And my Windows machine is not home now... BUAAaaa!
And my Windows machine is not home now... BUAAaaa!
Re: AnimatedGIFSprite
Well, I'm getting Zero, but most animated gifs have a zero-delay! I'll re-check!infratec wrote: Sun Jan 22, 2023 12:33 pm Can someone check with my small tool if on macOS the PB GIFDecoder returns correct results for the FrameDelay?
Re: AnimatedGIFSprite
On Windows:
So you see only a black area.
If FrameDelay = 0, the code never draws the image on the sprite.animated-dog-image-0175.gif
Size: 145x72
Frames: 7
FrameDelay: 100ms
So you see only a black area.
Re: AnimatedGIFSprite
You have to check every frame for delays.
Very quick and fast change on your small tool and I get different values, because the first frame seems to be the one considered when you check the ImageDelay, but after that you get different values.
I've looped 20 times, but we can change the 20 to Number of Frames!
With the next code (yours with small changes), I got this answer:
"animated-dog-image-0175.gif
Size: 145x72
Frames: 7
FrameDelay: 0ms , 100 , 100 , 100 , 100 , 100 , 100 , 100 , 100 , 100 , 100 , 100 , 100 , 100 , 100 , 100 , 100 , 100 , 100 , 100 , 100 , 100ms"
NOTE: With 20 times, it repeats the last value until loop ends!
Hope it helps!
Very quick and fast change on your small tool and I get different values, because the first frame seems to be the one considered when you check the ImageDelay, but after that you get different values.
I've looped 20 times, but we can change the 20 to Number of Frames!
With the next code (yours with small changes), I got this answer:
"animated-dog-image-0175.gif
Size: 145x72
Frames: 7
FrameDelay: 0ms , 100 , 100 , 100 , 100 , 100 , 100 , 100 , 100 , 100 , 100 , 100 , 100 , 100 , 100 , 100 , 100 , 100 , 100 , 100 , 100 , 100ms"
NOTE: With 20 times, it repeats the last value until loop ends!
Hope it helps!
Code: Select all
EnableExplicit
Define Filename$, Message$, X
UseGIFImageDecoder()
Filename$ = OpenFileRequester("Choose an animated GIF", "", "GIF|*.gif", 0)
If Filename$
If LoadImage(0, Filename$)
Message$ = GetFilePart(Filename$) + #LF$ + #LF$
Message$ + "Size: " + Str(ImageWidth(0)) + "x" + Str(ImageHeight(0)) + #LF$
Message$ + "Frames: " + Str(ImageFrameCount(0)) + #LF$
Message$ + "FrameDelay: " + Str(GetImageFrameDelay(x)) + "ms"
For X=0 To ImageFrameCount(0)
SetImageFrame(0,X)
Message$ + " , " + Str(GetImageFrameDelay(0))
Next X
Message$ + "ms"
MessageRequester("GIF Info", Message$)
FreeImage(0)
Else
MessageRequester("Error", "Error loading GIF" + #LF$ + #LF$ + Filename$)
EndIf
EndIf
Last edited by Kamarro on Sun Jan 22, 2023 1:57 pm, edited 2 times in total.
Re: AnimatedGIFSprite
It looks that on Windows you read the Last Frame and on Mac I read the First Frame!!!
I changed the last code of yours to FrameCount instead of 20.
The result is now correct:
I changed the last code of yours to FrameCount instead of 20.
The result is now correct:
animated-dog-image-0175.gif
Size: 145x72
Frames: 7
FrameDelay: 0ms , 100 , 100 , 100 , 100 , 100 , 100 , 100 , 100ms
Re: AnimatedGIFSprite
you read that the file has 7 frames.
And my code shows only one FrameDelay.
You are showing 9 FrameDelays

And my code shows only one FrameDelay.
You are showing 9 FrameDelays



Re: AnimatedGIFSprite
Code: Select all
*AnimatedGIFSprite = AddMapElement(AnimatedGIFSprite\GIFInfoMap(), Str(Sprite))
*AnimatedGIFSprite\OrgImage = Image
*AnimatedGIFSprite\Sprite = Sprite
*AnimatedGIFSprite\Frames = ImageFrameCount(Image)
*AnimatedGIFSprite\FrameDelay = GetImageFrameDelay(Image)
If *AnimatedGIFSprite\FrameDelay = 0 : *AnimatedGIFSprite\FrameDelay = 1 : EndIf
I just changed the last line; it was an added line, not a real change!
Re: AnimatedGIFSprite
With this changes, I get 8 values, like if the image as one more frame considered the EndGif or something like that.
And now I don't have the Zero
And now I don't have the Zero
animated-dog-image-0175.gif
Size: 145x72
Frames: 7
FrameDelay: 100 - 100 - 100 - 100 - 100 - 100 - 100 - 100 - ms
Code: Select all
EnableExplicit
Define Filename$, Message$, X
UseGIFImageDecoder()
Filename$ = OpenFileRequester("Choose an animated GIF", "", "GIF|*.gif", 0)
If Filename$
If LoadImage(0, Filename$)
Message$ = GetFilePart(Filename$) + #LF$ + #LF$
Message$ + "Size: " + Str(ImageWidth(0)) + "x" + Str(ImageHeight(0)) + #LF$
Message$ + "Frames: " + Str(ImageFrameCount(0)) + #LF$
Message$ + "FrameDelay: "
For X=0 To ImageFrameCount(0)
SetImageFrame(0,X)
Message$ + Str(GetImageFrameDelay(0)) + " - "
Next X
Message$ + "ms"
MessageRequester("GIF Info", Message$)
FreeImage(0)
Else
MessageRequester("Error", "Error loading GIF" + #LF$ + #LF$ + Filename$)
EndIf
EndIf
Re: AnimatedGIFSprite
Yur modification is still wrong.
You need:
Since the index starts from 0
You need:
Code: Select all
For X=0 To ImageFrameCount(0) - 1
Re: AnimatedGIFSprite
I changed the code in the first post.
Now it reflects that each frame can have its own delay.
Now it reflects that each frame can have its own delay.
Re: AnimatedGIFSprite
This Mac is crazy... If I read the Frame Delay of the image it reads 0, but if I read the frame 0, it says 100. It's like if he couldn't read the frame delay without setting the frame, or if there was a -1 frame, before frame 0.
I believe it's a small incompatibility with my MacOS, or something else. I tested with one of my big GIfs, with 343 frames, and it happens the same!
Crazy thing with FrameCount!!!
I believe it's a small incompatibility with my MacOS, or something else. I tested with one of my big GIfs, with 343 frames, and it happens the same!
Crazy thing with FrameCount!!!
Re: AnimatedGIFSprite
Of course... stupid guy.... If frames 7, starting on 0... YES!infratec wrote: Sun Jan 22, 2023 2:12 pm Yur modification is still wrong.
You need:Since the index starts from 0Code: Select all
For X=0 To ImageFrameCount(0) - 1
Re: AnimatedGIFSprite
Changed the code from first post:
Now the first frame is shown and then wait the delay befor the next frame is shown.
Also the different behaviour from windows and macOS is solved by first set the (first) frame
before getting the frame delay.
Now the first frame is shown and then wait the delay befor the next frame is shown.
Also the different behaviour from windows and macOS is solved by first set the (first) frame
before getting the frame delay.
Re: AnimatedGIFSprite
Yes, it's perfect now, even on a very old Mac... Wonderful work, man!
I had to do this, to test this things on a lot of GIFs with different sizes, frames and delays... It's completely working fine, thanks to your Small Tool, with just a little bit of repeatable options. I am talking about the code at the end of this Reply. Thanks.
Now, I'm cheking if I can use something like your procedures on my game, but I believe that it will be slower than I wish, but I can try it. Problem is that I have gifs, like this one:
Thanks a lot for your help.
I had to do this, to test this things on a lot of GIFs with different sizes, frames and delays... It's completely working fine, thanks to your Small Tool, with just a little bit of repeatable options. I am talking about the code at the end of this Reply. Thanks.
Now, I'm cheking if I can use something like your procedures on my game, but I believe that it will be slower than I wish, but I can try it. Problem is that I have gifs, like this one:
Or this one:ScanLand.gif
Size: 588x440
Frames: 121
FrameDelay: 30 - 30 - 20 - 30 - 30 - 30 - 30 - 30 - 30 - 30 - 20 - 30 - 30 - 30 - 20 - 30 - 30 - 30 - 30 - 30 - 30 - 30 - 30 - 30 - 30 - 30 - 30 - 30 - 30 - 30 - 20 - 30 - 30 - 30 - 30 - 30 - 30 - 30 - 20 - 30 - 30 - 30 - 20 - 30 - 30 - 30 - 30 - 30 - 30 - 30 - 30 - 30 - 30 - 30 - 30 - 30 - 30 - 30 - 30 - 30 - 30 - 30 - 30 - 30 - 30 - 30 - 30 - 30 - 30 - 30 - 30 - 20 - 30 - 30 - 30 - 30 - 30 - 30 - 20 - 30 - 30 - 30 - 30 - 30 - 30 - 30 - 30 - 30 - 40 - 30 - 30 - 30 - 30 - 30 - 30 - 30 - 30 - 30 - 20 - 30 - 30 - 30 - 20 - 30 - 30 - 30 - 30 - 30 - 30 - 30 - 20 - 30 - 30 - 30 - 20 - 30 - 30 - 30 - 30 - 20 - 30ms.
See my problem? And I also have to put Sprites on top of this GIFs while running... Maybe, I'll have to put aside the idea of using Animated Gifs!Radar.gif
Size: 800x600
Frames: 299
FrameDelay: 20 - 20 - 20 - 20 - 20 - 20 - 20 - 20 - 20 - 20 - 20 - 20 - 20 - 20 - 20 - 20 - 20 - 20 - 20 - 20 - 20 - 20 - 20 - 20 - 20 - 20 - 20 - 20 - 20 - 20 - 20 - 20 - 20 - 20 - 20 - 20 - 20 - 20 - 20 - 20 - 20 - 20 - 20 - 20 - 20 - 20 - 20 - 20 - 20 - 20 - 20 - 20 - 20 - 20 - 20 - 20 - 20 - 20 - 20 - 20 - 20 - 20 - 20 - 20 - 20 - 20 - 20 - 20 - 20 - 20 - 20 - 20 - 20 - 20 - 20 - 20 - 20 - 20 - 20 - 20 - 20 - 20 - 20 - 20 - 20 - 20 - 20 - 20 - 20 - 20 - 20 - 20 - 20 - 20 - 20 - 20 - 20 - 20 - 20 - 20 - 20 - 20 - 20 - 20 - 20 - 20 - 20 - 20 - 20 - 20 - 20 - 20 - 20 - 20 - 20 - 20 - 20 - 20 - 20 - 20 - 20 - 20 - 20 - 20 - 20 - 20 - 20 - 20 - 20 - 20 - 20 - 20 - 20 - 20 - 20 - 20 - 20 - 20 - 20 - 20 - 20 - 20 - 20 - 20 - 20 - 20 - 20 - 20 - 20 - 20 - 20 - 20 - 20 - 20 - 20 - 20 - 20 - 20 - 20 - 20 - 20 - 20 - 20 - 20 - 20 - 20 - 20 - 20 - 20 - 20 - 20 - 20 - 20 - 20 - 20 - 20 - 20 - 20 - 20 - 20 - 20 - 20 - 20 - 20 - 20 - 20 - 20 - 20 - 20 - 20 - 20 - 20 - 20 - 20 - 20 - 20 - 20 - 20 - 20 - 20 - 20 - 20 - 20 - 20 - 20 - 20 - 20 - 20 - 20 - 20 - 20 - 20 - 20 - 20 - 20 - 20 - 20 - 20 - 20 - 20 - 20 - 20 - 20 - 20 - 20 - 20 - 20 - 20 - 20 - 20 - 20 - 20 - 20 - 20 - 20 - 20 - 20 - 20 - 20 - 20 - 20 - 20 - 20 - 20 - 20 - 20 - 20 - 20 - 20 - 20 - 20 - 20 - 20 - 20 - 20 - 20 - 20 - 20 - 20 - 20 - 20 - 20 - 20 - 20 - 20 - 20 - 20 - 20 - 20 - 20 - 20 - 20 - 20 - 20 - 20 - 20 - 20 - 20 - 20 - 20 - 20 - 20 - 20 - 20 - 20 - 20 - 20 - 20 - 20 - 20 - 20 - 20 - 20 - 20 - 20 - 20 - 20 - 20 - 20ms.
Thanks a lot for your help.
Code: Select all
EnableExplicit
Define Filename$, Message$, X, FIN
UseGIFImageDecoder()
Repeat
Filename$ = OpenFileRequester("Choose an animated GIF", "", "GIF|*.gif", 0)
If Filename$
If LoadImage(0, Filename$)
Message$ = GetFilePart(Filename$) + #LF$ + #LF$
Message$ + "Size: " + Str(ImageWidth(0)) + "x" + Str(ImageHeight(0)) + #LF$
Message$ + "Frames: " + Str(ImageFrameCount(0)) + #LF$
Message$ + "FrameDelay: "
If MessageRequester("Loop or Not","Use the LOOP?", #PB_MessageRequester_YesNo) = #PB_MessageRequester_Yes
For X=0 To ImageFrameCount(0)-1
SetImageFrame(0,X)
Message$ + Str(GetImageFrameDelay(0))
If X<ImageFrameCount(0)-1 : Message$ + " - " : EndIf
Next X
Message$ + "ms."
Else
Message$ + Str(GetImageFrameDelay(0)) + "ms"
EndIf
MessageRequester("GIF Info", Message$)
FreeImage(0)
Else
MessageRequester("Error", "Error loading GIF" + #LF$ + #LF$ + Filename$)
EndIf
EndIf
If MessageRequester("AGAIN?","Do it again with another image?", #PB_MessageRequester_YesNo) = #PB_MessageRequester_No
FIN=1
Else
FreeImage(#PB_All)
EndIf
Until FIN=1
Last edited by Kamarro on Sun Jan 22, 2023 3:54 pm, edited 1 time in total.