Android Dev Summit, October 23-24: two days of technical content, directly from the Android team. Sign-up for livestream updates.

ImageProxy

public interface ImageProxy
implements AutoCloseable

androidx.camera.core.ImageProxy


An image proxy which has an analogous interface as Image.

Summary

Nested classes

interface ImageProxy.PlaneProxy

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

Public methods

abstract void close()

Closes the underlying Image.

abstract Rect getCropRect()

Returns the crop rectangle.

abstract int getFormat()

Returns the image format.

abstract int getHeight()

Returns the image height.

abstract Image getImage()

Returns the android Image.

abstract ImageInfo getImageInfo()

Returns the ImageInfo.

abstract PlaneProxy[] getPlanes()

Returns the array of planes.

abstract long getTimestamp()

Returns the timestamp.

abstract int getWidth()

Returns the image width.

abstract void setCropRect(Rect rect)

Sets the crop rectangle.

abstract void setTimestamp(long timestamp)

Sets the timestamp.

Inherited methods

Public methods

close

public abstract void close ()

Closes the underlying Image.

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

@see Image.close().

getCropRect

public abstract Rect getCropRect ()

Returns the crop rectangle.

@see Image.getCropRect().

Returns
Rect

getFormat

public abstract int getFormat ()

Returns the image format.

@see Image.getFormat().

Returns
int

getHeight

public abstract int getHeight ()

Returns the image height.

@see Image.getHeight().

Returns
int

getImage

public abstract Image getImage ()

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 ImageReader. So an Image obtained with this method will behave as such @see Image.close().

Returns
Image the android image.

getImageInfo

public abstract ImageInfo getImageInfo ()

Returns the ImageInfo.

Will be null if there is no associated additional metadata.

Returns
ImageInfo

getPlanes

public abstract PlaneProxy[] getPlanes ()

Returns the array of planes.

@see Image.getPlanes().

Returns
PlaneProxy[]

getTimestamp

public abstract long getTimestamp ()

Returns the timestamp.

@see Image.getTimestamp().

Returns
long

getWidth

public abstract int getWidth ()

Returns the image width.

@see Image.getWidth().

Returns
int

setCropRect

public abstract void setCropRect (Rect rect)

Sets the crop rectangle.

@see Image.setCropRect(Rect).

Parameters
rect Rect

setTimestamp

public abstract void setTimestamp (long timestamp)

Sets the timestamp.

@see Image.setTimestamp(long).

Parameters
timestamp long