Java Swing Display gif

Source: Internet
Author: User


Original address: http://yanwushu.sinaapp.com/?p=48


GIF is a common means of implementing animations in swing. The simplest way to typically display a picture in swing is to call the JButton or JLabel's SetIcon (icon icon) method. However, this is not a good way to display GIF images, because if you do this you will find that the GIF refresh rate is often very fast, or should be said too fast, and the corresponding CPU utilization will increase significantly, in severe cases may lead to panic.


In order to solve this problem you can choose the following two ideas, the first idea is: the GIF image into a number of static pictures, and then through the program cycle display these pictures, to achieve the purpose of animation. For example, this is certainly bad practice, cumbersome, and a lot of work.


Animating with looping display


The second idea is to use code to parse GIF files manually, this part of this article provides a complete implementation of the download link at the end of the article. The Gifanalysis.java in the download package is an analysis tool for GIF. Gif.java is a reference for rendering GIF.


If you want to understand the Gifanalysis.java implementation principle, then need to have some basic understanding of the GIF file format and understand the interface of Java processing GIF, then please refer to the link at the end, this is a translation, may be some not fluent, interested people can find the relevant foreign documents.


Principle of implementation: http://www.blogjava.net/javagui/archive/2008/12/07/javafx.html

Code Download: Http://pan.baidu.com/s/1kT40wPT

If the resource fails, please notify [email protected]il.com

Java Swing Display gif

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.