ImageWrapper


interface ImageWrapper : UnsafeWrapper, AutoCloseable

Known direct subclasses
ImageProxy

An image proxy which has a similar interface as android.media.Image.

MutableImageWrapper

A mutable extension of ImageWrapper that allows modifying properties of the image.

Known indirect subclasses
FakeImage

Fake implementation of MutableImageWrapper for testing.


A wrapper interface that mirrors the primary read-only properties of Image.

This wrapper abstracts the underlying platform image format to support common operations and ease testing by allowing mocking.

Summary

Public functions

Unit

Closes the underlying image and releases any associated resources.

Public properties

Rect

The crop rectangle of the image.

open Int

The dataspace associated with this image.

Int

The format of the image.

open HardwareBuffer?

The handle to the underlying image's hardware buffer, or null if this image does not support hardware buffers.

Int

The height of the image in pixels.

List<ImagePlane>

The list of pixel planes for this image.

open SyncFence?

The sync fence associated with this image, or null if there is no fence.

Long

The timestamp associated with this image, in nanoseconds.

Int

The width of the image in pixels.

Inherited functions

From androidx.camera.common.UnsafeWrapper
T?
<T : Any> unwrapAs(type: Class<T>)

Attempts to unwrap this object into the specified underlying type.

Public functions

close

Added in 1.7.0-alpha03
fun close(): Unit

Closes the underlying image and releases any associated resources.

Overridden to remove the checked Exception from the throws clause for Java callers.

Public properties

cropRect

Added in 1.7.0-alpha03
val cropRectRect

The crop rectangle of the image.

The crop rectangle defines the region of the image that contains valid pixel data. If not set, it defaults to the full size of the image.

See also
getCropRect

dataSpace

Added in 1.7.0-alpha03
open val dataSpaceInt

The dataspace associated with this image.

The dataspace defines how the color components of the image should be interpreted.

The value returned is one of the constants defined in ImageDataSpace.

format

Added in 1.7.0-alpha03
val formatInt

The format of the image.

The value returned is one of the constants defined in ImageFormat.

hardwareBuffer

Added in 1.7.0-alpha03
open val hardwareBufferHardwareBuffer?

The handle to the underlying image's hardware buffer, or null if this image does not support hardware buffers.

The HardwareBuffer follows the lifecycle of its associated ImageWrapper. It is not required to be closed explicitly; however, the ImageWrapper must not be closed while the hardware buffer is still in use.

height

Added in 1.7.0-alpha03
val heightInt

The height of the image in pixels.

See also
getHeight

imagePlanes

Added in 1.7.0-alpha03
val imagePlanesList<ImagePlane>

The list of pixel planes for this image.

The number of planes is determined by the format of the image. For example, YUV images usually have three planes (Y, U, V), while RGB or JPEG images typically have a single plane.

See also
getPlanes

syncFence

Added in 1.7.0-alpha03
open val syncFenceSyncFence?

The sync fence associated with this image, or null if there is no fence.

The sync fence is used to coordinate access to the image data, ensuring that the producer has finished writing before the consumer starts reading, or vice versa.

See also
getFence

timestamp

Added in 1.7.0-alpha03
val timestampLong

The timestamp associated with this image, in nanoseconds.

See also
getTimestamp

width

Added in 1.7.0-alpha03
val widthInt

The width of the image in pixels.

See also
getWidth