HERE Android SDK Developer's Guide

Image

The class Image is a member of com.here.android.mpa.common .

Class Summary

public final class Image

extends java.lang.Object

Encapsulates an image file.

[For complete information, see the section Class Details]

Nested Class Summary

Table 1. Nested Classes in Image
Nested Classes

public static final enumeration Image.Type

This helps the application know the base type of the Image .

Constructor Summary

Table 2. Constructors in Image
Constructors

Image ()

Public Constructor

Method Summary

Table 3. Methods in Image
Methods

public boolean equals (Object other)

For documentation, see java.lang.Object

public Bitmap getBitmap (int width, int height)

Creates a new Bitmap object with the given dimension from this Image .

public Bitmap getBitmap ()

Creates an android.graphics.Bitmap from this Image if the type is BITMAP, null otherwise.

public long getHeight ()

Gets the current height of the Image , in pixels.

public Type getType ()

Gets the file type of this Image.

public long getWidth ()

Gets the current width of the Image , in pixels.

public int hashCode ()

For documentation, see java.lang.Object

public boolean isValid ()

Determines whether the Image object contains a valid image.

public boolean setBitmap (Bitmap bitmap)

Sets a Bitmap for the Image .

public void setCategory (IconCategory category)

Sets IconCategory for the Image .

public void setImageAsset (String assetName)

Sets Image data by an image in the assets directory.

public void setImageData (byte[] bytes)

Sets an array of byte data for the Image .

public void setImageFile (String fileName)

Sets Image data by an image file located in the internal storage.

public void setImageResource (int id)

Sets data for the Image by way of an application's resource.

public void setLocalUrl (String localUrl)

Sets a local URL that the Image can access for an image.

Class Details

Encapsulates an image file.

An Image object can only be created with BMP, JPEG, and PNG data formats. However, although these 3 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:

  • BMP v3 (standard BMP) with 24/32 bits per pixel without compression
  • BMP v4/v5 (newer BMP formats) with 24/32 bits per pixel, bit fields compression and A8R8G8B8 pixel format

Constructor Details

Image ()

Public Constructor

Method Details

public boolean equals (Object other)

For documentation, see java.lang.Object

Parameters:

  • other

public Bitmap getBitmap (int width, int height)

Creates a new Bitmap object with the given dimension from this Image . This method only supports Image s of SVG. null is returned for Image s not of the supported type(s).

Parameters:

  • width

    The width (in pixels) of the new Bitmap to be created.

  • height

    The height (in pixels) of the new Bitmap to be created.

Returns:

A new Bitmap object of the Image.

public Bitmap getBitmap ()

Creates an android.graphics.Bitmap from this Image if the type is BITMAP, null otherwise.

Returns:

An android.graphics.Bitmap or null if this Image is not BITMAP.

public long getHeight ()

Gets the current height of the Image , in pixels.

Returns:

The current height

public Type getType ()

Gets the file type of this Image.

Returns:

The Image.Type for this Image object.

public long getWidth ()

Gets the current width of the Image , in pixels.

Returns:

The current width

public int hashCode ()

For documentation, see java.lang.Object

public boolean isValid ()

Determines whether the Image object contains a valid image.

Returns:

True if the Image object is valid and can render an image, false otherwise

public boolean setBitmap (Bitmap bitmap)

Sets a Bitmap for the Image .

Parameters:

  • bitmap

    A Bitmap to be used by the Image

Returns:

True if the Bitmap is set successfully, false otherwise

public void setCategory (IconCategory category)

Sets IconCategory for the Image .

Parameters:

  • category

    An category (such as "museum") for the icon image.

public void setImageAsset (String assetName)

Sets Image data by an image in the assets directory. In particular, this calls openFileInput(String).

SVG format files are not supported.

Parameters:

  • assetName

    The name of an image in the assets directory.

Throws:

  • IOException

    throws exception when failure to read the resource

public void setImageData (byte[] bytes)

Sets an array of byte data for the Image .

Only JPEG, BMP and PNG formats are supported.

Parameters:

  • bytes

    An array of byte data containing the Image

public void setImageFile (String fileName)

Sets Image data by an image file located in the internal storage. In particular, this calls openFileInput(String).

SVG format files are not supported.

Parameters:

  • fileName

    The name of the image file.

Throws:

  • IOException

    throws exception when failure to read the resource

public void setImageResource (int id)

Sets data for the Image by way of an application's resource.

Parameters:

  • id

    An ID for the resource

Throws:

  • IOException

    Upon a failure to read the resource

public void setLocalUrl (String localUrl)

Sets a local URL that the Image can access for an image.

SVG format files are not supported.

Parameters:

  • localUrl

    The local URL that the Image uses