Stay organized with collections Save and categorize content based on your preferences.

ImageProxy

@RequiresApi(value = 21)
public interface ImageProxy extends AutoCloseable


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

Summary

Nested types

public interface ImageProxy.PlaneProxy

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

Public methods

abstract void

Closes the underlying android.media.Image.

abstract @NonNull Rect

Returns the crop rectangle.

abstract int

Returns the image format.

abstract int

Returns the image height.

abstract @Nullable Image

Returns the android Image.

abstract @NonNull ImageInfo

Returns the ImageInfo.

abstract @NonNull ImageProxy.PlaneProxy[]

Returns the array of planes.

abstract int

Returns the image width.

abstract void

Sets the crop rectangle.

Public methods

close

abstract void close()

Closes the underlying android.media.Image.

See also
close

getCropRect

abstract @NonNull Rect getCropRect()

Returns the crop rectangle.

See also
getCropRect

getFormat

abstract int getFormat()

Returns the image format.

The image format can be one of the android.graphics.ImageFormat or android.graphics.PixelFormat constants.

See also
getFormat

getHeight

abstract int getHeight()

Returns the image height.

See also
getHeight

getImage

@ExperimentalGetImage
abstract @Nullable 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 android.media.ImageReader. So an Image obtained with this method will behave as such.

Returns
@Nullable Image

the android image.

See also
close

getImageInfo

abstract @NonNull ImageInfo getImageInfo()

Returns the ImageInfo.

getPlanes

abstract @NonNull ImageProxy.PlaneProxy[] getPlanes()

Returns the array of planes.

See also
getPlanes

getWidth

abstract int getWidth()

Returns the image width.

See also
getWidth

setCropRect

abstract void setCropRect(@Nullable Rect rect)

Sets the crop rectangle.

See also
setCropRect