mirror of
https://github.com/bevyengine/bevy
synced 2024-11-25 22:20:20 +00:00
convert grayscale images to rgb (#1524)
Fixes #1518 Issue was that images loaded as [`ImageLumaA8`](https://docs.rs/image/0.23.13/image/enum.DynamicImage.html#variant.ImageLumaA8) (grayscale with alpha channel) from `image` were considered as [`Rg8Unorm`](https://docs.rs/wgpu/0.7.0/wgpu/enum.TextureFormat.html#variant.Rg8Unorm) (red green channels) from `wgpu`. Same for `ImageLuma8` (grayscale) that was converted to `R8Unorm` (only red channel). As `wgpu` doesn't seem to have grayscale texture formats, I converted the grayscale textures to rgba.
This commit is contained in:
parent
319e75c7aa
commit
6a0968b2ea
1 changed files with 4 additions and 2 deletions
|
@ -12,16 +12,18 @@ pub(crate) fn image_to_texture(dyn_img: image::DynamicImage) -> Texture {
|
|||
|
||||
match dyn_img {
|
||||
image::DynamicImage::ImageLuma8(i) => {
|
||||
let i = image::DynamicImage::ImageLuma8(i).into_rgba8();
|
||||
width = i.width();
|
||||
height = i.height();
|
||||
format = TextureFormat::R8Unorm;
|
||||
format = TextureFormat::Rgba8UnormSrgb;
|
||||
|
||||
data = i.into_raw();
|
||||
}
|
||||
image::DynamicImage::ImageLumaA8(i) => {
|
||||
let i = image::DynamicImage::ImageLumaA8(i).into_rgba8();
|
||||
width = i.width();
|
||||
height = i.height();
|
||||
format = TextureFormat::Rg8Unorm;
|
||||
format = TextureFormat::Rgba8UnormSrgb;
|
||||
|
||||
data = i.into_raw();
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue