load_image_from_resource

Function load_image_from_resource 

Source
pub fn load_image_from_resource(
    image: &ImageRef,
    cx: &mut Cx,
    abs_path: &str,
) -> Result<(), ImageError>
Expand description

Loads an image into an [ImageRef] from a resource registered via crate_resource().

abs_path is the absolute filesystem path stored as the resource’s abs_path when it was registered with the script resource system. The function looks up the corresponding [ScriptHandle], ensures the resource data is loaded, and feeds the bytes to the image widget’s async decoder.

Returns Ok(()) if the image was decoded or if the resource data is not yet available (e.g. pending HTTP fetch on web) — the caller should retry on the next draw pass, matching the behavior of Makepad’s built-in [Image] widget.

§Errors

Returns [ImageError::PathNotFound] if no script resource matches abs_path.