Skip to content

Commit

Permalink
Update image_loader.rs
Browse files Browse the repository at this point in the history
  • Loading branch information
rustbasic authored Nov 6, 2024
1 parent 5d6a58b commit ea43480
Showing 1 changed file with 2 additions and 7 deletions.
9 changes: 2 additions & 7 deletions crates/egui_extras/src/loaders/image_loader.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ use egui::{
ColorImage,
};
use image::ImageFormat;
use std::{mem::size_of, path::Path, sync::Arc};
use std::{mem::size_of, sync::Arc};

type Entry = Result<Arc<ColorImage>, String>;

Expand All @@ -19,16 +19,11 @@ impl ImageCrateLoader {
}

fn is_supported_uri(uri: &str) -> bool {
let Some(ext) = Path::new(uri).extension().and_then(|ext| ext.to_str()) else {
// `true` because if there's no extension, assume that we support it
return true;
};

// Uses only the enabled image crate features
ImageFormat::all()
.filter(ImageFormat::reading_enabled)
.flat_map(ImageFormat::extensions_str)
.any(|format_ext| ext == *format_ext)
.any(|format_ext| uri.contains(*format_ext))
}

fn is_unsupported_mime(mime: &str) -> bool {
Expand Down

0 comments on commit ea43480

Please sign in to comment.