mirror of
https://github.com/bevyengine/bevy
synced 2024-11-23 05:03:47 +00:00
b1a634cade
# Objective The following code: ```rs use bevy::prelude::Image; use image::{ DynamicImage, GenericImage, Rgba }; fn main() { let mut dynamic_image = DynamicImage::new_rgb32f(1, 1); dynamic_image.put_pixel(0, 0, Rgba([1, 1, 1, 1])); let image = Image::from_dynamic(dynamic_image, false); // Panic! println!("{image:?}"); } ``` Can cause an assertion failed: ``` thread 'main' panicked at 'assertion failed: `(left == right)` left: `16`, right: `14`: Pixel data, size and format have to match', .../bevy_render-0.9.1/src/texture/image.rs:209:9 stack backtrace: ... 4: core::panicking::assert_failed<usize,usize> at /rustc/897e37553bba8b42751c67658967889d11ecd120/library/core/src/panicking.rs:181 5: bevy_render::texture::image::Image::new at .../bevy_render-0.9.1/src/texture/image.rs:209 6: bevy_render::texture::image::Image::from_dynamic at .../bevy_render-0.9.1/src/texture/image_texture_conversion.rs:159 7: bevy_test::main at ./src/main.rs:8 ... ``` It seems to be cause by a copypasta in `crates/bevy_render/src/texture/image_texture_conversion.rs`. Let's fix it. ## Solution ```diff // DynamicImage::ImageRgb32F(image) => { - let a = u16::max_value(); + let a = 1f32; ``` This will fix the conversion. --- ## Changelog - Fixed the alpha channel of the `image::DynamicImage::ImageRgb32F` to `bevy_render::texture::Image` conversion in `bevy_render::texture::Image::from_dynamic()`. |
||
---|---|---|
.. | ||
bevy_animation | ||
bevy_app | ||
bevy_asset | ||
bevy_audio | ||
bevy_core | ||
bevy_core_pipeline | ||
bevy_derive | ||
bevy_diagnostic | ||
bevy_dylib | ||
bevy_dynamic_plugin | ||
bevy_ecs | ||
bevy_ecs_compile_fail_tests | ||
bevy_encase_derive | ||
bevy_gilrs | ||
bevy_gltf | ||
bevy_hierarchy | ||
bevy_input | ||
bevy_internal | ||
bevy_log | ||
bevy_macro_utils | ||
bevy_math | ||
bevy_mikktspace | ||
bevy_pbr | ||
bevy_ptr | ||
bevy_reflect | ||
bevy_render | ||
bevy_scene | ||
bevy_sprite | ||
bevy_tasks | ||
bevy_text | ||
bevy_time | ||
bevy_transform | ||
bevy_ui | ||
bevy_utils | ||
bevy_window | ||
bevy_winit |