Jump to content
Michael Aivaliotis

Animated GIF speed

Recommended Posts

I admit I don't use GIFs in my UI's much, and when I do I usually don't care about how fast they run.  But I just did a quick test with this GIF cause it was one of the first results on google, and the speed seemed to match the speed of Chrome for the VI when running or not, with the only noticeable hiccup is when running or stopping the VI.  This is using LabVIEW 2015 SP1 Windows 7 x64.

Is this a GIF you can post to test with?  How many frames are in the GIF?  You can be a bit hacky and use a picture ring and invoke the image based on how much time has elapsed.  Oh and you can also use a .NET picture box, here is some code I posted a while ago showing how to load an image, but for some reason it isn't animated, it could be a setting with the picture box.  

  • Like 1

Share this post


Link to post
Share on other sites
11 hours ago, Michael Aivaliotis said:

Is it possible to control the speed of animated GIFs in LabVIEW UIs? It seems that the speed of the animation is slower when placed on a LabVIEW UI.

No and I believe they run in the root loop so I would suggest using sparingly and not too fancy.

Edited by ShaunR

Share this post


Link to post
Share on other sites
13 hours ago, hooovahh said:

I admit I don't use GIFs in my UI's much, and when I do I usually don't care about how fast they run.

200.gif

Stay thirsty my friends

  • Like 1

Share this post


Link to post
Share on other sites

To be a little more helpful, I googled speed up gifs and found this:

Ezgif speed up site

