SHOW Colour SHOW Framework
 

net.rim.device.api.system
Class PNGEncodedImage

java.lang.Object
  |
  +--net.rim.device.api.system.EncodedImage
        |
        +--net.rim.device.api.system.PNGEncodedImage

public final class PNGEncodedImage
extends EncodedImage

Represents an image encoded in the PNG format.

To create a PNGEncodedImage 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.

Since:
JDE 3.6.0
See Also:
JPEGEncodedImage

Field Summary
 
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_JPEG, IMAGE_TYPE_PNG, IMAGE_TYPE_TIFF, IMAGE_TYPE_WBMP
 
Method Summary
  static PNGEncodedImage encode(Bitmap bitmap)
          Creates a PNGEncodedImage by compressing a Bitmap.
   int getAlphaBitDepth()
          Queries the bit depth of the alpha channel.
   int getAlphaType(int frameIndex)
          Returns the alpha channel type.
   int getBitDepth()
          Queries the PNG bit depth.
   int getBitmapType(int frameIndex)
          Returns the bitmap type.
   int getColorType()
          Queries the PNG color type.
 Category: Colour Category: Framework  String getMIMEType()
          Return the commonly known MIME type associate for this encoded image object.
   boolean hasAlpha()
          Queries whether the PNG has an alpha channel.
 
Methods inherited from class net.rim.device.api.system.EncodedImage
createEncodedImage, createEncodedImage, getBitmap, getBitmap, getData, getDecodeMode, getEncodedImageResource, getEncodedImageResource, getFrameCount, getFrameHeight, getFrameMonochrome, getFrameTransparency, getFrameWidth, getHeight, getImageType, getLength, getMetaData, getOffset, getScale, getScaledFrameHeight, getScaledFrameWidth, getScaledHeight, getScaledWidth, getScaleX32, getScaleY32, getSupportedMIMETypes, getWidth, hasTransparency, isMIMETypeSupported, isMonochrome, scaleImage32, setDecodeMode, setScale
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

encode

public static PNGEncodedImage encode(Bitmap bitmap)
Creates a PNGEncodedImage by compressing a Bitmap.
Parameters:
bitmap - the Bitmap to encode.
Returns:
a newly-created PNGEncodedImage object that is the specified bitmap encoded as a PNG image; never returns null.
Throws:
NullPointerException - if bitmap is null.
Since:
JDE 4.3.0

getAlphaBitDepth

public int getAlphaBitDepth()
Queries the bit depth of the alpha channel.

Returns:
The bit depth of the alpha channel, 0 if the image does not have an alpha channel.
Since:
JDE 3.6.0

getAlphaType

public int getAlphaType(int frameIndex)
Returns the alpha channel type.

Overrides:
getAlphaType in class EncodedImage
Parameters:
frameIndex - The index of the frame. This method calls the parent method.
Since:
JDE 3.7.0

getBitDepth

public int getBitDepth()
Queries the PNG bit depth.

Returns:
The PNG bit depth of the image.
Since:
JDE 3.6.0

getBitmapType

public int getBitmapType(int frameIndex)
Returns the bitmap type.

Overrides:
getBitmapType in class EncodedImage
Parameters:
frameIndex - The index of the frame.
Since:
JDE 3.7.0

getColorType

public int getColorType()
Queries the PNG color type.

Returns:
The PNG color type of the image.
Since:
JDE 3.6.0

getMIMEType

public String getMIMEType()
Return the commonly known MIME type associate for this encoded image object.
Overrides:
getMIMEType in class EncodedImage
Returns:
A String representing the MIME type generally associated with this object.
Since:
JDE 4.2.0
Category:
Colour: Pertains to devices' ability to display colour. May only be applicable on colour devices.
Framework: This element may be called by the underlying framework. Members that are invoked by the framework may not behave exactly as documented.

hasAlpha

public boolean hasAlpha()
Queries whether the PNG has an alpha channel.

Returns:
True if the PNG has an alpha channel, false otherwise.
Since:
JDE 3.6.0



Copyright 1999-2009 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.