{"record":{"id":"07ea3ff8cdad6190","repo":"FyroxEngine/Fyrox","slug":"pixel-types-must-match","errorCode":null,"errorMessage":"Pixel types must match!","messagePattern":"Pixel types must match!","errorType":"panic","errorClass":null,"httpStatus":null,"severity":"error","filePath":"fyrox-texture/src/lib.rs","lineNumber":1663,"sourceCode":"                    if mip_count != 0 {\n                        let mut dst_img =\n                            fr::images::Image::new(level_width, level_height, src_pixel_type);\n\n                        let mut resizer = fr::Resizer::new();\n\n                        resizer\n                            .resize(\n                                &current_level,\n                                &mut dst_img,\n                                Some(&ResizeOptions {\n                                    algorithm: fr::ResizeAlg::Convolution(\n                                        import_options.mip_filter.into_filter_type(),\n                                    ),\n                                    cropping: Default::default(),\n                                    mul_div_alpha: true,\n                                }),\n                            )\n                            .expect(\"Pixel types must match!\");\n\n                        current_level = dst_img;\n                    }\n\n                    mip_count += 1;\n\n                    if import_options.compression == CompressionOptions::NoCompression {\n                        bytes.extend_from_slice(current_level.buffer())\n                    } else if let Some((compressed_data, new_pixel_kind)) = try_compress(\n                        src_pixel_kind,\n                        current_level.buffer(),\n                        level_width as usize,\n                        level_height as usize,\n                        import_options.compression,\n                    ) {\n                        final_pixel_kind = new_pixel_kind;\n                        bytes.extend_from_slice(&compressed_data);\n                    } else {","sourceCodeStart":1645,"sourceCodeEnd":1681,"githubUrl":"https://github.com/FyroxEngine/Fyrox/blob/76c91aad8eca488ce527b1af707be8b3b24ad72d/fyrox-texture/src/lib.rs#L1645-L1681","documentation":"While generating mip maps during texture import, the code resizes/copy-converts the image to the next mip level and expects the resulting pixel format to equal the source's. 'Pixel types must match!' means the downscaled image came back with a different pixel type, which the importer treats as an unrecoverable invariant break.","triggerScenarios":"Importing a texture whose image crate operations (resize/generate_mipmaps with mul_div_alpha, cropping, or custom pixel kind) produce a different pixel type than the base level — typically with unusual pixel kinds (e.g. compressed or float formats) that the mip generator cannot preserve.","commonSituations":"Importing HDR/BC-compressed textures with mip map generation enabled; custom import options (mip_filter/cropping) that change the pixel representation; version drift between the image crate and fyrox-texture changing returned pixel types.","solutions":["Disable mip map generation in TextureImportOptions (with_mip_maps(false)) or pre-generate mips offline in a tool.","Convert the source image to a standard pixel kind (e.g. RGBA8) before import using image::DynamicImage::to_rgba8().","Check/import with default import options to isolate whether a custom option (mul_div_alpha, cropping, mip_filter) causes the pixel type change; then adjust the option."],"exampleFix":"// before\nlet texture = Texture::load_from_memory(\n    bytes,\n    TextureKind::D2 { width, height },\n    TexturePixelKind::BC7Srgb,\n    TextureImportOptions::default().with_mip_maps(true),\n)?; // panics generating mips\n// after\nlet texture = Texture::load_from_memory(\n    bytes,\n    TextureKind::D2 { width, height },\n    TexturePixelKind::RGBA8Srgb,\n    TextureImportOptions::default().with_mip_maps(true),\n)?;","handlingStrategy":"validation","validationCode":"let img = image::load_from_memory(bytes)?.to_rgba8(); // ensure uniform pixel type before mip generation","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Import textures as RGBA8 when enabling mip map generation","Disable mips for compressed/HDR pixel kinds"],"tags":["texture","mipmap","pixel-format","panic"],"backgroundTag":"incompatible-source-type","analyzedSha":"76c91aad8eca488ce527b1af707be8b3b24ad72d","analyzedAt":"2026-09-10T16:04:01.633Z","contentChangedAt":"2026-09-10T16:04:01.633Z","schemaVersion":2},"datasetVersion":"2026-09-16T09:17:16.951Z"}