ImagePart

data class ImagePart : Part


A data class representing an image part of a prompt. This class handles the conversion of various image sources into a Bitmap upon creation.

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

Summary

Public constructors

ImagePart(bitmap: Bitmap)

Creates an ImagePart from a ByteArray.

ImagePart(uri: Uri)

Creates an ImagePart from a Uri.

Public functions

open operator Boolean
equals(other: Any?)

Compares this ImagePart to another object for equality.

open Int

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

Public properties

Bitmap

the internal Bitmap representation of the image.

Int

the height of the image in pixels.

Int

the width of the image in pixels.

Public constructors

ImagePart

ImagePart(bitmap: Bitmap)

ImagePart

ImagePart(blob: ByteArray)

Creates an ImagePart from a ByteArray.

Parameters
blob: ByteArray

the ByteArray of the encoded image.

Throws
java.lang.IllegalArgumentException

if the byte array cannot be decoded into a bitmap.

ImagePart

ImagePart(uri: Uri)

Creates an ImagePart from a Uri. This constructor will perform I/O to decode the image.

Parameters
uri: Uri

the Uri pointing to the image.

Throws
java.io.IOException

if the URI cannot be read.

java.lang.IllegalArgumentException

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
Boolean

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 bitmapBitmap

the internal Bitmap representation of the image.

height

val heightInt

the height of the image in pixels.

width

val widthInt

the width of the image in pixels.