1
0
mirror of https://github.com/emilk/egui.git synced 2026-06-26 22:53:14 -04:00

egui_extra: Fix "Apply size hint to ImageCrateLoader::load"

This commit is contained in:
Varphone Wong
2025-01-06 10:14:49 +08:00
parent 41a0db3af9
commit 68fa843843
2 changed files with 5 additions and 3 deletions

View File

@@ -244,7 +244,8 @@ pub fn load_image_bytes_for_size(
image_bytes: &[u8],
hint: SizeHint,
) -> Result<egui::ColorImage, String> {
crate::profile_function!();
profiling::function_scope!();
let image = image::load_from_memory(image_bytes).map_err(|err| err.to_string())?;
let src_size = [image.width() as _, image.height() as _];
let dst_size = calculate_size_for_hint(src_size, hint);

View File

@@ -89,8 +89,9 @@ impl ImageLoader for ImageCrateLoader {
// (3)
log::trace!("started loading {uri:?}");
let result =
crate::image::load_image_bytes_for_size(&bytes, hint).map(Arc::new);
let result = crate::image::load_image_bytes_for_size(&bytes, hint)
.map_err(|e| LoadError::Loading(e))
.map(Arc::new);
log::trace!("finished loading {uri:?}");
cache.insert(uri.into(), result.clone());
result.map(|image| ImagePoll::Ready { image })