FileDocCategorySizeDatePackage
AbstractImageDataFactory.javaAPI DocphoneME MR2 API (J2ME)12181Wed May 02 18:00:08 BST 2007javax.microedition.lcdui

AbstractImageDataFactory

public interface AbstractImageDataFactory
Creates ImageDate that is based on platform decoder and storage.

Fields Summary
Constructors Summary
Methods Summary
public ImageDatacreateImmutableCopy(ImageData mutableSource)
Creates an immutable image data from a source mutable image data.

This method is useful for placing the contents of mutable images into Choice objects. The application can create an off-screen image using the {@link #createImage(int, int) createImage(w, h)} method, draw into it using a Graphics object obtained with the {@link #getGraphics() getGraphics()} method, and then create an immutable copy of it with this method. The immutable copy may then be placed into Choice objects.

param
mutableSource the source mutable image data to be copied
return
the new immutable image data

public ImageDatacreateImmutableImageData(byte[] imageData, int imageOffset, int imageLength)
Creates an immutable image data which is decoded from the data stored in the specified byte array at the specified offset and length. The data must be in a self-identifying image file format supported by the implementation, such as PNG.

The imageoffset and imagelength parameters specify a range of data within the imageData byte array. The imageOffset parameter specifies the offset into 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.

This method is intended for use when loading an image from a variety of sources, such as from persistent storage or from the network.

param
imageData the array of image data in a supported image format
param
imageOffset the offset of the start of the data in the array
param
imageLength the length of the data in the array
return
the created image data
throws
IllegalArgumentException if imageData is incorrectly formatted or otherwise cannot be decoded

public ImageDatacreateImmutableImageData(ImageData imageData, int x, int y, int width, int height, int transform)
Creates an immutable image data using pixel data from the specified region of a source image data, transformed as specified.

The source image may be mutable or immutable. For immutable source images, transparency information, if any, is copied to the new image unchanged.

On some devices, pre-transformed images may render more quickly than images that are transformed on the fly using drawRegion. However, creating such images does consume additional heap space, so this technique should be applied only to images whose rendering speed is critical.

The transform function used must be one of the following, as defined in the {@link javax.microedition.lcdui.game.Sprite Sprite} class:
Sprite.TRANS_NONE - causes the specified image region to be copied unchanged
Sprite.TRANS_ROT90 - causes the specified image region to be rotated clockwise by 90 degrees.
Sprite.TRANS_ROT180 - causes the specified image region to be rotated clockwise by 180 degrees.
Sprite.TRANS_ROT270 - causes the specified image region to be rotated clockwise by 270 degrees.
Sprite.TRANS_MIRROR - causes the specified image region to be reflected about its vertical center.
Sprite.TRANS_MIRROR_ROT90 - causes the specified image region to be reflected about its vertical center and then rotated clockwise by 90 degrees.
Sprite.TRANS_MIRROR_ROT180 - causes the specified image region to be reflected about its vertical center and then rotated clockwise by 180 degrees.
Sprite.TRANS_MIRROR_ROT270 - causes the specified image region to be reflected about its vertical center and then rotated clockwise by 270 degrees.

The size of the returned image will be the size of the specified region with the transform applied. For example, if the region is 100 x 50 pixels and the transform is TRANS_ROT90, the returned image will be 50 x 100 pixels.

Note: If all of the following conditions are met, this method may simply return the source Image without creating a new one:

  • the source image is immutable;
  • the region represents the entire source image; and
  • the transform is TRANS_NONE.

param
imageData the source image data to be copied from
param
x the horizontal location of the region to be copied
param
y the vertical location of the region to be copied
param
width the width of the region to be copied
param
height the height of the region to be copied
param
transform the transform to be applied to the region
return
the new immutable image data

public ImageDatacreateImmutableImageData(java.io.InputStream stream)
Creates an immutable image data from decoded image data obtained from an InputStream. This method blocks until all image data has been read and decoded. After this method completes (whether by returning or by throwing an exception) the stream is left open and its current position is undefined.

param
stream the name of the resource containing the image data in one of the supported image formats
return
the created image data
throws
java.io.IOException if an I/O error occurs, if the image data cannot be loaded, or if the image data cannot be decoded

public ImageDatacreateImmutableImageData(int[] rgb, int width, int height, boolean processAlpha)
Creates an immutable image data from a sequence of ARGB values, specified as 0xAARRGGBB. The ARGB data within the rgb array is arranged horizontally from left to right within each row, row by row from top to bottom. If processAlpha is true, the high-order byte specifies opacity; that is, 0x00RRGGBB specifies a fully transparent pixel and 0xFFRRGGBB specifies a fully opaque pixel. Intermediate alpha values specify semitransparency. If the implementation does not support alpha blending for image rendering operations, it must replace any semitransparent pixels with fully transparent pixels. (See Alpha Processing for further discussion.) If processAlpha is false, the alpha values are ignored and all pixels must be treated as fully opaque.

Consider P(a,b) to be the value of the pixel located at column a and row b of the Image, where rows and columns are numbered downward from the top starting at zero, and columns are numbered rightward from the left starting at zero. This operation can then be defined as:


P(a, b) = rgb[a + b * width]; 

for


0 <= a < width
0 <= b < height 

param
rgb an array of ARGB values that composes the image
param
width the width of the image
param
height the height of the image
param
processAlpha true if rgb has an alpha channel, false if all pixels are fully opaque
return
the created immutable image data

public ImageDatacreateImmutableImageData(int imageDataArrayPtr, int imageDataArrayLength)
Create a immutable image from romized image data.

param
imageDataArrayPtr native pointer to image data as Java int
param
imageDataArrayLength length of image data array
throws
IllegalArgumentException if the id is invalid
return
the created image data

public ImageDatacreateOffScreenImageData(int width, int height)
Creates a new, mutable image data for off-screen drawing. Every pixel within the newly created image is white. The width and height of the image must both be greater than zero.

param
width the width of the new image, in pixels
param
height the height of the new image, in pixels
return
the created image data

public ImageDatacreateResourceImageData(java.lang.String name)
Creates an immutable image data from decoded image data obtained from the named resource. The name parameter is a resource name as defined by {@link Class#getResourceAsStream(String) Class.getResourceAsStream(name)}. The rules for resolving resource names are defined in the Application Resource Files section of the java.lang package documentation.

param
name the name of the resource containing the image data in one of the supported image formats
return
the created image data
throws
java.io.IOException if the resource does not exist, the data cannot be loaded, or the image data cannot be decoded