Taking Photos
Capture and save an image.
Capturing a Photo
With a preview on screen, the next step is to take a photo. CameRX handles this with the ImageCapture use case.
You'll bind ImageCapture alongside the preview, then call takePicture() when the user taps a shutter button, and save the result to the device gallery.
Building the ImageCapture Use Case
ImageCapture is configured with a builder. A useful option is the capture mode, which trades latency against quality:
CAPTURE_MODE_MINIMIZE_LATENCY— fast shutter.CAPTURE_MODE_MAXIMIZE_QUALITY— best image, slightly slower.
val imageCapture = ImageCapture.Builder()
.setCaptureMode(ImageCapture.CAPTURE_MODE_MINIMIZE_LATENCY)
.build()