androidx.camera.viewfinder.compose

Standalone Composable Viewfinder for Camera

Interfaces

CoordinateTransformer

Coordinate transformer that's used to convert coordinates from one space to another.

MutableCoordinateTransformer

CoordinateTransformer where the transformMatrix is mutable.

Objects

IdentityCoordinateTransformer

CoordinateTransformer where the transformMatrix is the identity matrix.

Top-level functions summary

MutableCoordinateTransformer

Creates a MutableCoordinateTransformer with the given matrix as the transformMatrix.

Unit
@Composable
Viewfinder(
    surfaceRequest: ViewfinderSurfaceRequest,
    implementationMode: ImplementationMode,
    transformationInfo: TransformationInfo,
    modifier: Modifier,
    coordinateTransformer: MutableCoordinateTransformer?
)

Displays a media stream with the given transformations for crop and rotation while maintaining proper scaling.

Top-level functions

MutableCoordinateTransformer

fun MutableCoordinateTransformer(matrix: Matrix = Matrix()): MutableCoordinateTransformer

Creates a MutableCoordinateTransformer with the given matrix as the transformMatrix.

@Composable
fun Viewfinder(
    surfaceRequest: ViewfinderSurfaceRequest,
    implementationMode: ImplementationMode,
    transformationInfo: TransformationInfo,
    modifier: Modifier = Modifier,
    coordinateTransformer: MutableCoordinateTransformer? = null
): Unit

Displays a media stream with the given transformations for crop and rotation while maintaining proper scaling.

Provides a Surface for the given ViewfinderSurfaceRequest, surface can be accessed through ViewfinderSurfaceRequest.getSurface.

This has two underlying implementations either using an AndroidEmbeddedExternalSurface for ImplementationMode.EMBEDDED or an AndroidExternalSurface for ImplementationMode.EXTERNAL.

Parameters
surfaceRequest: ViewfinderSurfaceRequest

Details about the surface being requested

implementationMode: ImplementationMode

Determines the underlying implementation of the Surface.

transformationInfo: TransformationInfo

Specifies the required transformations for the media being displayed.

modifier: Modifier = Modifier

Modifier to be applied to the Viewfinder

coordinateTransformer: MutableCoordinateTransformer? = null

Coordinate transformer that can be used to convert Compose space coordinates such as touch coordinates to surface space coordinates. When the Viewfinder is displaying content from the camera, this transformer can be used to translate touch events into camera sensor coordinates for focus and metering actions.

TODO(b/322420487): Add a sample with @sample