net.rim.device.api.system
Class JPEGEncodedImage

java.lang.Object
  extended by net.rim.device.api.system.EncodedImage
      extended by net.rim.device.api.system.JPEGEncodedImage

public final class JPEGEncodedImage
extends EncodedImage

Represents an image encoded in the JPEG format.

To create a JPEGEncodedImage instance, use the EncodedImage.createEncodedImage(byte[],int,int) method. The createEncodedImage method accepts a java byte array containing the encoding of an image.

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:

  1. Using a binary file converter, such as xxd, convert the image to a C-style byte array.
  2. Open the target file and search for the string "0x".
  3. Replace the string with the following "(byte)0x".
  4. Adjust the array declaration at the top of the file to conform to Java standards.
  5. Remove the following string from the bottom of the file "unsigned int input_file_name_len = XXXX".

If done correctly, the file will contain a valid Java byte array containing the image encoding.

See Also:
EncodedImage
Since:
BlackBerry API 3.7.0

Field Summary
static int EXIF_ORIENTATION_HORIZONTAL_FLIP
          EXIF orientation value for correctly displaying images that have no rotation, but do have a horizontal axis flip.
static int EXIF_ORIENTATION_ROTATED_CW_180
          EXIF orientation value for correctly displaying images that are rotated clockwise by 180 degrees.
static int EXIF_ORIENTATION_ROTATED_CW_180_HORIZONTAL_FLIP
          EXIF orientation value for correctly displaying images that have been rotated clockwise 180 degrees, followed by a horizontal flip.
static int EXIF_ORIENTATION_ROTATED_CW_270
          EXIF orientation value for correctly displaying images that are rotated clockwise 270 degrees.
static int EXIF_ORIENTATION_ROTATED_CW_270_HORIZONTAL_FLIP
          EXIF orientation value for correctly displaying images that have been rotated clockwise 270 degrees, followed by a horizontal flip.
static int EXIF_ORIENTATION_ROTATED_CW_90
          EXIF orientation value for correctly displaying images that are rotated clockwise by 90 degrees.
static int EXIF_ORIENTATION_ROTATED_CW_90_HORIZONTAL_FLIP
          EXIF orientation value for correctly displaying images that are rotated clockwise 90 degrees, followed by a horizontal flip.
static int EXIF_ORIENTATION_STANDARD
          EXIF orientation value for correctly displaying images with no rotation.
static int FILETYPE_EXIF
          Constant indicating the EXIF file type.
static int FILETYPE_JFIF
          Constant indicating the JFIF file type.
static int FILETYPE_SPIFF
          Constant indicating the SPIFF file type.
static int FILETYPE_UNKNOWN
          Constant indicating an unknown file type.
static int FRAMETYPE_BASELINE
          Constant indicating the baseline jpeg mode.
static int FRAMETYPE_PROGRESSIVE
          Constant indicating the progressive jpg mode.
static int FRAMETYPE_SEQUENTIAL
          Constant indicating the sequential jpeg mode .
 
Fields inherited from class net.rim.device.api.system.EncodedImage
DECODE_ALPHA, DECODE_NATIVE, DECODE_NO_DITHER, DECODE_READONLY, IMAGE_TYPE_BMP, IMAGE_TYPE_GIF, IMAGE_TYPE_ICO, IMAGE_TYPE_JPEG, IMAGE_TYPE_PNG, IMAGE_TYPE_TIFF, IMAGE_TYPE_WBMP
 
Method Summary
static JPEGEncodedImage encode(Bitmap bitmap, int quality)
          Creates a JPEGEncodedImage from a Bitmap.
static JPEGEncodedImage encode(Bitmap bitmap, int srcLeft, int srcTop, int srcWidth, int srcHeight, int quality)
          Creates a JPEGEncodedImage from a Bitmap.
 int getBitmapType(int frameIndex)
          Returns the default bitmap type of the given frame.
 int getFileType()
          Returns an integer representing the file type.
 int getFrameType()
          Returns an integer representing the frame type.
 String getMIMEType()
          Return the commonly known MIME type associate for this encoded image object.
 int getOrientation()
          Returns the orientation of the image as stored in the exif data.
 boolean isColor()
          Returns a boolean indicating whether or not the jpeg is color.
static boolean isJPEGSupported()
          Returns whether or not the device's software supports the JPEG image format.
 
Methods inherited from class net.rim.device.api.system.EncodedImage
createEncodedImage, createEncodedImage, getAlphaType, getBitmap, getBitmap, getData, getDecodeMode, getEncodedImageResource, getEncodedImageResource, getFrameCount, getFrameHeight, getFrameMonochrome, getFrameTransparency, getFrameWidth, getHeight, getImageHeight, getImageType, getImageWidth, getLength, getMetaData, getOffset, getScale, getScaleX32, getScaleY32, getScaledFrameHeight, getScaledFrameWidth, getScaledHeight, getScaledHeight, getScaledWidth, getScaledWidth, getSupportedMIMETypes, getWidth, hasTransparency, isAnimated, isMIMETypeSupported, isMonochrome, scaleImage32, scaleImageToFill, setDecodeMode, setScale
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 



