Name

Image

Synopsis

A class that represents a memory-resident image that can be drawn onto the screen. Images are used in both the high- and low-level user interface APIs. In the high-level API, Images can be used with Alerts, ChoiceGroups, ImageItems and Lists. In the low-level API, an Image can be drawn onto any part of a Canvas object from within its paint() method.

An Image may be either mutable or immutable. Images used in the high-level API must be immutable; either type may be used with the low-level API. Given an arbitrary Image, the isMutable() method can be used to determine whether it is mutable or not. The dimensions of an Image can be obtained by calling its getWidth() and getHeight() methods.

There are are four static createImage() methods can be used to create an Image. The createImage(byte[] data, int offset, int length) method creates an immutable image from data held in a portion of a given byte array. The data must be encoded in a format that is supported by the implementation. The only format that the MIDP specification requires a device to support is Portable Network Graphics (PNG). The image data can be obtained from any source, such as over a network or from a record in a RecordStore on the device. The createImage(String fileName) method uses the content of a file addressable using the resource name fileName as the image data and creates an immutable image from it. fileName is usually the absolute path name of a file within the MIDlet suite’s JAR file, such ...

Get J2ME in a Nutshell now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.