Skip to content

Image

Image displays an ImageResource, decoded ImageAsset, VectorAsset, or ExternalTexture.

Image(app::images::cover)
.Fit(ImageFit::Cover)
.Align(HorizontalAlignment::Center, VerticalAlignment::Center)
.Sampling(ImageSampling::Linear)
.With(
Frame{.width = 320.0F, .height = 180.0F},
CornerRadius(16.0F),
ClipChildren()
)

Resource images select the best packaged density and locale variant for the active ResourceConfiguration. Raster and vector assets expose intrinsic size; parent constraints and .Fit(...) determine their final destination rectangle.

Pass an ImageResource directly when Image owns the display. Call UseImage only when application code needs the resolved ImageAsset, such as a custom Canvas painter or asset inspection.

ImageFit supports Fill, Contain, Cover, None, and ScaleDown. Alignment controls where unused space or cropped content is anchored.

.Sampling(...) selects the raster sampling policy. .Tint(Color) recolors compatible raster or vector content and is useful for theme-owned icons.

Decorative images need no extra semantic label. Meaningful images should provide image semantics explicitly:

Image(app::images::status)
.With(Semantics{
.role = SemanticRole::Image,
.label = "Build succeeded",
})
  • Constructors: Image(ImageResource), Image(ImageAsset), Image(VectorAsset), Image(ExternalTexture).
  • Fluent methods: .Fit(ImageFit), .Align(horizontal, vertical), .Sampling(ImageSampling), .Tint(Color).
  • Common modifiers: Frame, CornerRadius, ClipChildren, Opacity, Semantics.

See Resources and localization and ExternalTexture.