Builder

class Builder : Builder<ImageCapture!, ImageCaptureConfig!, ImageCaptureConfig.Builder!>, Builder<ImageCaptureConfig.Builder!>, Builder<ImageCaptureConfig.Builder!>, Builder<ImageCaptureConfig.Builder!>
kotlin.Any
   ↳ androidx.camera.core.ImageCaptureConfig.Builder

Builder for a ImageCaptureConfig.

Summary

Public constructors

Creates a new Builder object.

Public methods

ImageCaptureConfig

Builds an immutable ImageCaptureConfig from the current state.

static ImageCaptureConfig.Builder
fromConfig(@NonNull configuration: ImageCaptureConfig)

Generates a Builder from another Config object

ImageCaptureConfig.Builder
setBackgroundExecutor(@NonNull executor: Executor)

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

ImageCaptureConfig.Builder

Sets the image capture mode.

ImageCaptureConfig.Builder
setFlashMode(@NonNull flashMode: FlashMode)

Sets the FlashMode.

ImageCaptureConfig.Builder
setLensFacing(@NonNull lensFacing: CameraX.LensFacing)

Sets the primary camera to be configured based on the direction the lens is facing.

ImageCaptureConfig.Builder
setTargetAspectRatio(@NonNull aspectRatio: AspectRatio)

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

ImageCaptureConfig.Builder
setTargetName(@NonNull targetName: String)

Sets the name of the target object being configured.

ImageCaptureConfig.Builder
setTargetResolution(@NonNull resolution: Size)

Sets the intended output target resolution.

ImageCaptureConfig.Builder

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

Public constructors

<init>

Builder()

Creates a new Builder object.

Public methods

build

@NonNull fun build(): ImageCaptureConfig

Builds an immutable ImageCaptureConfig from the current state.

Return
ImageCaptureConfig: A ImageCaptureConfig populated with the current state.

fromConfig

@NonNull static fun fromConfig(@NonNull configuration: ImageCaptureConfig): ImageCaptureConfig.Builder

Generates a Builder from another Config object

Parameters
configuration ImageCaptureConfig: An immutable configuration to pre-populate this builder.
Return
ImageCaptureConfig.Builder: The new Builder.

setBackgroundExecutor

@NonNull fun setBackgroundExecutor(@NonNull executor: Executor): ImageCaptureConfig.Builder

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

Parameters
executor Executor: The executor which will be used for background tasks.
Return
ImageCaptureConfig.Builder: the current Builder.

setCaptureMode

@NonNull fun setCaptureMode(@NonNull captureMode: ImageCapture.CaptureMode): ImageCaptureConfig.Builder

Sets the image capture mode.

Valid capture modes are CaptureMode#MIN_LATENCY, which prioritizes latency over image quality, or CaptureMode#MAX_QUALITY, which prioritizes image quality over latency.

Parameters
captureMode ImageCapture.CaptureMode: The requested image capture mode.
Return
ImageCaptureConfig.Builder: The current Builder.

setFlashMode

@NonNull fun setFlashMode(@NonNull flashMode: FlashMode): ImageCaptureConfig.Builder

Sets the FlashMode.

Parameters
flashMode FlashMode: The requested flash mode.
Return
ImageCaptureConfig.Builder: The current Builder.

setLensFacing

@NonNull fun setLensFacing(@NonNull lensFacing: CameraX.LensFacing): ImageCaptureConfig.Builder

Sets the primary camera to be configured based on the direction the lens is facing.

If multiple cameras exist with equivalent lens facing direction, the first ("primary") camera for that direction will be chosen.

Parameters
lensFacing CameraX.LensFacing: The direction of the camera's lens.
Return
ImageCaptureConfig.Builder: the current Builder.

setTargetAspectRatio

@NonNull fun setTargetAspectRatio(@NonNull aspectRatio: AspectRatio): ImageCaptureConfig.Builder

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

It is not allowed to set both target aspect ratio and target resolution on the same use case.

The target aspect ratio is used as a hint when determining the resulting output aspect ratio which may differ from the request, possibly due to device constraints. Application code should check the resulting output's resolution.

Parameters
aspectRatio AspectRatio: A AspectRatio representing the ratio of the target's width and height.
Return
ImageCaptureConfig.Builder: The current Builder.

setTargetName

@NonNull fun setTargetName(@NonNull targetName: String): ImageCaptureConfig.Builder

Sets the name of the target object being configured.

The name should be a value that can uniquely identify an instance of the object being configured.

Parameters
targetName String: A unique string identifier for the instance of the class being configured.
Return
ImageCaptureConfig.Builder: the current Builder.

setTargetResolution

@NonNull fun setTargetResolution(@NonNull resolution: Size): ImageCaptureConfig.Builder

Sets the intended output target resolution.

The target resolution attempts to establish a minimum bound for the image resolution. The actual image resolution will be the closest available resolution in size that is not smaller than the target resolution, as determined by the Camera implementation. However, if no resolution exists that is equal to or larger than the target resolution, the nearest available resolution smaller than the target resolution will be chosen.

It is not allowed to set both target aspect ratio and target resolution on the same use case.

The target aspect ratio will also be set the same as the aspect ratio of the provided Size. Make sure to set the target resolution with the correct orientation.

Parameters
resolution Size: The target resolution to choose from supported output sizes list.
Return
ImageCaptureConfig.Builder: The current Builder.

setTargetRotation

@NonNull fun setTargetRotation(rotation: Int): ImageCaptureConfig.Builder

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

This is one of four valid values: Surface#ROTATION_0, , Surface#ROTATION_180, Surface#ROTATION_270. Rotation values are relative to the "natural" rotation, Surface#ROTATION_0.

Parameters
rotation Int: The rotation of the intended target.
Return
ImageCaptureConfig.Builder: The current Builder.