# BitmapMlImageBuilder

public class **BitmapMlImageBuilder** Builds `MlImage` from `Bitmap`.

You can pass in either mutable or immutable `Bitmap`. However once
`Bitmap` is passed in, to keep data integrity you shouldn't modify content
in it.

Use `BitmapExtractor` to get `Bitmap` you passed in.

<br />

<br />

### Public Constructors

|---|---|
|   | [BitmapMlImageBuilder](https://developers.google.com/edge/api/tflite/java/com/google/android/odml/image/BitmapMlImageBuilder.md.txt#BitmapMlImageBuilder(Bitmap))(Bitmap bitmap) Creates the builder with a mandatory `Bitmap`. |
|   | [BitmapMlImageBuilder](https://developers.google.com/edge/api/tflite/java/com/google/android/odml/image/BitmapMlImageBuilder.md.txt#BitmapMlImageBuilder(Context,%20Uri))(Context context, Uri uri) Creates the builder to build `MlImage` from a file. |

### Public Methods

|---|---|
| [MlImage](https://developers.google.com/edge/api/tflite/java/com/google/android/odml/image/MlImage.md.txt) | [build](https://developers.google.com/edge/api/tflite/java/com/google/android/odml/image/BitmapMlImageBuilder.md.txt#build())() Builds an `MlImage` instance. |
| [BitmapMlImageBuilder](https://developers.google.com/edge/api/tflite/java/com/google/android/odml/image/BitmapMlImageBuilder.md.txt) | [setRotation](https://developers.google.com/edge/api/tflite/java/com/google/android/odml/image/BitmapMlImageBuilder.md.txt#setRotation(int))(int rotation) Sets value for `MlImage.getRotation()`. |

### 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() |

## Public Constructors

#### public
**BitmapMlImageBuilder**
(Bitmap bitmap)

Creates the builder with a mandatory `Bitmap`.

Also calls `setRotation(int)` to set the optional properties. If not set, the values
will be set with default:

- rotation: 0

<br />

<br />

##### Parameters

| bitmap | image data object. |
|---|---|

#### public
**BitmapMlImageBuilder**
(Context context, Uri uri)

Creates the builder to build `MlImage` from a file.

Also calls `setRotation(int)` to set the optional properties. If not set, the values
will be set with default:

- rotation: 0

<br />

<br />

##### Parameters

| context | the application context. |
| uri | the path to the resource file. |
|---|---|

##### Throws

| [IOException](https://developer.android.com/reference/java/io/IOException.html) |   |
|---|---|

## Public Methods

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

Builds an `MlImage` instance.

#### public [BitmapMlImageBuilder](https://developers.google.com/edge/api/tflite/java/com/google/android/odml/image/BitmapMlImageBuilder.md.txt)
**setRotation**
(int rotation)

Sets value for `MlImage.getRotation()`.

##### Parameters

| rotation |   |
|---|---|

##### Throws

| [IllegalArgumentException](https://developer.android.com/reference/java/lang/IllegalArgumentException.html) | if the rotation value is not 0, 90, 180 or 270. |
|---|---|