{"record":{"id":"3617cec64d06d7d7","repo":"bevyengine/bevy","slug":"conversion-into-dynamic-image-not-supported-for-0","errorCode":null,"errorMessage":"Conversion into dynamic image not supported for {0:?}.","messagePattern":"Conversion into dynamic image not supported for (.+?)\\.","errorType":"exception","errorClass":"IntoDynamicImageError","httpStatus":null,"severity":"error","filePath":"crates/bevy_image/src/image_texture_conversion.rs","lineNumber":200,"sourceCode":"                    data\n                })\n                .map(DynamicImage::ImageRgba8)\n            }\n            // Throw and error if conversion isn't supported\n            texture_format => return Err(IntoDynamicImageError::UnsupportedFormat(texture_format)),\n        }\n        .ok_or(IntoDynamicImageError::UnknownConversionError(\n            self.texture_descriptor.format,\n        ))\n    }\n}\n\n/// Errors that occur while converting an [`Image`] into a [`DynamicImage`]\n#[non_exhaustive]\n#[derive(Error, Debug)]\npub enum IntoDynamicImageError {\n    /// Conversion into dynamic image not supported for source format.\n    #[error(\"Conversion into dynamic image not supported for {0:?}.\")]\n    UnsupportedFormat(TextureFormat),\n\n    /// Encountered an unknown error during conversion.\n    #[error(\"Failed to convert into {0:?}.\")]\n    UnknownConversionError(TextureFormat),\n\n    /// Tried to convert an image that has no texture data\n    #[error(\"Image has no texture data\")]\n    UninitializedImage,\n}\n\n#[cfg(test)]\nmod test {\n    use image::{GenericImage, Rgba};\n\n    use super::*;\n\n    #[test]","sourceCodeStart":182,"sourceCodeEnd":218,"githubUrl":"https://github.com/bevyengine/bevy/blob/396ca727080776bd313bb892423b7d94e03b81b4/crates/bevy_image/src/image_texture_conversion.rs#L182-L218","documentation":"IntoDynamicImageError::UnsupportedFormat is returned by Image::try_into_dynamic (crates/bevy_image/src/image_texture_conversion.rs:158-192) for any format outside its small whitelist: R8Unorm, Rg8Unorm, Rgba8UnormSrgb, and Bgra8UnormSrgb/Bgra8Unorm (the last two for screenshots). Every other TextureFormat — including the very common linear Rgba8Unorm — falls into the catch-all arm at line 187 and is rejected, because DynamicImage has no corresponding buffer type. The method's doc explicitly points to Image::convert for changing format first.","triggerScenarios":"Calling image.try_into_dynamic() on an Image created with TextureFormat::Rgba8Unorm (linear), Rgba16Unorm, or any 10-bit/12-bit/float format; post-processing camera render targets that were configured with linear RGBA8; converting images loaded with texture_format overrides in ImageLoaderSettings.","commonSituations":"Screenshot or thumbnail code following Image::convert or render-target reads; mixing up Rgba8Unorm and Rgba8UnormSrgb when constructing images manually; feeding bevy_render-extracted textures into `image`-crate based tooling.","solutions":["Convert before extracting: image.convert(TextureFormat::Rgba8UnormSrgb) (Image::convert at image.rs:1565 returns Option<Image>) and call try_into_dynamic on the result.","Or convert to R8Unorm/Rg8Unorm if you want Luma8/LumaA8 DynamicImages.","When you control image creation, pick one of the four supported formats up front.","Note Bgra8UnormSrgb/Bgra8Unorm are supported specifically so swapchain screenshots work — no manual swizzle needed."],"exampleFix":"// before — linear RGBA8 is not convertible\nlet dyn_img = image.try_into_dynamic()?; // Err(UnsupportedFormat(Rgba8Unorm))\n\n// after — convert to a supported format first\nlet dyn_img = image\n    .convert(TextureFormat::Rgba8UnormSrgb)\n    .ok_or_else(|| anyhow!(\"conversion failed\"))?\n    .try_into_dynamic()?;","handlingStrategy":"type-guard","validationCode":"// ensure a convertible format before calling try_into_dynamic\nlet fmt = image.texture_descriptor.format;\nif !is_dynamic_convertible(fmt) {\n    image = image.convert(TextureFormat::Rgba8UnormSrgb).expect(\"format convertible\");\n}","typeGuard":"fn is_dynamic_convertible(fmt: TextureFormat) -> bool {\n    matches!(\n        fmt,\n        TextureFormat::R8Unorm\n            | TextureFormat::Rg8Unorm\n            | TextureFormat::Rgba8UnormSrgb\n            | TextureFormat::Bgra8UnormSrgb\n            | TextureFormat::Bgra8Unorm\n    )\n}","tryCatchPattern":"match image.try_into_dynamic() {\n    Ok(dyn_img) => { /* ... */ }\n    Err(IntoDynamicImageError::UnsupportedFormat(fmt)) => {\n        let dyn_img = image.convert(TextureFormat::Rgba8UnormSrgb)\n            .expect(\"convert to supported format\")\n            .try_into_dynamic()?;\n    }\n    Err(IntoDynamicImageError::UninitializedImage) => { /* re-load with MAIN_WORLD */ }\n    Err(IntoDynamicImageError::UnknownConversionError(fmt)) => { /* data/extent mismatch */ }\n}","preventionTips":["Standardize on Rgba8UnormSrgb for images you intend to convert to DynamicImage.","Remember Rgba8Unorm (linear) is NOT convertible — only the sRGB twin is.","Wrap try_into_dynamic in one project helper that converts first."],"tags":["bevy","texture","dynamic-image","format-conversion","rust"],"backgroundTag":"unsupported-pixel-format-conversion","analyzedSha":"396ca727080776bd313bb892423b7d94e03b81b4","analyzedAt":"2026-08-20T16:12:39.808Z","contentChangedAt":"2026-08-20T16:12:39.808Z","schemaVersion":2},"datasetVersion":"2026-09-08T20:17:18.057Z"}