Help with Animated GIFs...

Just starting out? Need help? Post your questions and find answers here.
User avatar
Kamarro
User
User
Posts: 65
Joined: Thu Mar 19, 2015 7:55 pm
Location: England

Help with Animated GIFs...

Post by Kamarro »

Hello Guys

Hope that you're having a nice 2023.
I'm working on an old project and need to put 2 animated gifs on screen, but since I'm on a Repeat LOOP scene and image is refreshed a few times per second, GIF doesn't animate at all. If I try to use a Delay(3000) to stop program for 3 seconds and allow user to see the animation, of course NOT working at all because all the program stops and GIF do not animate.

Any simple solution for this? Am I doing anything wrong? I'm using OpenScreen and never found a way to use this language without the Repeat LOOP, as I normaly do on other languages, keeping the screen static and changing only texts and images. Is that possible on PB 6.0?

Sorry, now I have 2 questions: one for animated gifs and another for no Repeat solution.
Can you help me?
infratec
Always Here
Always Here
Posts: 7619
Joined: Sun Sep 07, 2008 12:45 pm
Location: Germany

Re: Help with Animated GIFs...

Post by infratec »

It depends on your used code.

How you display gifs on an OpenScreen?
So please provide a small working code which shows your problem.

In general you need also a window event loop and there you can execute the timer events.
User avatar
Kamarro
User
User
Posts: 65
Joined: Thu Mar 19, 2015 7:55 pm
Location: England

Re: Help with Animated GIFs...

Post by Kamarro »

How you display gifs on an OpenScreen?
So please provide a small working code which shows your problem.
Hi, Thanks for your question:

I don't have the code here, but it's easy to answer:

I LoadSprite as I do for any other image. Since I load the GIFDecoder, I DisplayTransparentSprite as I do for my other images, JPEG or GIFs, and everything runs fine, but... and here is the but... after Display Sprite done, the program continues and gets to Until ESC pressed, looping and repeating the main LOOP again and again. This is the problem.

Should I use an independent Thread Task to process the GIF? That will be a Pain in the... because I was expecting to use quite a few of this animated gifs.
Maybe the best solution is to create a DIM with the frames and load each one every time the program loops. Is not a wonderful solution and a bit heavier than desired, but it works fine. I was trying to simplify the code, expecting to see a new DisplayAnimatedSprite or something like that.
There isn't anything like this yet, right?
Bitblazer
Enthusiast
Enthusiast
Posts: 762
Joined: Mon Apr 10, 2017 6:17 pm
Location: Germany
Contact:

Re: Help with Animated GIFs...

Post by Bitblazer »

The quick, dirty but simple way is to use AddWindowTimer and display a frame "on each new event".
infratec
Always Here
Always Here
Posts: 7619
Joined: Sun Sep 07, 2008 12:45 pm
Location: Germany

Re: Help with Animated GIFs...

Post by infratec »

So you are using only OpenScreen() and Sprites.
Animated Gifs ar only implemented for Images and, as I know, not for Sprites,
There is no function called SetSpriteFrame(), only SetImageFrame()

See also help for UseGIFImageDecoder().
LoadSprite() and CatchSprite() does not support multi-frame GIFs.
User avatar
JHPJHP
Addict
Addict
Posts: 2258
Joined: Sat Oct 09, 2010 3:47 am

Re: Help with Animated GIFs...

Post by JHPJHP »

Hi Kamarro,

See Windows Services & Other Stuff\Other_Stuff\AnimatedGIF\MovableSpriteObject.pb
Last edited by JHPJHP on Sat Jan 21, 2023 4:43 pm, edited 1 time in total.

If you're not investing in yourself, you're falling behind.

My PureBasic StuffFREE STUFF, Scripts & Programs.
My PureBasic Forum ➤ Questions, Requests & Comments.
User avatar
Kamarro
User
User
Posts: 65
Joined: Thu Mar 19, 2015 7:55 pm
Location: England

Re: Help with Animated GIFs...

Post by Kamarro »

infratec wrote: Sat Jan 21, 2023 3:38 pm So you are using only OpenScreen() and Sprites.
Animated Gifs ar only implemented for Images and, as I know, not for Sprites,
There is no function called SetSpriteFrame(), only SetImageFrame()

See also help for UseGIFImageDecoder().
LoadSprite() and CatchSprite() does not support multi-frame GIFs.
This was my hope about...
After so many years without touch this PB again, I thought that it could have been added...
Thanks for your Help!
User avatar
Kamarro
User
User
Posts: 65
Joined: Thu Mar 19, 2015 7:55 pm
Location: England

Re: Help with Animated GIFs...

Post by Kamarro »

JHPJHP wrote: Sat Jan 21, 2023 3:59 pm Hi Kamarro,
See Windows Services & Other Stuff\Other_Stuff\AnimatedGIF\MovableSpriteObject.pb
Thanks for your answer and help, but this is almost what I am doing in a simplyfied way.
The hard bone of this is the creation of each frame to display individually, that's what I expected to be able to avoid.

No problem at all. I already acepted the fact that I don't have a static display page and that I need a Repeat Display Loop... This is , in fact, the biggest low point of this language for me. I am used to easier display this, display that without the need of a LOOP.
Since I can't do that, I have to change the programs in accordance with the language.

Thanks a lot.
User avatar
Kamarro
User
User
Posts: 65
Joined: Thu Mar 19, 2015 7:55 pm
Location: England

Re: Help with Animated GIFs...

Post by Kamarro »

What happened to my Replies???

I answered one post with a small quote and a little sample of my exact program and IT Disappeared.

I answered a second reply from another user with a larger example of my program and the post has been deleted? Why???

It was just a small and simple sample of what I am doing, no bad words, no antipathy to anyone, nothing.

What have I done to get my posts deleted?

Is there a reason, I dont't believe that was a bug...
Did you already experienced this situation?
User avatar
netmaestro
PureBasic Bullfrog
PureBasic Bullfrog
Posts: 8451
Joined: Wed Jul 06, 2005 5:42 am
Location: Fort Nelson, BC, Canada

Re: Help with Animated GIFs...

Post by netmaestro »

BERESHEIT
User avatar
Kamarro
User
User
Posts: 65
Joined: Thu Mar 19, 2015 7:55 pm
Location: England

Re: Help with Animated GIFs...

Post by Kamarro »

netmaestro wrote: Sat Jan 21, 2023 4:38 pm This works: viewtopic.php?f=12&t=57656
Thank you but no, it doesn't.
I can not use gadgets. I need to use only OpenScreen and Sprites. Program is big and almost finished. This is a fullscreen game, not an application with windows and things like that.

I already posted the solution that I am using but, for no known reason my two posts with program samples disappeared. Sorry!

Thanks the same!
Bitblazer
Enthusiast
Enthusiast
Posts: 762
Joined: Mon Apr 10, 2017 6:17 pm
Location: Germany
Contact:

Re: Help with Animated GIFs...

Post by Bitblazer »

Kamarro wrote: Sat Jan 21, 2023 4:37 pm Is there a reason, I dont't believe that was a bug...
Did you already experienced this situation?
In between, i posted a reply with 3 solution for GIF multi-frame files. Then JHPJHP posted his solution - so i erased my post. So this thread was quite busy in between and maybe the forum software had a hickup due to that - just a guess.
User avatar
Kamarro
User
User
Posts: 65
Joined: Thu Mar 19, 2015 7:55 pm
Location: England

Re: Help with Animated GIFs...

Post by Kamarro »

Bitblazer wrote: Sat Jan 21, 2023 4:56 pm
Kamarro wrote: Sat Jan 21, 2023 4:37 pm Is there a reason, I dont't believe that was a bug...
Did you already experienced this situation?
In between, i posted a reply with 3 solution for GIF multi-frame files. Then JHPJHP posted his solution - so i erased my post. So i assume this threat was quite busy in between and maybe the forum software had a hickup - just a guess.
LOL... Maybe there's a bug about deleting posts with direct replies. You shouldn't be able to delete your post if the post already has a public reply. This is a misconception error on phpBB settings. The administration should change this, because my answers could be helpful to someone who wants to put an animated gif inside a loop...

Whatever, I've seen worse on this forums! ;)
infratec
Always Here
Always Here
Posts: 7619
Joined: Sun Sep 07, 2008 12:45 pm
Location: Germany

Re: Help with Animated GIFs...

Post by infratec »

Maybe this works.
Threads can not be used, since SpriteOutput() needs to be called in the same thread as OpenScreen().

I moved the code to Tips 'n' Tricks:
viewtopic.php?p=594218
Last edited by infratec on Sat Jan 21, 2023 11:25 pm, edited 9 times in total.
infratec
Always Here
Always Here
Posts: 7619
Joined: Sun Sep 07, 2008 12:45 pm
Location: Germany

Re: Help with Animated GIFs...

Post by infratec »

works with 2 sprites of:
Image
Post Reply