public final class Image
extends java.lang.Object
Note: although BMP, JPEG and PNG data formats are supported, only basic parsing of a BMP header is done (gamma correction and color profile information are ignored), and supported BMP data formats are limited to:
Modifier and Type | Class and Description |
---|---|
static class |
Image.Type
This helps the application know the base type of the
Image . |
Constructor and Description |
---|
Image() |
Modifier and Type | Method and Description |
---|---|
android.graphics.Bitmap |
getBitmap()
Creates an
android.graphics.Bitmap from this Image if the type is
Image.Type.BITMAP , null otherwise. |
long |
getHeight()
Gets the current height of the
Image , in pixels. |
Image.Type |
getType()
Gets the file type of this
Image . |
long |
getWidth()
Gets the current width of the
Image , in pixels. |
boolean |
isValid()
Determines whether the
Image object contains a valid image. |
boolean |
setBitmap(android.graphics.Bitmap bitmap)
Sets a
Bitmap for the Image . |
void |
setImageAsset(java.lang.String assetName)
Sets Image data by an image in the assets directory.
|
void |
setImageData(byte[] bytes)
Sets an array of
byte data for the Image . |
void |
setImageFile(java.lang.String fileName)
Sets Image data by an image file located in the internal storage.
|
void |
setImageResource(int id)
Sets data for the
Image by way of an application's resource. |
void |
setLocalUrl(java.lang.String localUrl)
Sets a local URL that the
Image can access for an image. |
public boolean setBitmap(android.graphics.Bitmap bitmap)
Bitmap
for the Image
.bitmap
- A Bitmap
to be used by the Image
Bitmap
is set successfully, false otherwisepublic void setImageData(byte[] bytes)
byte
data for the Image
.
Note: JPEG and BMP are supported.
bytes
- An array of byte
data containing the Image
public void setImageResource(int id) throws java.io.IOException
Image
by way of an application's resource.id
- An ID for the resourcejava.io.IOException
- Upon a failure to read the resource.public void setImageFile(java.lang.String fileName) throws java.io.IOException
fileName
- The name of the image file.java.io.IOException
- On failure to read the resource.public void setImageAsset(java.lang.String assetName) throws java.io.IOException
assetName
- The name of an image in the assets directory.java.io.IOException
- on failure to read the resource.public void setLocalUrl(java.lang.String localUrl)
Image
can access for an image.localUrl
- The local URL that the Image
usespublic boolean isValid()
Image
object contains a valid image.Image
object is valid and can render an image, false otherwisepublic long getHeight()
Image
, in pixels.public long getWidth()
Image
, in pixels.public android.graphics.Bitmap getBitmap()
android.graphics.Bitmap
from this Image
if the type is
Image.Type.BITMAP
, null otherwise.android.graphics.Bitmap
or null if this Image
is not
Image.Type.BITMAP
.public Image.Type getType()
Image
.Image.Type
for this Image
object.