mirror of
https://github.com/emilk/egui.git
synced 2026-08-31 05:40:03 -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],
|
image_bytes: &[u8],
|
||||||
hint: SizeHint,
|
hint: SizeHint,
|
||||||
) -> Result<egui::ColorImage, String> {
|
) -> 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 image = image::load_from_memory(image_bytes).map_err(|err| err.to_string())?;
|
||||||
let src_size = [image.width() as _, image.height() as _];
|
let src_size = [image.width() as _, image.height() as _];
|
||||||
let dst_size = calculate_size_for_hint(src_size, hint);
|
let dst_size = calculate_size_for_hint(src_size, hint);
|
||||||
|
|||||||
@@ -95,8 +95,9 @@ impl ImageLoader for ImageCrateLoader {
|
|||||||
|
|
||||||
// (3)
|
// (3)
|
||||||
log::trace!("started loading {uri:?}");
|
log::trace!("started loading {uri:?}");
|
||||||
let result =
|
let result = crate::image::load_image_bytes_for_size(&bytes, hint)
|
||||||
crate::image::load_image_bytes_for_size(&bytes, hint).map(Arc::new);
|
.map_err(|e| LoadError::Loading(e))
|
||||||
|
.map(Arc::new);
|
||||||
log::trace!("finished loading {uri:?}");
|
log::trace!("finished loading {uri:?}");
|
||||||
cache.insert(uri.into(), result.clone());
|
cache.insert(uri.into(), result.clone());
|
||||||
result.map(|image| ImagePoll::Ready { image })
|
result.map(|image| ImagePoll::Ready { image })
|
||||||
|
|||||||
Reference in New Issue
Block a user