Register now for Android Dev Summit 2019!

ImageProxy

interface ImageProxy : AutoCloseable
androidx.camera.core.ImageProxy

An image proxy which has an analogous interface as android.media.Image.

Summary

Nested classes

abstract

A plane proxy which has an analogous interface as android.media.Image.Plane.

Public methods

abstract Unit

Closes the underlying android.media.Image.

abstract Rect!

Returns the crop rectangle.

abstract Int

Returns the image format.

abstract Int

Returns the image height.

abstract Image?

Returns the android Image.

abstract ImageInfo?

Returns the ImageInfo.

abstract Array<ImageProxy.PlaneProxy!>!

Returns the array of planes.

abstract Long

Returns the timestamp.

abstract Int

Returns the image width.

abstract Unit
setCropRect(rect: Rect!)

Sets the crop rectangle.

abstract Unit
setTimestamp(timestamp: Long)

Sets the timestamp.

Public methods

close

abstract fun close(): Unit

Closes the underlying android.media.Image.

If obtained from an ImageAnalysis.Analyzer the image will be closed on return from the ImageAnalysis.Analyzer function.

@see android.media.Image#close().

getCropRect

abstract fun getCropRect(): Rect!

Returns the crop rectangle.

@see android.media.Image#getCropRect().

getFormat

abstract fun getFormat(): Int

Returns the image format.

@see android.media.Image#getFormat().

getHeight

abstract fun getHeight(): Int

Returns the image height.

@see android.media.Image#getHeight().

getImage

@Nullable abstract fun getImage(): Image?

Returns the android Image.

If the ImageProxy is a wrapper for an android Image, it will return the Image. It is possible for an ImageProxy to wrap something that isn't an Image. If that's the case then it will return null.

The returned image should not be closed by the application. Instead it should be closed by the ImageProxy, which happens, for example, on return from the ImageAnalysis.Analyzer function. Destroying the ImageAnalysis will close the underlying android.media.ImageReader. So an Image obtained with this method will behave as such @see android.media.Image#close().

Return
Image?: the android image.

getImageInfo

@Nullable abstract fun getImageInfo(): ImageInfo?

Returns the ImageInfo.

Will be null if there is no associated additional metadata.

getPlanes

abstract fun getPlanes(): Array<ImageProxy.PlaneProxy!>!

Returns the array of planes.

@see android.media.Image#getPlanes().

getTimestamp

abstract fun getTimestamp(): Long

Returns the timestamp.

@see android.media.Image#getTimestamp().

getWidth

abstract fun getWidth(): Int

Returns the image width.

@see android.media.Image#getWidth().

setCropRect

abstract fun setCropRect(rect: Rect!): Unit

Sets the crop rectangle.

@see android.media.Image#setCropRect(Rect).

setTimestamp

abstract fun setTimestamp(timestamp: Long): Unit

Sets the timestamp.

@see android.media.Image#setTimestamp(long).