Field Detail

FILETYPE_UNKNOWN

public static final int FILETYPE_UNKNOWN
Constant indicating an unknown file type.

See Also:
Constant Field Values
Since:
BlackBerry API 3.7.0

FILETYPE_JFIF

public static final int FILETYPE_JFIF
Constant indicating the JFIF file type.

See Also:
Constant Field Values
Since:
BlackBerry API 3.7.0

FILETYPE_EXIF

public static final int FILETYPE_EXIF
Constant indicating the EXIF file type.

See Also:
Constant Field Values
Since:
BlackBerry API 4.0.0

FILETYPE_SPIFF

public static final int FILETYPE_SPIFF
Constant indicating the SPIFF file type.

See Also:
Constant Field Values
Since:
BlackBerry API 4.0.0

FRAMETYPE_BASELINE

public static final int FRAMETYPE_BASELINE
Constant indicating the baseline jpeg mode.

See Also:
Constant Field Values
Since:
BlackBerry API 3.7.0

FRAMETYPE_SEQUENTIAL

public static final int FRAMETYPE_SEQUENTIAL
Constant indicating the sequential jpeg mode .

See Also:
Constant Field Values
Since:
BlackBerry API 3.7.0

FRAMETYPE_PROGRESSIVE

public static final int FRAMETYPE_PROGRESSIVE
Constant indicating the progressive jpg mode.

See Also:
Constant Field Values
Since:
BlackBerry API 3.7.0

EXIF_ORIENTATION_STANDARD

public static final int EXIF_ORIENTATION_STANDARD
EXIF orientation value for correctly displaying images with no rotation.
 888888
 88
 8888
 88
 88
 

See Also:
Constant Field Values
Since:
BlackBerry API 6.0.0

EXIF_ORIENTATION_ROTATED_CW_90

public static final int EXIF_ORIENTATION_ROTATED_CW_90
EXIF orientation value for correctly displaying images that are rotated clockwise by 90 degrees.
 8888888888
     88  88
         88
 

See Also:
Constant Field Values
Since:
BlackBerry API 6.0.0

EXIF_ORIENTATION_ROTATED_CW_180

public static final int EXIF_ORIENTATION_ROTATED_CW_180
EXIF orientation value for correctly displaying images that are rotated clockwise by 180 degrees.
     88
     88
   8888
     88
 888888
 

See Also:
Constant Field Values
Since:
BlackBerry API 6.0.0

EXIF_ORIENTATION_ROTATED_CW_270

public static final int EXIF_ORIENTATION_ROTATED_CW_270
EXIF orientation value for correctly displaying images that are rotated clockwise 270 degrees.
 88
 88  88
 8888888888
 

See Also:
Constant Field Values
Since:
BlackBerry API 6.0.0

EXIF_ORIENTATION_HORIZONTAL_FLIP

public static final int EXIF_ORIENTATION_HORIZONTAL_FLIP
EXIF orientation value for correctly displaying images that have no rotation, but do have a horizontal axis flip.
 888888
     88
   8888
     88
     88
 

See Also:
Constant Field Values
Since:
BlackBerry API 6.0.0

EXIF_ORIENTATION_ROTATED_CW_90_HORIZONTAL_FLIP

public static final int EXIF_ORIENTATION_ROTATED_CW_90_HORIZONTAL_FLIP
EXIF orientation value for correctly displaying images that are rotated clockwise 90 degrees, followed by a horizontal flip.
 8888888888
 88  88     
 88
 

See Also:
Constant Field Values
Since:
BlackBerry API 6.0.0

EXIF_ORIENTATION_ROTATED_CW_180_HORIZONTAL_FLIP

public static final int EXIF_ORIENTATION_ROTATED_CW_180_HORIZONTAL_FLIP
EXIF orientation value for correctly displaying images that have been rotated clockwise 180 degrees, followed by a horizontal flip.
 88
 88
 8888
 88
 888888
 

See Also:
Constant Field Values
Since:
BlackBerry API 6.0.0

EXIF_ORIENTATION_ROTATED_CW_270_HORIZONTAL_FLIP

public static final int EXIF_ORIENTATION_ROTATED_CW_270_HORIZONTAL_FLIP
EXIF orientation value for correctly displaying images that have been rotated clockwise 270 degrees, followed by a horizontal flip.
         88
     88  88
 8888888888
 

