Just An Application

July 22, 2009

What’s New In MIDP 3.0 ? Part 29: LCDUI – AnimatedImage

Filed under: Java, JME, LCDUI, MIDP, MIDP3, MIDP3LCDUI — Tags: , , , , , , — Simon Lewis @ 9:07 am

1. AnimatedImage

The AnimatedImage class is a sub-class of the Image class.

An AnimatedImage is a composite Image which comprises a sequence of Images. It is displayed by displaying the individual Images within the sequence one after another, each Image being replaced by its successor after a specified period of time.

An AnimatedImage may be used anywhere an Image can be used, but an implementation may not necessarily render the AnimatedImage exactly as specified. It may render it statically using the first Image in the sequence, or animate it only for a period of time.

2. Terminology

2.1 Frame

A frame is an individual Image within the sequence of Image’s that comprise the AnimatedImage.

2.2 Frame Count

The frame count is the number of Image’s in the sequence of Image’s that comprise the AnimatedImage.

2.2 Frame Delay

The frame delay is the amount of time, in milliseconds, for which a given frame will be displayed

2.3 Frame Index

The index of a given frame is it’s position within the sequence of Image’s that comprise the AnimatedImage.

Frames are indexed from zero so a valid frame index must be greater than or equal to zero and less than the frame count.

2.3 Loop Count

The loop count is the number of times the AnimatedImage’s frame sequence will be repeated after it has been shown for the first time.

3. Creating An AnimatedImage

An AnimatedImage can be created from data in the GIF89a format using any of the following Image method’s


    public static Image createImage(java.io.InputStream stream)
                        throws 
                            java.io.IOException

    public static Image createImage(String name)
                        throws 
                            java.io.IOException
						 
    public static Image createImage(byte[] imageData, int imageOffset, int imageLength)

In each case the resulting Image can then be cast to an AnimatedImage.

Whether the resulting Image is in fact an AnimatedImage can be determined by calling the Image’s isAnimated() method.

4. Getting The Frame Count

The frame count of an AnimatedImage can be obtained by calling it’s

    public int getFrameCount()

method.

5. Getting The Loop Count

The loop count of an AnimatedImage can be obtained by calling it’s

	public int getLoopCount()

method.

The method will return -1 if the frame sequence will be repeated indefitely.

6. Getting A Specific Frame

A specific frame of an AnimatedImage can be obtained by calling it’s

    public Image getFrame(int index)

method

It is an error if the index argument does not specify a valid frame index and an IndexOutOfBoundsException will e thrown.

The method will return an immutable Image representing the specified frame.

7. Getting The Delay For A Specific Frame

The delay for a specific Frame of an AnimatedImage by calling it’s

	public int getFrameDelay(int index)

method.

It is an error if the index argument does not specify a valid frame index and an IndexOutOfBoundsException will e thrown.


Copyright (c) 2009 By Simon Lewis. All Rights Reserved.

Advertisements

Leave a Comment »

No comments yet.

RSS feed for comments on this post. TrackBack URI

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

Create a free website or blog at WordPress.com.

%d bloggers like this: