Skip to content

bevy_gltf cannot convert between image pixel formats #896

@iwikal

Description

@iwikal

Bevy version
0.3.0

Operating system & version
Arch Linux

What you did
Tried to load a .glb file with images in rgb8 format

What you expected to happen
A scene with my model in it? Not a panic, that's for sure.

What actually happened
The scene was not loaded. Instead, this was printed:

thread 'IO Task Pool (0)' panicked at 'called `Result::unwrap()` on an `Err` value: AssetLoaderError(Failed to convert image to rgb8.)', /home/joenor/.cargo/registry/src/github.com-1ecc6299db9ec823/bevy_asset-0.3.0/src/asset_server.rs:295:60
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace

Additional information
I noticed there's a call to image.as_rgba8, here:

let image = image
.as_rgba8()
.ok_or(GltfError::ImageRgb8ConversionFailure)?;

The error message suggests that the intention was to convert from one format to another, but this method doesn't actually convert anything. It just matches the type of image, and if it already was in rgba8 format, returns it. Otherwise you get None. I'm guessing what you want is into_rgba8.

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-AssetsLoad files from disk to use for things like images, models, and soundsC-BugAn unexpected or incorrect behavior

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions