Incular logoIncular
API ReferenceText & Media

Image

Retained image widget with sizing, fit, repeat, and sampling options.

Retains a shared handle, never bytes or GPU resources. Defaults: no explicit size, scale = 1.0, Contain, NoRepeat, CENTER, Linear.

Props

Prop

Type

use incular::prelude::*;

fn main() -> Result<(), Box<dyn std::error::Error>> {
    let pixels = ImageHandle::from_rgba8(2, 2, vec![200u8; 16]).expect("image");
    let app = Application::new(move |_cx| {
        Container::builder()
            .padding(EdgeInsets::all(24.0))
            .alignment(Alignment::CENTER)
            .child(
                Image::new(pixels.clone())
                    .width(200.0)
                    .height(120.0)
                    .scale(2.0)
                    .fit(BoxFit::Cover)
                    .repeat(ImageRepeat::NoRepeat)
                    .alignment(Alignment::CENTER)
                    .sampling(ImageSampling::Linear)
                    .filter_quality(FilterQuality::Low),
            )
            .build()
            .into()
    })?;
    incular::run(app)?;
    Ok(())
}

ImageFit: Fill / Contain (default) / Cover / FitWidth / FitHeight / None / ScaleDown. ImageRepeat: NoRepeat (default) / RepeatX / RepeatY / Repeat.

RawImage adds color tint; ImageIcon::new(image).size(24.0).color(c); ImageFiltered::blur(sigma, child) and .controlled(controller, child).

Related: Image Providers, Icon, BoxFit.

On this page