Image

fun Image(model: Any?, contentDescription: String?, modifier: Modifier = Modifier, onState: (State) -> Unit? = null, emptyIcon: @Composable () -> Unit = { ImageIconState(SparkIcons.NoPhoto) }, errorIcon: @Composable () -> Unit = { ImageIconState(SparkIcons.ErrorPhoto) }, alignment: Alignment = Alignment.Center, contentScale: ContentScale = ContentScale.Fit, alpha: Float = DefaultAlpha, colorFilter: ColorFilter? = null, filterQuality: FilterQuality = DrawScope.DefaultFilterQuality, loadingPlaceholder: @Composable () -> Unit = ImageDefaults.placeholder)

A composable that lays out and draws a given Image. This will attempt to size the composable according to the Image's given width and height. However, an optional Modifier parameter can be provided to adjust sizing or draw additional content (ex. background). Any unspecified dimension will leverage the Image's size as a minimum constraint.

Parameters

model

An object representing the image to be displayed. This can be a URL, a file, or any other type of object that can be used to identify the image.

contentDescription

text used by accessibility services to describe what this image represents. This should always be provided unless this image is used for decorative purposes, and does not represent a meaningful action that a user can take. This text should be localized, such as by using androidx.compose.ui.res.stringResource or from the backend

modifier

Modifier used to adjust the layout algorithm or draw decoration content (ex. background)

onState

A callback function that is called when the state of the image changes.

emptyIcon

Placeholder used when the image loading has not started yet.

errorIcon

Placeholder used when the image loading failed.

alignment

Optional alignment parameter used to place the image in the given bounds defined by the width and height

contentScale

Optional scale parameter used to determine the aspect ratio scaling to be used if the bounds are a different size from the intrinsic size of the image

alpha

Optional opacity to be applied to the image when it is rendered onscreen. Default to 1f.

colorFilter

Optional ColorFilter to apply for the image when it is rendered onscreen

filterQuality

Sampling algorithm applied to the image when it is scaled and drawn into the destination. The default is FilterQuality.Low which scales using a bilinear sampling algorithm

loadingPlaceholder

Placeholder used when the image is loading. You can use a different one in special cases like when the image is displayed in fullscreen for example.