# ImagePart


```
data class ImagePart : Part
```

<br />

|---|---|---|
| [kotlin.Any](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-any/index.html) |||
| ↳ | [com.google.mlkit.genai.prompt.Part](https://developers.google.com/android/reference/kotlin/com/google/mlkit/genai/prompt/Part) ||
|   | ↳ | [com.google.mlkit.genai.prompt.ImagePart](https://developers.google.com/android/reference/kotlin/com/google/mlkit/genai/prompt/ImagePart) |

*** ** * ** ***

A data class representing an image part of a prompt. This class handles the conversion of various image sources into a `https://developer.android.com/reference/android/graphics/Bitmap.html` upon creation.

Note: Equality is determined by the content of the bitmap (`sameAs`), not by reference.

## Summary

| ### Public constructors |
|---|
| `https://developers.google.com/android/reference/kotlin/com/google/mlkit/genai/prompt/ImagePart#ImagePart(android.graphics.Bitmap)(bitmap: https://developer.android.com/reference/android/graphics/Bitmap.html)` |
| `https://developers.google.com/android/reference/kotlin/com/google/mlkit/genai/prompt/ImagePart#ImagePart(kotlin.ByteArray)(blob: https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-byte-array/index.html)` Creates an `https://developers.google.com/android/reference/kotlin/com/google/mlkit/genai/prompt/ImagePart` from a `https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-byte-array/index.html`. |
| `https://developers.google.com/android/reference/kotlin/com/google/mlkit/genai/prompt/ImagePart#ImagePart(android.net.Uri)(uri: https://developer.android.com/reference/android/net/Uri.html)` Creates an `https://developers.google.com/android/reference/kotlin/com/google/mlkit/genai/prompt/ImagePart` from a `https://developer.android.com/reference/android/net/Uri.html`. |

| ### Public functions |
|---|---|
| `open operator https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-boolean/index.html` | `https://developers.google.com/android/reference/kotlin/com/google/mlkit/genai/prompt/ImagePart#equals(kotlin.Any)(other: https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-any/index.html?)` Compares this ImagePart to another object for equality. |
| `open https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-int/index.html` | `https://developers.google.com/android/reference/kotlin/com/google/mlkit/genai/prompt/ImagePart#hashCode()()` Returns a hash code value for the object, consistent with the overridden `equals` method. |

| ### Public properties |
|---|---|
| `https://developer.android.com/reference/android/graphics/Bitmap.html` | `https://developers.google.com/android/reference/kotlin/com/google/mlkit/genai/prompt/ImagePart#bitmap()` the internal `https://developer.android.com/reference/android/graphics/Bitmap.html` representation of the image. |
| `https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-int/index.html` | `https://developers.google.com/android/reference/kotlin/com/google/mlkit/genai/prompt/ImagePart#height()` the height of the image in pixels. |
| `https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-int/index.html` | `https://developers.google.com/android/reference/kotlin/com/google/mlkit/genai/prompt/ImagePart#width()` the width of the image in pixels. |

## Public constructors

### ImagePart

```
ImagePart(bitmap: Bitmap)
```

### ImagePart

```
ImagePart(blob: ByteArray)
```

Creates an `https://developers.google.com/android/reference/kotlin/com/google/mlkit/genai/prompt/ImagePart` from a `https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-byte-array/index.html`.

| Parameters |
|---|---|
| `blob: https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-byte-array/index.html` | the `https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-byte-array/index.html` of the encoded image. |

| Throws |
|---|---|
| `https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-illegal-argument-exception/index.html` | if the byte array cannot be decoded into a bitmap. |

### ImagePart

```
ImagePart(uri: Uri)
```

Creates an `https://developers.google.com/android/reference/kotlin/com/google/mlkit/genai/prompt/ImagePart` from a `https://developer.android.com/reference/android/net/Uri.html`. This constructor will perform I/O to decode the image.

| Parameters |
|---|---|
| `uri: https://developer.android.com/reference/android/net/Uri.html` | the `https://developer.android.com/reference/android/net/Uri.html` pointing to the image. |

| Throws |
|---|---|
| `https://developer.android.com/reference/java/io/IOException.html` | if the URI cannot be read. |
| `https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-illegal-argument-exception/index.html` | if the data from the URI cannot be decoded into a bitmap. |

## Public functions

### equals

```
open operator fun equals(other: Any?): Boolean
```

Compares this ImagePart to another object for equality.

| Returns |
|---|---|
| `https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-boolean/index.html` | `true` if the other object is an `ImagePart` and their bitmaps have the same dimensions, configuration, and pixel data. |

### hashCode

```
open fun hashCode(): Int
```

Returns a hash code value for the object, consistent with the overridden `equals` method.

## Public properties

### bitmap

```
val bitmap: Bitmap
```

the internal `https://developer.android.com/reference/android/graphics/Bitmap.html` representation of the image.

### height

```
val height: Int
```

the height of the image in pixels.

### width

```
val width: Int
```

the width of the image in pixels.