Skip to content

Commit

Permalink
Enable loading textures of unlimited size (bevyengine#5305)
Browse files Browse the repository at this point in the history
# Objective

Fixes bevyengine#5304 

## Solution

Instead of using a simple utility function for loading, which uses a default allocation limit of 512MB, we use a Reader object which can be configured ad hoc.

## Changelog

> This section is optional. If this was a trivial fix, or has no externally-visible impact, you can delete this section.

- Allows loading of textures larger than 512MB
  • Loading branch information
fgiordana authored and james7132 committed Oct 28, 2022
1 parent 0537d20 commit 628d982
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion crates/bevy_render/src/texture/image.rs
Original file line number Diff line number Diff line change
Expand Up @@ -381,7 +381,10 @@ impl Image {
let image_crate_format = format.as_image_crate_format().ok_or_else(|| {
TextureError::UnsupportedTextureFormat(format!("{:?}", format))
})?;
let dyn_img = image::load_from_memory_with_format(buffer, image_crate_format)?;
let mut reader = image::io::Reader::new(std::io::Cursor::new(buffer));
reader.set_format(image_crate_format);
reader.no_limits();
let dyn_img = reader.decode()?;
Ok(image_to_texture(dyn_img, is_srgb))
}
}
Expand Down

0 comments on commit 628d982

Please sign in to comment.