ImageCapture.Builder

public static final class ImageCapture.Builder
extends Object implements ExtendableBuilder<T extends UseCase>

java.lang.Object
   ↳ androidx.camera.core.ImageCapture.Builder


Builder for an ImageCapture.

Summary

Public constructors

Builder()

Creates a new Builder object.

Public methods

ImageCapture build()

Builds an immutable ImageCapture from the current state.

ImageCapture.Builder setCaptureMode(int captureMode)

Sets the image capture mode.

ImageCapture.Builder setFlashMode(int flashMode)

Sets the flashMode.

ImageCapture.Builder setIoExecutor(Executor executor)

Sets the default executor that will be used for IO tasks.

ImageCapture.Builder setJpegQuality(int jpegQuality)

Sets the output JPEG image compression quality.

ImageCapture.Builder setTargetAspectRatio(int aspectRatio)

Sets the aspect ratio of the intended target for images from this configuration.

ImageCapture.Builder setTargetName(String targetName)

Sets the name of the target object being configured, used only for debug logging.

ImageCapture.Builder setTargetResolution(Size resolution)

Sets the intended output target resolution.

ImageCapture.Builder setTargetRotation(int rotation)

Sets the rotation of the intended target for images from this configuration.

Inherited methods

Public constructors

Builder

public Builder ()

Creates a new Builder object.

Public methods

build

public ImageCapture build ()

Builds an immutable ImageCapture from the current state.

Returns
ImageCapture A ImageCapture populated with the current state.

Throws
IllegalArgumentException if attempting to set both target aspect ratio and target resolution.

setCaptureMode

public ImageCapture.Builder setCaptureMode (int captureMode)

Sets the image capture mode.

Valid capture modes are ImageCapture.CAPTURE_MODE_MINIMIZE_LATENCY, which prioritizes latency over image quality, or ImageCapture.CAPTURE_MODE_MAXIMIZE_QUALITY, which prioritizes image quality over latency.

If not set, the capture mode will default to ImageCapture.CAPTURE_MODE_MINIMIZE_LATENCY.

Parameters
captureMode int: The requested image capture mode.

Returns
ImageCapture.Builder The current Builder.

setFlashMode

public ImageCapture.Builder setFlashMode (int flashMode)

Sets the flashMode.

If not set, the flash mode will default to ImageCapture.FLASH_MODE_OFF.

See ImageCapture.setFlashMode(int) for more information.

Parameters
flashMode int: The requested flash mode. Value is ImageCapture.FLASH_MODE_AUTO, ImageCapture.FLASH_MODE_ON, or ImageCapture.FLASH_MODE_OFF.

Returns
ImageCapture.Builder The current Builder.

setIoExecutor

public ImageCapture.Builder setIoExecutor (Executor executor)

Sets the default executor that will be used for IO tasks.

This executor will be used for any IO tasks specifically for ImageCapture, such as ImageCapture.takePicture(OutputFileOptions, Executor, ImageCapture.OnImageSavedCallback). If no executor is set, then a default Executor specifically for IO will be used instead.

Parameters
executor Executor: The executor which will be used for IO tasks.

Returns
ImageCapture.Builder the current Builder.

setJpegQuality

public ImageCapture.Builder setJpegQuality (int jpegQuality)