Example usage for android.media ImageReader acquireNextImage

List of usage examples for android.media ImageReader acquireNextImage

Introduction

In this page you can find the example usage for android.media ImageReader acquireNextImage.

Prototype

public Image acquireNextImage() 

Source Link

Document

Acquire the next Image from the ImageReader's queue.

Usage

From source file:com.andrasta.dashi.MainActivity.java

@Override
public void onImageAvailable(@NonNull ImageReader reader) {
    Preconditions.assertParameterNotNull(reader, "reader");
    if (saveImageOnDisk.getAndSet(false)) {
        imageSaver.saveToFile(reader.acquireNextImage(), imageDestination);
        Toast.makeText(this, "Image saved to " + imageDestination.getAbsolutePath(), Toast.LENGTH_SHORT).show();
        return;/* w  ww . j  a va2  s.  co m*/
    }

    try {
        alprHandler.recognize(reader.acquireNextImage());
    } catch (IllegalStateException e) {
        Log.w(TAG, "Error on acquireNextImage");
    }
}

From source file:com.android.camera2.its.ItsService.java

private ImageReader.OnImageAvailableListener createAvailableListenerDropper(final CaptureCallback listener) {
    return new ImageReader.OnImageAvailableListener() {
        @Override/*w  w w .j av  a2  s .com*/
        public void onImageAvailable(ImageReader reader) {
            Image i = reader.acquireNextImage();
            i.close();
        }
    };
}

From source file:com.android.camera2.its.ItsService.java

public ImageReader.OnImageAvailableListener createAvailableListener(final CaptureCallback listener) {
    return new ImageReader.OnImageAvailableListener() {
        @Override/*from  w ww.  jav a  2 s . c o m*/
        public void onImageAvailable(ImageReader reader) {
            Image i = null;
            try {
                i = reader.acquireNextImage();
                listener.onCaptureAvailable(i);
            } finally {
                if (i != null) {
                    i.close();
                }
            }
        }
    };
}