Android.Media.ImageReader.AcquireLatestImage Method

Syntax

[Android.Runtime.Register("acquireLatestImage", "()Landroid/media/Image;", "GetAcquireLatestImageHandler")]
public virtual Image AcquireLatestImage ()

Returns

Documentation for this section has not yet been entered.

Exceptions

TypeReason
Java.Lang.IllegalStateExceptionif too many images are currently acquired

Remarks

Acquire the latest Android.Media.Image from the ImageReader's queue, dropping older Android.Media.Image. Returns null if no new image is available.

This operation will acquire all the images possible from the ImageReader, but ImageReader.Close all images that aren't the latest. This function is recommended to use over ImageReader.AcquireNextImage for most use-cases, as it's more suited for real-time processing.

Note that ImageReader.MaxImages should be at least 2 for ImageReader.AcquireLatestImage to be any different than ImageReader.AcquireNextImage - discarding all-but-the-newest Android.Media.Image requires temporarily acquiring two Android.Media.Image at once. Or more generally, calling ImageReader.AcquireLatestImage with less than two images of margin, that is (maxImages - currentAcquiredImages will not discard as expected.

This operation will fail by throwing an Java.Lang.IllegalStateException if maxImages have been acquired with ImageReader.AcquireLatestImage or ImageReader.AcquireNextImage. In particular a sequence of ImageReader.AcquireLatestImage calls greater than ImageReader.MaxImages without calling Image.Close in-between will exhaust the underlying queue. At such a time, Java.Lang.IllegalStateException will be thrown until more images are released with Image.Close.

[Android Documentation]

Requirements

Namespace: Android.Media
Assembly: Mono.Android (in Mono.Android.dll)
Assembly Versions: 0.0.0.0