0

Animated GIF’s in JavaFX, a word of warning…

Posted by Steven Herod on Jun 28, 2009 in twitterfx

I’ve learned many things over the course of putting together TwitterFX, and for the most part, I’ve failed to share them with the world!

I hope to change this over the coming weeks/months, but in the meantime, here is a tidbit.

One of neat things about JavaFX is the ease with which one can place Image and ImageView elements into your applicaton.

Not only does JavaFX support feedback on image loading and powerful effects, it will automatically render any GIF animation.

There is a however a caveat! Animated GIFs

JavaFX provides no way (that I can tell) to detect if an image is an animated GIF, or to control said GIF (for instance, to stop the animation)

Furthermore, the rendering of animated GIFs in JavaFX seems to be quite inefficient at this time and if you think you are going to add animation to your application easily by dropping in an animated GIF I wouldn’t recommend it.

In my experience, you can expect placing an animated GIF in your UI will cause your application to consume around 20% + more of CPU time on a Core 2 Duo! This may occur even if the image is hidden, but ceases after the image is removed from the scene graph.

Native JavaFX Timelines or the two Progress Indicator classes ProgressIndicator and ProgressBar l are a more efficient and powerful way of providing progress indicators or animation.

Tags: ,

Copyright © 2010 Fumbling Forward All rights reserved. Theme by Laptop Geek.