|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
java.lang.Object | +--net.rim.device.api.system.Bitmap
Encapsulates a Bitmap graphic usable for display on the device.
When constructing a bitmap object, you have the option to specify the type of encoding used.
Bitmap.PNGInfo| Inner Class Summary | ||
static class |
Bitmap.PNGInfo
Provides additional information relevant for PNG bitmap graphics. |
|
| Field Summary | ||
|
static int |
ALPHA_BITDEPTH_8BPP
8-bit Alpha Channel type identifier. |
|
static int |
ALPHA_BITDEPTH_MONO
1-bit Alpha Channel type identifier. |
static int |
COLUMNWISE_MONOCHROME
Columnwise, monochrome bitmap type. |
|
static int |
EXCLAMATION
Predefined bitmap used for alert dialogs. |
|
static int |
HOURGLASS
Predefined bitmap used for busy cursors. |
|
static int |
INFORMATION
Predefined bitmap used for information dialogs. |
|
static int |
QUESTION
Predefined bitmap used for query dialogs. |
|
|
static int |
ROWWISE_16BIT_COLOR
Rowwise, color bitmap type. |
|
static int |
ROWWISE_MONOCHROME
Rowwise, monochrome bitmap type. |
static int |
TRUE_BLACK
The hexadecimal representation of pure black. |
|
static int |
TRUE_WHITE
The hexadecimal representation of pure white. |
|
| Constructor Summary | ||
Bitmap(int width,
int height)
Constructs a blank bitmap object. |
||
Bitmap(int type,
int width,
int height)
Constructs a blank bitmap object of a specific type. |
||
Bitmap(int type,
int width,
int height,
byte[] data)
Constructs a new bitmap of a specific type from existing data. |
||
| Method Summary | ||
|
void |
createAlpha(int bitDepth)
Create the alpha map associated with this Bitmap. |
static Bitmap |
createBitmapFromBytes(byte[] bytes,
int offset,
int length,
int scale)
Creates a bitmap from image data. |
|
static Bitmap |
createBitmapFromPNG(byte[] png,
int offset,
int length)
Creates a bitmap from provided PNG format data. |
|
boolean |
equals(Object obj)
Tests if provided bitmap is equal to this bitmap. |
|
|
void |
getARGB(int[] argbData,
int offset,
int scanLength,
int x,
int y,
int width,
int height)
Gets raw ARGB data from region of this Bitmap and stores it in the provided array. |
static Bitmap |
getBitmapResource(String name)
Creates a bitmap from provided name resource. |
|
static Bitmap |
getBitmapResource(String module,
String name)
Creates a bitmap from provided named resource found in module. |
|
int |
getBitsPerPixel()
Get the bits per pixel of the bitmap. |
|
static int |
getDefaultType()
Query the default Bitmap type for the device. |
|
int |
getHeight()
Retrieves this bitmap's height. |
|
static Bitmap |
getPredefinedBitmap(int predefinedBitmap)
Retrieves one of the predefined system bitmaps. |
|
int |
getType()
Retrieves this bitmap's type. |
|
int |
getWidth()
Retrieves this bitmap's width. |
|
boolean |
hasAlpha()
Tests whether there is an alpha map associated with this Bitmap. |
|
boolean |
isWritable()
Indicates whether the Bitmap object is read-only. |
|
void |
setARGB(int[] data,
int offset,
int scanLength,
int left,
int top,
int width,
int height)
Changes the bitmap to match the data in the provided array. |
|
| Methods inherited from class java.lang.Object |
getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
public static final int ALPHA_BITDEPTH_8BPP
Used as an input to createAlpha to create an 8-bit
alpha channel (8 bit opacity per pixel).
public static final int ALPHA_BITDEPTH_MONO
Used as an input to createAlpha to create a 1-bit
alpha channel (1 bit opacity per pixel).
public static final int COLUMNWISE_MONOCHROME
This bitmap type stores data in pixel wide columns in successive bytes. Each bit in a byte is a pixel value: 0 is white and 1 is black. Uppermost pixels are in the less significant bits within a byte, and lower numbered bytes contain the uppermost pixels within a column.
public static final int ROWWISE_16BIT_COLOR
This bitmap type stores data in rows, with 2 bytes per pixel. A 0 is black and a 0xffff (65535) is white. Each row is padded (if necessary) so that each row is a multiple of 4 bytes in width.
public static final int ROWWISE_MONOCHROME
This bitmap type stores data in rows, with 1 bit per pixel. A 0 is black and 1 is white. Each row is a multiple of 4 bytes. Leftmost pixels are in the less significant bits within a byte, and lower numbered bytes contain the leftmost pixels within a row.
public static final int TRUE_BLACK
public static final int TRUE_WHITE
| Constructor Detail |
public Bitmap(int width,
int height)
width - Width of this bitmap.height - Height of this bitmap.IllegalArgumentException - Thrown if width or height parameters are invalid.
public Bitmap(int type,
int width,
int height)
width - Width of this bitmap.height - Height of this bitmap.type - Type of this bitmap.IllegalArgumentException - Thrown if the width, height, or
the type is invalid.
public Bitmap(int type,
int width,
int height,
byte[] data)
Note that this method makes a copy of your provided bitmap data.
This method requires that the provided data be consistent with the specified bitmap type and dimensions. This includes any necessary padding to ensure that stride breaks occur on DWORD (4-byte) boundaries.
type - Type of this bitmap.width - Width of this bitmap.height - Height of this bitmap.data - Data from which to build this bitmap.IllegalArgumentException - Thrown if the length of the data array is
incorrect, the width or height are invalid, or the type is invalid.| Method Detail |
public void createAlpha(int bitDepth)
Alpha maps can only be set for Bitmaps of type ROWWISE_16BIT_COLOR.
The alpha Bitmap bitdepth must be ALPHA_BITDEPTH_MONO or
ALPHA_BITDEPTH_8BPP, be the same width and height as the image Bitmap,
and must not have an a Bitmap itself.
bitDepth - The bitdepth (pixels per bit) of the alpha data.IllegalArgumentException - If the bitdepth is not valid.public static Bitmap createBitmapFromBytes(byte[] bytes, int offset, int length, int scale)
The image can be optionally downscaled during decoding by an integer scale factor.
bytes - Image data.offset - Start of image data in the passed byte array.length - Length of image data in the passed byte array: -1 means to
the end of the data array.scale - Integer downscale factor: 1 means no scaling.OutOfMemoryError - If insufficient memory to process the image data
into a bitmap.NullPointerException - If the bytes parameter is null.IllegalArgumentException - If the bytes parameter is invalid,
offset or length are invalid.ArithmeticException - is scale is 0.public static Bitmap createBitmapFromPNG(byte[] png, int offset, int length)
png - PNG data.offset - Start of PNG data in the passed byte array.length - Length of PNG data in the passed byte array: -1 means to
the end of the data array.OutOfMemoryError - Thrown if insufficient memory to process the PNG data
into a bitmap.NullPointerException - Thrown if the png parameter is null.IllegalArgumentException - Thrown if the png parameter is invalid, or
offset or length are invalid.public boolean equals(Object obj)
A bitmap is equal to another if the types are the same, the dimensions are the same, and the data is the same.
obj - The object to compare to this bitmap.
public void getARGB(int[] argbData,
int offset,
int scanLength,
int x,
int y,
int width,
int height)
argbData - Array of data where the ARGB data will be stored. Each pixel is stored in 0xAARRGGBB format.offset - Offset into the data to start writing to.scanLength - Width of a scanline within the data array.x - Left edge of rectangle to copy from.y - Top edge of the rectangle to copy from.width - Width of the rectangle to copy from.height - Height of the rectangle to copy from.NullPointerException - Thrown if 'argbData' is null.ArrayIndexOutOfBoundsException - Thrown if the data parameters are invalid.public static Bitmap getBitmapResource(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 bitmap resource.NullPointerException - If the name parameter is null.public static Bitmap getBitmapResource(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 bitmap resource. If
not specified, the name of the calling module is used.name - Name of the bitmap resource.NullPointerException - If the name parameter is null.public int getBitsPerPixel()
public static int getDefaultType()
public int getHeight()
public static Bitmap getPredefinedBitmap(int predefinedBitmap)
predefinedBitmap - System graphic to retrieve. If you specify a
value not currently assigned to a standard system bitmap, this method
returns the INFORMATION bitmap.public int getWidth()
public boolean hasAlpha()
public boolean isWritable()
Readonly bitmaps cannot be drawn to by attaching a Graphics object.
public void setARGB(int[] data,
int offset,
int scanLength,
int left,
int top,
int width,
int height)
data - Array of ARGB data that will be used as the new bitmap data. Each pixel is stored in 0xAARRGGBB format.offset - Offset into the data to start writing to.scanLength - Width of a scanline within the data array.left - Start x position in bitmap for ARGB data.top - Start y position in bitmap for ARGB data.width - Width of ARGB data.height - Height of ARGB data.NullPointerException - if 'data' is null.IllegalArgumentException - if data/coordinates(top,left,width,height) are invalid or bitmap is read-only
|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
Copyright 1999-2008 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.