public class **MlImage** Wraps image data for on-device machine learning (ODML) usages.

`https://developers.google.com/edge/api/tflite/java/com/google/android/odml/image/MlImage` is designed to be an immutable image container, which could be shared
cross-platforms, among different Google ODML frameworks(TFLite Support, MLKit).

It is a common abstraction image that could help to chain different frameworks that adapts
`https://developers.google.com/edge/api/tflite/java/com/google/android/odml/image/MlImage` together.

To construct an `https://developers.google.com/edge/api/tflite/java/com/google/android/odml/image/MlImage`, use the provided builders:

- `https://developers.google.com/edge/api/tflite/java/com/google/android/odml/image/ByteBufferMlImageBuilder`
- `https://developers.google.com/edge/api/tflite/java/com/google/android/odml/image/BitmapMlImageBuilder`
- `https://developers.google.com/edge/api/tflite/java/com/google/android/odml/image/MediaMlImageBuilder`

`https://developers.google.com/edge/api/tflite/java/com/google/android/odml/image/MlImage` uses reference counting to maintain internal storage. When it is created the
reference count is 1. Developer can call `https://developers.google.com/edge/api/tflite/java/com/google/android/odml/image/MlImage#close()` to reduce reference count to release
internal storage earlier, otherwise Java garbage collection will release the storage eventually.

To extract concrete image, first check `https://developers.google.com/edge/api/tflite/java/com/google/android/odml/image/MlImage.StorageType` and then use the provided
extractors:

- `https://developers.google.com/edge/api/tflite/java/com/google/android/odml/image/ByteBufferExtractor`
- `https://developers.google.com/edge/api/tflite/java/com/google/android/odml/image/BitmapExtractor`
- `https://developers.google.com/edge/api/tflite/java/com/google/android/odml/image/MediaImageExtractor`

In future release, `https://developers.google.com/edge/api/tflite/java/com/google/android/odml/image/MlImage` will support internal conversion(e.g. Bitmap -\> ByteBuffer) and multiple storages.

<br />

<br />

<br />

<br />

<br />

<br />

### Nested Classes