See Also:
Constant Field Values
Since:
BlackBerry API 6.0.0


Method Detail

encode

public static JPEGEncodedImage encode(Bitmap bitmap,
                                      int srcLeft,
                                      int srcTop,
                                      int srcWidth,
                                      int srcHeight,
                                      int quality)
Creates a JPEGEncodedImage from a Bitmap.

Parameters:
bitmap - The Bitmap to be encoded into JPEG format.
srcLeft - X coordinate of the top left corner of the area to be copied from the source bitmap.
srcTop - Y coordinate of the top left corner of the area to be copied from the source bitmap.
srcWidth - Width of the area to be copied from the source bitmap.
srcHeight - Height of the area to be copied from the source bitmap.
quality - The quality that will be used to encode the Bitmap; valid values are between 0 (lowest quality) and 100 (highest quality), inclusive.
Returns:
A newly-created JPEGEncodedImage object that is the specified Bitmap encoded in JPEG format with the specified quality setting.
Throws:
NullPointerException - if bitmap is null.
IllegalArgumentException - if quality is outside the valid range.
Since:
BlackBerry API 5.0.0

encode

public static JPEGEncodedImage encode(Bitmap bitmap,
                                      int quality)
Creates a JPEGEncodedImage from a Bitmap.

Parameters:
bitmap - The Bitmap to be encoded into JPEG format.
quality - The quality that will be used to encode the Bitmap; valid values are between 0 (lowest quality) and 100 (highest quality), inclusive.
Returns:
A newly-created JPEGEncodedImage object that is the specified Bitmap encoded in JPEG format with the specified quality setting.
Throws:
NullPointerException - if bitmap is null.
IllegalArgumentException - if quality is outside the valid range.
Since:
BlackBerry API 4.3.0

getBitmapType

public int getBitmapType(int frameIndex)
Returns the default bitmap type of the given frame.

Specified by:
getBitmapType in class EncodedImage
Parameters:
frameIndex - The index of the frame for which to return the type.
Returns:
An integer representing the type.
Since:
BlackBerry API 3.7.0

getFileType

public int getFileType()
Returns an integer representing the file type. One of FILETYPE_UNKNOWN, FILETYPE_JFIF.

Returns:
An integer representing the file type.
Since:
BlackBerry API 3.7.0

getFrameType

public int getFrameType()
Returns an integer representing the frame type.

One of FRAMETYPE_BASELINE, FRAMETYPE_SEQUENTIAL, FRAMETYPE_PROGRESSIVE.

Returns:
An integer representing the file type.
Since:
BlackBerry API 3.7.0

getMIMEType

public String getMIMEType()
Return the commonly known MIME type associate for this encoded image object.

Specified by:
getMIMEType in class EncodedImage
Returns:
A String representing the MIME type generally associated with this object.
Since:
BlackBerry API 4.2.0

getOrientation

public int getOrientation()
Returns the orientation of the image as stored in the exif data. Valid values are JPEGEncodedImage.EXIF_ORIENTATION_STANDARD (standard orientation), JPEGEncodedImage.EXIF_ORIENTATION_ROTATED_CW_90 (90 degree rotation), JPEGEncodedImage.EXIF_ORIENTATION_ROTATED_CW_180 (180 degree rotation), JPEGEncodedImage.EXIF_ORIENTATION_ROTATED_CW_270 (270 degree rotation), JPEGEncodedImage.EXIF_ORIENTATION_HORIZONTAL_FLIP (no rotation, flipped horizontally), JPEGEncodedImage.EXIF_ORIENTATION_ROTATED_CW_90_HORIZONTAL_FLIP (90 degree rotation, followed by a horizontal flip), JPEGEncodedImage.EXIF_ORIENTATION_ROTATED_CW_180_HORIZONTAL_FLIP (180 degree rotation, followed by a horizontal flip), JPEGEncodedImage.EXIF_ORIENTATION_ROTATED_CW_270_HORIZONTAL_FLIP (270 degree rotation, followed by a horizontal flip).

Returns:
An int representing the orientation of image.
Since:
BlackBerry API 6.0.0

isColor

public boolean isColor()
Returns a boolean indicating whether or not the jpeg is color.

Returns:
true if the jpeg is color, false otherwise.
Since:
BlackBerry API 3.7.0

isJPEGSupported

public static final boolean isJPEGSupported()
Returns whether or not the device's software supports the JPEG image format.

Returns:
true if the device's software supports the JPEG image format or false if the device's software does not support the JPEG image format.
Since:
BlackBerry API 4.0.2





Copyright 1999-2011 Research In Motion Limited. 295 Phillip Street, Waterloo, Ontario, Canada, N2L 3W8. All Rights Reserved.
Java is a trademark of Oracle America Inc. in the US and other countries.
Legal