and sped up the above gif by 200% and inserted it into the attached VI.  Then inserted the original gif saved from the site at 100% (for some reason the original gif wouldn't drag/drop into the VI, but ones run through the website would). 

Anyway it seems the speed up works on my machine/vi.  

staythirsty.vi

Share this post


Link to post
Share on other sites

Thanks for the tip about the speedup site. I'll try that.

There must be CPU cycles consumed where LabVIEW is purposefully advancing the GIF, one frame at a time. So a larger sized GIF or one with a significant color depth will be slower.

Share this post


Link to post
Share on other sites

There is a time delay specified in the animated GIF file for every frame.

It is like: frame1, delay1, frame2, delay2, ...

LabVIEW doesn't support the delays, uses a constant instead.

You can control the frame rate in C#, but not in LabVIEW.

 

Share this post


Link to post
Share on other sites
Just now, Zou said:

LabVIEW doesn't support the delays, uses a constant instead.

This is simply not true.  Download the VI posted in this thread and you'll see the two GIF that have the same number of frames are at different rates.  Recently a user also posted talking about having GIFs on buttons and I was able to make a GIF with a 400ms delay in it and put it on the front panel of the VI and it delayed as it was supposed to.

Share this post


Link to post
Share on other sites

Which version of LabVIEW you tested?

I haven't try this for recent versions.

Share this post


Link to post
Share on other sites

This behavior is the same on 2015 SP1 and 2016 which are the two versions I have installed, but I know I've placed loading gifs on splash screens from 2011 and newer, and the speed wasn't effected.

Share this post


Link to post
Share on other sites

Just tested this image (:frusty:) on LabVIEW 2016.

The problem is those short delays.

 

Share this post


Link to post
Share on other sites

Very interesting, all the GIFs I was testing with had the same delay between all frames.  Wonder if NI this could be an issue brought up to NI and have a CAR assigned if it is related to short frame length, or varying frame length in the images.

Share this post


Link to post
Share on other sites

Just ran into this today. Wanted to use the attached animated gif, but it runs really slow on a FP (as state image on a button actually).

Oh well, just one of those things.

I bet one of those images from 1985 will work just fine. You know, black/white 16x16 px, 4 frames, 1 second in-between frames, no transparency...

Preloader.gif

EDIT: I did try one of those gif speedup services (ezgif.com), and the new gif animates much faster, except in LabVIEW where it continues to crawl along. It must be an issue of LabVIEW throttling resources to run the gif. I can see how such a gif could easily bog down my multi-GHz 8-core CPU. I'm glad those gifs are kept in check, wouldn't want them to animate at anywhere near intended speed... Sarcasm might occur.

Edited by Steen Schmidt

Share this post


Link to post
Share on other sites

I tried once getting a gif to load in a .Net picture box but I couldn't get it to animate, I wonder if that would be a better solution.  Here is the basics of the code I used to load an image into a picturebox.  It looks like it should animate but it doesn't, maybe I'm missing something.

Share this post


Link to post
Share on other sites

If you use a .net PictureBox on a button, then you won't be able to click the button in that area.

It would be better to draw on the front panel directly without a control, just like all LabVIEW controls.

 

 

Share this post


Link to post
Share on other sites

These gifs don't look like the kind of thing the user is clicking.  These look like loading gifs or things to look at while stuff happens in the background.  If you really needed to detect interactions with the animated image, a picture ring, with changing values, would be suggested but that wouldn't be able to be dynamically loadable either.  It all depends on your needs.  I was just trying to suggest a way to display an animated gif from a file, on the front panel, that adhered to better timing needs.

Share this post


Link to post
Share on other sites

Steen Schmidt Wrote:
> Just ran into this today. Wanted to use the attached animated gif, but it runs really slow on a FP (as state image on a button actually).

The gif is intended to show on a button.

 

  • Like 1

Share this post


Link to post
Share on other sites

Oops missed that, like given.  Well some tricks could try to be done to detect mouse down and detect where the mouse is clicked, but not getting the gif animated in the first place is a bit of a show stopper anyway.

Share this post


Link to post
Share on other sites

Right.  That's an acceptable work around.

As for loading the gif, you can always read all the images in the gif using C#/.net, and display them with a LabVIEW picture control.

I did this before long time ago.

 

Share this post


Link to post
Share on other sites

Yes, I want to do some loaders/spinners. I wanted the gif on a button to easily switch between inactive (a static subdued image) and active (the animated gif) states.

I started on the route to populate either a ring or a 1D array with the images, and then make a brat VI to automate animation of it. Then I thought better of it; "this is LabVIEW again forcing me to jump through hoops and spend numerous hours on something that should just be a drop-in". I simply won't do any of these work arounds to get a freaking animated gif to roll. But LabVIEW isn't alone here, animated gif support is always riddled with exceptions in browsers and the like. Animated PNGs are even worse for wear in this regard.

LabVIEW probably just have an upper limit as to how many frames it will allow a gif to execute per second. Below that rate it'll play at full speed. I'll investigate that assertion and get back shortly.

Edited by Steen Schmidt

Share this post


Link to post
Share on other sites

Then I thought better of it; "this is LabVIEW again forcing me to jump through hoops and spend numerous hours on something that should just be a drop-in".

I whole wholeheartedly agree.  That being said customers don't really care what kinds of hoops I have to go through to make something work, they just care about it working the way they think it should (with my input of course).  I don't remember a customer putting any kind of requirement on my software to have an animated gif that is clickable, that sounds more like the kind of thing I would look into in my spare time.  Because I think it would set my software apart from other LabVIEW software they had seen, and show an expertise in the field.  

Yes LabVIEW should be able to to do this, and we can complain to NI, vote on it, and tell them all we want.  But I'm sorta in the opinion of also trying to come up with a solution that works mostly well with the tools I have today.  Then trying to wrap that functionality into a easily reusable example. 

I did make a thread on the dark side asking about PictureBox animation.  One suggestion is to use the ActiveX container for the web browser which has other dependencies but I think could be made to work.  Clearly you could do this with an array of images you are updating, but I wanted to avoid polling and timing and updating, and have that off load to some other tool.  Attached is an example using the ActiveX web browser and a sub panel.

GIF Click Test.zip

Share this post


Link to post
Share on other sites

Maybe I say an heresy, but what's wrong with a clickable picture box?  This is a q&d attempt, just loads in memory all *.png found in a directory and animates them, it doesn't look to me as overcomplicate as an embedded activeX browser or the like. Maybe a portable Xcontrol out of it?

animate.png

 

RotatePNG.vi

Share this post


Link to post
Share on other sites
4 hours ago, hooovahh said:

I don't remember a customer putting any kind of requirement on my software to have an animated gif that is clickable

Not like that. This requirement is:

1. Illustrate busy state on the window.
2. When the window is not busy, the busy indicator must be visible but subdued (to familiarize users with the location of the busy indicator).

Just like in VIPM for instance:

VIPM.png

One simple way to do that was with a toggle-button that has a static subdued image in False state, and a spinner gif in True state. Then activating "busy" is simply programmatically setting the button to True. It's not so the user can push that button.

Share this post


Link to post
Share on other sites
4 hours ago, ensegre said:

Maybe I say an heresy, but what's wrong with a clickable picture box?  This is a q&d attempt,

There's a few reasons I don't like this method but might meet the needs of others.  This means the gif you load must have even timing between frames, and you need to export the gif frames before hand.  I'd prefer a method that you give the path to a gif and it takes care of the rest, but if this method meets your needs go for it.  I've also seen images pre-loaded into a picture ring and then write to the terminal which image to show.

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.


×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.