Skip to main content

stamp_image_natural_size

Function stamp_image_natural_size 

Source
pub fn stamp_image_natural_size(
    commands: Commands<'_, '_>,
    changed: Query<'_, '_, (Entity, &ImageSource, &LoadedImage), (Changed<LoadedImage>, Without<BackgroundImage>)>,
    existing: Query<'_, '_, &mut ImageComponent>,
)
Expand description

D6: stamp the decoded bitmap’s intrinsic size onto lumen_core::components::ImageComponent as soon as a LoadedImage lands on the entity (cache hit or decode completion - both surface as Added/Changed<LoadedImage>).

The layout backend’s measure path reads ImageComponent.natural_size for images without an explicit size (spec section 13: intrinsic = bitmap logical size; explicit size wins because taffy passes known dimensions first). The bitmap’s pixel size is reported 1:1 as logical pixels - no @2x asset-scale metadata exists yet. A Changed<ImageComponent> hook in the layout crate turns this write into a DirtyLayout, so the image relayouts to its natural size on the tick after decode.

A BackgroundImage is skipped: a background never sizes its element.