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:
@@ -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);
|
||||
|
||||
@@ -95,8 +95,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 })
|
||||
|
||||
Reference in New Issue
Block a user