|---|---|---|---|
| @interface | [MlImage.ImageFormat](https://developers.google.com/edge/api/tflite/java/com/google/android/odml/image/MlImage.ImageFormat) || Specifies the image format of an image. |
| class | [MlImage.Internal](https://developers.google.com/edge/api/tflite/java/com/google/android/odml/image/MlImage.Internal) || Advanced API access for `https://developers.google.com/edge/api/tflite/java/com/google/android/odml/image/MlImage`. |
| @interface | [MlImage.StorageType](https://developers.google.com/edge/api/tflite/java/com/google/android/odml/image/MlImage.StorageType) || Specifies the image container type. |

### Constants

|---|---|---|
| int | [IMAGE_FORMAT_ALPHA](https://developers.google.com/edge/api/tflite/java/com/google/android/odml/image/MlImage#IMAGE_FORMAT_ALPHA) |   |
| int | [IMAGE_FORMAT_JPEG](https://developers.google.com/edge/api/tflite/java/com/google/android/odml/image/MlImage#IMAGE_FORMAT_JPEG) |   |
| int | [IMAGE_FORMAT_NV12](https://developers.google.com/edge/api/tflite/java/com/google/android/odml/image/MlImage#IMAGE_FORMAT_NV12) |   |
| int | [IMAGE_FORMAT_NV21](https://developers.google.com/edge/api/tflite/java/com/google/android/odml/image/MlImage#IMAGE_FORMAT_NV21) |   |
| int | [IMAGE_FORMAT_RGB](https://developers.google.com/edge/api/tflite/java/com/google/android/odml/image/MlImage#IMAGE_FORMAT_RGB) |   |
| int | [IMAGE_FORMAT_RGBA](https://developers.google.com/edge/api/tflite/java/com/google/android/odml/image/MlImage#IMAGE_FORMAT_RGBA) |   |
| int | [IMAGE_FORMAT_UNKNOWN](https://developers.google.com/edge/api/tflite/java/com/google/android/odml/image/MlImage#IMAGE_FORMAT_UNKNOWN) |   |
| int | [IMAGE_FORMAT_YUV_420_888](https://developers.google.com/edge/api/tflite/java/com/google/android/odml/image/MlImage#IMAGE_FORMAT_YUV_420_888) |   |
| int | [IMAGE_FORMAT_YV12](https://developers.google.com/edge/api/tflite/java/com/google/android/odml/image/MlImage#IMAGE_FORMAT_YV12) |   |
| int | [IMAGE_FORMAT_YV21](https://developers.google.com/edge/api/tflite/java/com/google/android/odml/image/MlImage#IMAGE_FORMAT_YV21) |   |
| int | [STORAGE_TYPE_BITMAP](https://developers.google.com/edge/api/tflite/java/com/google/android/odml/image/MlImage#STORAGE_TYPE_BITMAP) |   |
| int | [STORAGE_TYPE_BYTEBUFFER](https://developers.google.com/edge/api/tflite/java/com/google/android/odml/image/MlImage#STORAGE_TYPE_BYTEBUFFER) |   |
| int | [STORAGE_TYPE_IMAGE_PROXY](https://developers.google.com/edge/api/tflite/java/com/google/android/odml/image/MlImage#STORAGE_TYPE_IMAGE_PROXY) |   |
| int | [STORAGE_TYPE_MEDIA_IMAGE](https://developers.google.com/edge/api/tflite/java/com/google/android/odml/image/MlImage#STORAGE_TYPE_MEDIA_IMAGE) |   |

### Public Methods

|---|---|
| synchronized void | [close](https://developers.google.com/edge/api/tflite/java/com/google/android/odml/image/MlImage#close())() Removes a reference that was previously acquired or init. |
| [List](https://developer.android.com/reference/java/util/List.html)\<[ImageProperties](https://developers.google.com/edge/api/tflite/java/com/google/android/odml/image/ImageProperties)\> | [getContainedImageProperties](https://developers.google.com/edge/api/tflite/java/com/google/android/odml/image/MlImage#getContainedImageProperties())() Returns a list of supported image properties for this `https://developers.google.com/edge/api/tflite/java/com/google/android/odml/image/MlImage`. |
| int | [getHeight](https://developers.google.com/edge/api/tflite/java/com/google/android/odml/image/MlImage#getHeight())() Returns the height of the image. |
| [MlImage.Internal](https://developers.google.com/edge/api/tflite/java/com/google/android/odml/image/MlImage.Internal) | [getInternal](https://developers.google.com/edge/api/tflite/java/com/google/android/odml/image/MlImage#getInternal())() Gets `https://developers.google.com/edge/api/tflite/java/com/google/android/odml/image/MlImage.Internal` object which contains internal APIs. |
| int | [getRotation](https://developers.google.com/edge/api/tflite/java/com/google/android/odml/image/MlImage#getRotation())() Returns the rotation value attached to the image. |
| int | [getWidth](https://developers.google.com/edge/api/tflite/java/com/google/android/odml/image/MlImage#getWidth())() Returns the width of the image. |

### Inherited Methods

From class java.lang.Object

|---|---|
| boolean | equals([Object](https://developer.android.com/reference/java/lang/Object.html) arg0) |
| final [Class](https://developer.android.com/reference/java/lang/Class.html)\<?\> | getClass() |
| int | hashCode() |
| final void | notify() |
| final void | notifyAll() |
| [String](https://developer.android.com/reference/java/lang/String.html) | toString() |
| final void | wait(long arg0, int arg1) |
| final void | wait(long arg0) |
| final void | wait() |

From interface java.io.Closeable

|---|---|
| abstract void | close() |

From interface java.lang.AutoCloseable

|---|---|
| abstract void | close() |

## Constants

#### public static final int
**IMAGE_FORMAT_ALPHA**

<br />

Constant Value: 8

#### public static final int
**IMAGE_FORMAT_JPEG**

<br />

Constant Value: 9

#### public static final int
**IMAGE_FORMAT_NV12**

<br />

Constant Value: 3

#### public static final int
**IMAGE_FORMAT_NV21**

<br />

Constant Value: 4

#### public static final int
**IMAGE_FORMAT_RGB**

<br />

Constant Value: 2

#### public static final int
**IMAGE_FORMAT_RGBA**

<br />

Constant Value: 1

#### public static final int
**IMAGE_FORMAT_UNKNOWN**

<br />

Constant Value: 0

#### public static final int
**IMAGE_FORMAT_YUV_420_888**

<br />

Constant Value: 7

#### public static final int
**IMAGE_FORMAT_YV12**

<br />

Constant Value: 5

#### public static final int
**IMAGE_FORMAT_YV21**

<br />

Constant Value: 6

#### public static final int
**STORAGE_TYPE_BITMAP**

<br />

Constant Value: 1

#### public static final int
**STORAGE_TYPE_BYTEBUFFER**

<br />

Constant Value: 2

#### public static final int
**STORAGE_TYPE_IMAGE_PROXY**

<br />

Constant Value: 4

#### public static final int
**STORAGE_TYPE_MEDIA_IMAGE**

<br />

Constant Value: 3

## Public Methods

#### public synchronized void
**close**
()

Removes a reference that was previously acquired or init.

When `https://developers.google.com/edge/api/tflite/java/com/google/android/odml/image/MlImage` is created, it has 1 reference count.

When the reference count becomes 0, it will release the resource under the hood.

<br />

<br />

#### public [List](https://developer.android.com/reference/java/util/List.html)\<[ImageProperties](https://developers.google.com/edge/api/tflite/java/com/google/android/odml/image/ImageProperties)\>
**getContainedImageProperties**
()

Returns a list of supported image properties for this `https://developers.google.com/edge/api/tflite/java/com/google/android/odml/image/MlImage`.

Currently `https://developers.google.com/edge/api/tflite/java/com/google/android/odml/image/MlImage` only support single storage type so the size of return list will
always be 1.

<br />

##### See Also

- `https://developers.google.com/edge/api/tflite/java/com/google/android/odml/image/ImageProperties`

#### public int
**getHeight**
()

Returns the height of the image.

#### public [MlImage.Internal](https://developers.google.com/edge/api/tflite/java/com/google/android/odml/image/MlImage.Internal)
**getInternal**
()

Gets `https://developers.google.com/edge/api/tflite/java/com/google/android/odml/image/MlImage.Internal` object which contains internal APIs.

#### public int
**getRotation**
()

Returns the rotation value attached to the image. Rotation value will be 0, 90, 180, 270.

#### public int
**getWidth**
()

Returns the width of the image.