Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update image requirement from 0.24 to 0.25 #12458

Merged
merged 5 commits into from
Mar 29, 2024
Merged
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion crates/bevy_render/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ bevy_utils = { path = "../bevy_utils", version = "0.14.0-dev" }
bevy_tasks = { path = "../bevy_tasks", version = "0.14.0-dev" }

# rendering
image = { version = "0.24", default-features = false }
image = { version = "0.25", default-features = false }

# misc
codespan-reporting = "0.11.0"
Expand Down
10 changes: 7 additions & 3 deletions crates/bevy_render/src/texture/hdr_texture_loader.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ use crate::{
texture::{Image, TextureFormatPixelInfo},
};
use bevy_asset::{io::Reader, AssetLoader, AsyncReadExt, LoadContext};
use image::DynamicImage;
use serde::{Deserialize, Serialize};
use thiserror::Error;
use wgpu::{Extent3d, TextureDimension, TextureFormat};
Expand Down Expand Up @@ -46,10 +47,13 @@ impl AssetLoader for HdrTextureLoader {
reader.read_to_end(&mut bytes).await?;
let decoder = image::codecs::hdr::HdrDecoder::new(bytes.as_slice())?;
let info = decoder.metadata();
let rgb_data = decoder.read_image_hdr()?;
let mut rgba_data = Vec::with_capacity(rgb_data.len() * format.pixel_size());
let dynamic_image = DynamicImage::from_decoder(decoder)?;
let image_buffer = dynamic_image
.as_rgb32f()
.expect("Image format should be Rgb32F");
james7132 marked this conversation as resolved.
Show resolved Hide resolved
let mut rgba_data = Vec::with_capacity(image_buffer.pixels().len() * format.pixel_size());

for rgb in rgb_data {
for rgb in image_buffer.pixels() {
let alpha = 1.0f32;

rgba_data.extend_from_slice(&rgb.0[0].to_ne_bytes());
Expand Down