|
|||||||||
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.
This class can only be extended by RIM because it contains one or more abstract methods with package access.
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_NO_DITHER
Don't dither when decoding. |
|
static int |
DECODE_READONLY
Marks the decoded bitmap as readonly. |
|
static int |
IMAGE_TYPE_BMP
Indicates that an image is encoded in the BMP format. |
|
static int |
IMAGE_TYPE_GIF
Indicates that an image is encoded in the GIF format. |
|
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_TIFF
Indicates that an image is encoded in the TIFF 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. |
|
abstract int |
getAlphaType(int frameIndex)
Gets the bitmap type for the given frame's alpha channel. |
|
Bitmap |
getBitmap()
Returns a bitmap of this image. |
|
Bitmap |
getBitmap(int frameIndex)
Returns a bitmap image of the specified frame. |
|
abstract int |
getBitmapType(int frameIndex)
Gets the bitmap type for the given frame. |
|
byte[] |
getData()
Returns the encoded data of this image. |
|
int |
getDecodeMode()
Gets the decoding mode for the image. |
|
static EncodedImage |
getEncodedImageResource(String name)
Creates an encoded image from provided name resource. |
|
static EncodedImage |
getEncodedImageResource(String module,
String name)
Creates an encoded image from provided named resource found in module. |
|
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 specified 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 (unscaled) height of this image in pixels. |
|
int |
getImageType()
Returns this image's encoding format. |
|
int |
getLength()
Returns the length of the encoded image data. |
|
![]() ![]() |
abstract String |
getMIMEType()
Return the commonly known MIME type associate for this encoded image object. |
int |
getOffset()
Returns the offset into the data where the encoded image begins. |
|
int |
getScale()
Gets the scale that is to be used when decoding this image. |
|
int |
getScaledFrameHeight(int frameIndex)
Returns the scaled height in pixels of the specified frame. |
|
int |
getScaledFrameWidth(int frameIndex)
Returns the scaled width in pixels of the specified frame. |
|
int |
getScaledHeight()
Returns the scaled height of this image in pixels. |
|
int |
getScaledWidth()
Returns the scaled width of this image in pixels. |
|
int |
getScaleX32()
Gets the x scale that is to be used when decoding this image. |
|
int |
getScaleY32()
Gets the y scale that is to be used when decoding this image. |
|
static Enumeration |
getSupportedMIMETypes()
Returns a list of the supported MIME image types. |
|
int |
getWidth()
Returns the (unscaled) width of this image in pixels. |
|
boolean |
hasTransparency()
Returns true if this image has transparency. |
|
![]() ![]() |
static boolean |
isMIMETypeSupported(String mimeType)
Determines whether or not the specified MIME type is supported. |
boolean |
isMonochrome()
Returns true if this is a monochrome image. |
|
EncodedImage |
scaleImage32(int scaleX,
int scaleY)
Returns a copy of this encoded image, but with its x and y scales set to scaleX
and scaleY , respectively. |
|
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_ALPHA
public static final int DECODE_NATIVE
public static final int DECODE_NO_DITHER
public static final int DECODE_READONLY
public static final int IMAGE_TYPE_BMP
public static final int IMAGE_TYPE_GIF
public static final int IMAGE_TYPE_JPEG
public static final int IMAGE_TYPE_PNG
public static final int IMAGE_TYPE_TIFF
public static final int IMAGE_TYPE_WBMP
Method Detail |
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.
This method accepts an encoding of the image in a byte array format. An image encoding can be obtained by either of the following methods:
First, when an image is added to a project in the IDE, the image resource becomes available to the developer.
Second, the image encoding can be obtained manually by converting the binary image file to a java byte array. This is accomplished using the following procedure:
If done correctly, the file will contain a valid Java byte array containing the image encoding.
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
,
WBMPEncodedImage
,
GIFEncodedImage
,
JPEGEncodedImage
,
BMPEncodedImage
,
TIFFEncodedImage
public 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. (NOT base64 encoded)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.
The following MIME types are supported:
IllegalArgumentException
- Thrown if the specified mime type is invalid.PNGEncodedImage
,
WBMPEncodedImage
public abstract int getAlphaType(int frameIndex)
frameIndex
- The index of the frame for which to return the alpha channel.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 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.public abstract int getBitmapType(int frameIndex)
frameIndex
- The index of the frame for which to return the bitmap type.getBitmap
.public final byte[] getData()
public int getDecodeMode()
public static EncodedImage getEncodedImageResource(String name)
This method looks for the resource in both the .cod file that called this method and any .cod files that it relies on. The resource files are automatically generated by the compiler when a new graphic (PNG, GIF, or, JPG) is added to a project.
name
- Name of the encoded image resource.NullPointerException
- If the name parameter is null.public static EncodedImage getEncodedImageResource(String module, String name)
This method looks for the resource in both the .cod file that called this method and any .cod files that it relies on. The resource files are automatically generated by the compiler when a new graphic (PNG, GIF, or, JPG) is added to a project.
module
- Name of the module containing the encoded image resource. If
not specified, the name of the calling module is used.name
- Name of the encoded image resource.NullPointerException
- If the name parameter is null.public int getFrameCount()
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 int getFrameWidth(int frameIndex)
frameIndex
- The frame in question.public int getHeight()
public int getImageType()
public final int getLength()
getData
.public abstract String getMIMEType()
String
representing the MIME type generally associated with this object.public final int getOffset()
getData
.public int getScale()
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.
public int getScaledFrameHeight(int frameIndex)
frameIndex
- The frame in question.public int getScaledFrameWidth(int frameIndex)
frameIndex
- The frame in question.public final int getScaledHeight()
public final int getScaledWidth()
public int getScaleX32()
Fixed32
number representing the
x-scaling factor (0 < scale
< 1 for upscaling,
scale
> 1 for downscaling).public int getScaleY32()
Fixed32
number representing the
y-scaling factor (0 < scale
< 1 for upscaling,
scale
> 1 for downscaling).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 int getWidth()
public boolean hasTransparency()
true
if this image contains transparency,
false
otherwise.public static boolean isMIMETypeSupported(String mimeType)
mimeType
- the MIME type in question. It is not case sensitive.NullPointerException
- when mimeType is nullpublic boolean isMonochrome()
true
if this image is monochrome,
false
otherwise.public EncodedImage scaleImage32(int scaleX, int scaleY)
scaleX
and scaleY
, respectively. Both provided scale values must be
Fixed32
numbers (0 < scale
< 1 for upscaling, and scale
> 1 for downscaling).scaleX
- The x-scaling factor (0 < scaleX
< 1 for upscaling,
and scaleX
> 1 for downscaling). Must be a
Fixed32
number.scaleY
- The y-scaling factor (0 < scaleY
< 1 for upscaling,
and scaleY
> 1 for downscaling). Must be a
Fixed32
number.scaleX
and scaleY
, respectively.IllegalArgumentException
- if scaleX
or scaleY
is
<= 0.public void setDecodeMode(int decodeMode)
DECODE_ALPHA
, DECODE_NATIVE
,
DECODE_NO_DITHER
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.IllegalArgumentException
- Thrown if scale is less than 1.
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
Copyright 1999-2007 Research In Motion Limited. 295 Phillip Street, Waterloo, Ontario, Canada, N2L 3W8. All Rights Reserved.
Copyright 1993-2003 Sun Microsystems, Inc. 901 San Antonio Road, Palo Alto, California, 94303, U.S.A.
Copyright 2002-2003 Nokia Corporation All Rights Reserved.
Java is a trademark or registered trademark of Sun Microsystems, Inc. in the US and other countries.