MIDP 3: Animated Images

Back | Tutorial Home

Animated image is a type of image where the single image is composed of set of image frames. One of the most popular animated image format is GIF89a format. MIDP3.0 adds support to this format. There is a new class “javax.microedition.lcdui.AnimatedImage” which can be used to render these animated images.

Create an animated image

AnimatedImage img = (AnimatedImage)Image.createImage("animate.gif");

Display an animated image

Graphics.drawImage(img, 0, 0, Graphics.LEFT + Graphics.TOP);

Class AnimatedImage also gives following methods to get information of the image.

getFrame(int index): Image frame at the specified index.
getFrameCount(): Number of frames in an AnimatedImage.
getFrameDelay(int index): Frame delay in milliseconds of the specified frame.
getLoopCount(): Number of times the animation should be repeated.

Back | Tutorial Home

site comments powered by Disqus

More Tutorials

MIDP for Beginners
MIDP Gaming
JSR 179: Location Based Services

This page is a part of a frames based web site. If you have landed on this page from a search engine click here to view the complete page.