ImageWrapper


public interface ImageWrapper extends 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 methods

abstract void

Closes the underlying image and releases any associated resources.

abstract @NonNull Rect

The crop rectangle of the image.

default int

The dataspace associated with this image.

abstract int

The format of the image.

default HardwareBuffer

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

abstract int

The height of the image in pixels.

abstract @NonNull List<@NonNull ImagePlane>

The list of pixel planes for this image.

default SyncFence

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

abstract long

The timestamp associated with this image, in nanoseconds.

abstract int

The width of the image in pixels.

Inherited methods

From androidx.camera.common.UnsafeWrapper
abstract T
<T extends Object> unwrapAs(@NonNull Class<@NonNull T> type)

Attempts to unwrap this object into the specified underlying type.

Public methods

close

Added in 1.7.0-alpha03
abstract void close()

Closes the underlying image and releases any associated resources.

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

getCropRect

Added in 1.7.0-alpha03
abstract @NonNull Rect getCropRect()

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

getDataSpace

Added in 1.7.0-alpha03
default int getDataSpace()

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.

getFormat

Added in 1.7.0-alpha03
abstract int getFormat()

The format of the image.

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

getHardwareBuffer

Added in 1.7.0-alpha03
default HardwareBuffer getHardwareBuffer()

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.

getHeight

Added in 1.7.0-alpha03
abstract int getHeight()

The height of the image in pixels.

See also
getHeight

getImagePlanes

Added in 1.7.0-alpha03
abstract @NonNull List<@NonNull ImagePlanegetImagePlanes()

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

getSyncFence

Added in 1.7.0-alpha03
default SyncFence getSyncFence()

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

getTimestamp

Added in 1.7.0-alpha03
abstract long getTimestamp()

The timestamp associated with this image, in nanoseconds.

See also
getTimestamp

getWidth

Added in 1.7.0-alpha03
abstract int getWidth()

The width of the image in pixels.

See also
getWidth