|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
java.lang.Object | +--net.rim.device.api.system.EncodedImage
Encapsulates encoded images of various formats.
To decode an image, first call EncodedImage.createEncodedImage to generate an instance of EncodedImage, and then call getBitmap.
| Field Summary | ||
static int |
DECODE_ALPHA
Decodes an alpha channel if there is one. |
|
static int |
DECODE_NATIVE
Forces the bitmap to be decoded to the native bitmap type of the device. |
|
static int |
DECODE_READONLY
Marks the decoded bitmap as readonly. |
|
static int |
IMAGE_TYPE_JPEG
Indicates that an image is encoded in the JPEG format. |
|
static int |
IMAGE_TYPE_PNG
Indicates that an image is encoded in the PNG format. |
|
static int |
IMAGE_TYPE_WBMP
Indicates that an image is encoded in the WBMP format. |
|
| Method Summary | ||
static EncodedImage |
createEncodedImage(byte[] data,
int offset,
int length)
Creates an EncodedImage from bytes. |
|
static EncodedImage |
createEncodedImage(byte[] data,
int offset,
int length,
String mimeType)
Creates an EncodedImage from bytes.
|
|
Bitmap |
getBitmap()
Returns a bitmap of this image. |
|
abstract Bitmap |
getBitmap(int frameIndex)
Returns a bitmap image of the specified frame. |
|
int |
getFrameCount()
Returns the number of frames in this image. |
|
int |
getFrameHeight(int frameIndex)
Returns the height in pixels of the specified frame. |
|
boolean |
getFrameMonochrome(int frameIndex)
Returns true if the spcified frame is monochrome. |
|
boolean |
getFrameTransparency(int frameIndex)
Returns true if the specified frame has transparency information. |
|
int |
getFrameWidth(int frameIndex)
Returns the width in pixels of the specified frame. |
|
int |
getHeight()
Returns the height of this image in pixels. |
|
int |
getImageType()
Returns this image's encoding format. |
|
static Enumeration |
getSupportedMIMETypes()
Returns a list of the supported MIME image types. |
|
int |
getWidth()
Returns The width of this image in pixels. |
|
boolean |
hasTransparency()
Returns true if this image has transparency. |
|
boolean |
isMonochrome()
Returns true of this is a monochrome image. |
|
void |
setDecodeMode(int decodeMode)
Sets the decoding mode for the image. |
|
void |
setScale(int scale)
Sets the scale to be used when decoding this image. |
|
| Methods inherited from class java.lang.Object |
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
public static final int DECODE_NATIVE
public static final int IMAGE_TYPE_PNG
public static final int IMAGE_TYPE_JPEG
public static final int IMAGE_TYPE_WBMP
| Method Detail |
public static Enumeration getSupportedMIMETypes()
This method returns an Enumeration containing Strings representing the MIME image types that the device supports (in lowercase). Note that MIME types are not case sensitive.
PNG format images are guaranteed to be supported.
public static EncodedImage createEncodedImage(byte[] data, int offset, int length)
EncodedImage from bytes. A new
instance of the appropriate EncodedImage subclass
is returned. If the image format is not recognized, an
IllegalArgumentException is thrown.data - The byte array containing the encoded image data.offset - The starting offset of the encoded image data
in the array.length - The length in bytes of the encoded image data,
or -1 to indicate the entire array should be used.PNGEncodedImage,
WBMPEncodedImagepublic static EncodedImage createEncodedImage(byte[] data, int offset, int length, String mimeType)
EncodedImage from bytes.
A new instance of the appropriate EncodedImage
subclass is returned. If the image format does not match the MIME
type, or the image data is otherwise invalid an
IllegalArgumentException is thrown. If the MIME
type is null then the system will attempt to infer the image type
from the image data.
data - The byte array containing the encoded image data.offset - The starting offset of the encoded image data
in the array.length - The length in bytes of the encoded image data,
or -1 to indicate the entire array should be used.mimeType - The MIME type of the image data.PNGEncodedImage,
WBMPEncodedImagepublic void setDecodeMode(int decodeMode)
DECODE_ALPHA, DECODE_NATIVE, or
DECODE_READONLY (described above). The default decode
mode is DECODE_ALPHA.decodeMode - the decoding mode to be used for this image.public void setScale(int scale)
Images can be downscaled by an integer factor when decoding. This is a more efficient way of scaling instead of decoding the image normally and using Graphics to scale.
scale - The downscale factor.public int getImageType()
public int getWidth()
public int getHeight()
public int getFrameCount()
public boolean isMonochrome()
true if this image is monochrome,
false otherwise.public boolean hasTransparency()
true if this image contains transparency,
false otherwise.public int getFrameWidth(int frameIndex)
frameIndex - The frame in question.public int getFrameHeight(int frameIndex)
frameIndex - The frame in question.public boolean getFrameMonochrome(int frameIndex)
frameIndex - The frame in question.true if this frame is monochrome,
false otherwise.public boolean getFrameTransparency(int frameIndex)
frameIndex - The frame in question.true if this frame contains transparency,
false otherwise.public Bitmap getBitmap()
This method decodes the image represented by this EncodedImage and returns a Bitmap. This call can be expensive.
Bitmap representation of the image.public abstract Bitmap getBitmap(int frameIndex)
This method decodes the given frame of the image represented by this EncodedImage. This call can be expensive.
frameIndex - The frame in question.Bitmap representation of the image frame.
|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
Copyright 1999-2002 Research In Motion Limited. 295 Phillip Street, Waterloo, Ontario, Canada, N2L 3W8. All Rights Reserved.
Copyright 1993-2000 Sun Microsystems, Inc. 901 San Antonio Road, Palo Alto, California, 94303, U.S.A. All Rights Reserved.
Java is a trademark or registered trademark of Sun Microsystems, Inc. in the US and other countries.