|
MID Profile | |||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--javax.microedition.lcdui.Image
The Image class is used to used to hold graphical image data. Image objects exist independently of the display device. They exist only in off-screen memory and will not be painted on the display unless an explicit command is issued by the application (such as within the paint() method of a Canvas) or when an Image object is placed within a Form screen or an Alert screen and that screen is made current.
Images are either mutable or immutable depending upon
how they are created. Immutable images are generally created by loading
image data from resource bundles, from files, or from the network. They
may not be modified once created. Mutable images are created in off-screen
memory. The application may paint into them after having created a
Graphics object expressly for this purpose. Images to be placed within an
ImageItem or onto Form or Alert screens must be immutable. An immutable
image may be created from a mutable image through the use of the createImage
method. It is possible to create a
mutable copy of an immutable image using a technique similar to the
following:
Image source; // the image to be copied Image copy = Image.createImage(source.getWidth(), source.getHeight()); Graphics g = copy.getGraphics(); g.drawImage(source, 0, 0, TOP|LEFT);
The implementations are assumed to support PNG as the image format. Implementation of filtering, progressive drawing/interlacing and transparency is not, however, required.
Method Summary | |
static Image |
createImage(byte[] imagedata,
int imageoffset,
int imagelength)
Creates an immutable image which is decoded from the data stored in the specified byte array at the specified offset and length. |
static Image |
createImage(Image image)
Creates an immutable image from a mutable image. |
static Image |
createImage(int width,
int height)
Creates a new, mutable image for off-screen drawing. |
static Image |
createImage(String name)
Creates an immutable image from decoded image data obtained from the named resource. |
Graphics |
getGraphics()
Creates a Graphics object that renders to this image. |
int |
getHeight()
Gets the height of the image in pixels. |
int |
getWidth()
Gets the width of the image in pixels. |
boolean |
isMutable()
Check if this image is mutable. |
Methods inherited from class java.lang.Object |
equals,
getClass,
hashCode,
notify,
notifyAll,
toString,
wait,
wait,
wait |
Method Detail |
public static Image createImage(int width, int height)
width
- the width, in pixels, of the new imageheight
- the height, in pixels, of the new imagepublic static Image createImage(Image image)
Alerts
, Forms
and
Choices
.image
- the image to be copiedpublic static Image createImage(String name) throws IOException
name
- the name of the resource containing the pixel data in one of
the recognized file formats.public static Image createImage(byte[] imagedata, int imageoffset, int imagelength)
The imageoffset and imagelength parameters specify a range of data the imagedata byte array. The imageoffset parameter specifies the offset within the array of the first data byte to be used. It must therefore lie within the range [0..(imagedata.length-1)]. The imagelength parameter specifies the number of data bytes to be used. It must be a positive integer and it must not cause the range to extend beyond the end of the array. That is, it must be true that imageoffset + imagelength <= imagedata.length.
Images created by this method are immutable. Therefore, resources permitting, the implementation is allowed to provide a caching scheme and return the same image object if the same data is provided to a subsequent createImage() call. Similarly, the application can safely cache and reuse these images.
This method is intended for use when loading an image from ROM or from the network.
imagedata
- the array of image data in a supported image formatimageoffset
- the offset of the start of the data in the arrayimagelength
- the length of the data in the arraypublic Graphics getGraphics()
public int getWidth()
public int getHeight()
public boolean isMutable()
|
MID Profile | |||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |