{"record":{"id":"5674205675e42a81","repo":"bevyengine/bevy","slug":"added-a-texture-with-the-wrong-format-in-an-atlas","errorCode":null,"errorMessage":"added a texture with the wrong format in an atlas","messagePattern":"added a texture with the wrong format in an atlas","errorType":"exception","errorClass":"TextureAtlasBuilderError","httpStatus":null,"severity":"error","filePath":"crates/bevy_image/src/texture_atlas_builder.rs","lineNumber":22,"sourceCode":"use rectangle_pack::{\n    contains_smallest_box, pack_rects, volume_heuristic, GroupedRectsToPlace, PackedLocation,\n    RectToInsert, TargetBin,\n};\nuse thiserror::Error;\nuse tracing::{debug, error, warn};\nuse wgpu_types::{Extent3d, TextureDimension, TextureFormat};\n\nuse crate::{Image, TextureAccessError, TextureFormatPixelInfo};\nuse crate::{TextureAtlasLayout, TextureAtlasSources};\n\n/// Errors returned by [`TextureAtlasBuilder`].\n#[derive(Debug, Error)]\npub enum TextureAtlasBuilderError {\n    /// The atlas texture wasn't large enough to fit the texture\n    #[error(\"could not pack textures into an atlas within the given bounds\")]\n    NotEnoughSpace,\n    /// Attempted to add a texture with a different format\n    #[error(\"added a texture with the wrong format in an atlas\")]\n    WrongFormat,\n    /// Attempted to add a texture to an uninitialized atlas\n    #[error(\"cannot add texture to uninitialized atlas texture\")]\n    UninitializedAtlas,\n    /// Attempted to add an uninitialized texture to an atlas\n    #[error(\"cannot add uninitialized texture to atlas\")]\n    UninitializedSourceTexture,\n    /// A texture access error occurred\n    #[error(\"texture access error: {0}\")]\n    TextureAccess(#[from] TextureAccessError),\n}\n\n#[derive(Debug)]\n#[must_use]\n/// A builder which is used to create a texture atlas from many individual\n/// sprites.\npub struct TextureAtlasBuilder<'a> {\n    /// Collection of texture's asset id (optional) and image data to be packed into an atlas","sourceCodeStart":4,"sourceCodeEnd":40,"githubUrl":"https://github.com/bevyengine/bevy/blob/396ca727080776bd313bb892423b7d94e03b81b4/crates/bevy_image/src/texture_atlas_builder.rs#L4-L40","documentation":"TextureAtlasBuilderError::WrongFormat — a texture was added whose TextureFormat differs from the format already established for the atlas. All images packed into one atlas must share a single TextureFormat; re-encode the offending image before adding.","triggerScenarios":"Thrown at crates/bevy_image/src/texture_atlas_builder.rs:22 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Convert added textures to the atlas's texture format before adding them","Create a separate atlas for the differently-formatted texture","Set the desired format on the builder before adding any textures"],"exampleFix":null,"handlingStrategy":"validation","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"396ca727080776bd313bb892423b7d94e03b81b4","analyzedAt":"2026-08-20T16:12:39.808Z","contentChangedAt":"2026-08-20T16:12:39.808Z","schemaVersion":2},"datasetVersion":"2026-09-14T00:17:10.932Z"}