Resolve graphics through graphicspath directories

This commit is contained in:
gloamxun committed 2026-10-24 23:35:14 +08:00
1 parent 46f86c771e
commit 9aacb91184
6 files changed
+118 -8

No files matched your search

+8 -4
View File
@@ -898,11 +898,15 @@ fn load_project_images(
id: &str,
) -> HashMap<String, route_d::RasterImage> {
let mut images = HashMap::new();
let mut prefixes = vec![String::new()];
prefixes.extend(route_d::graphics_paths(source));
for path in route_d::image_paths(source) {
let Ok(bytes) = store
.read_file(id, &path)
.or_else(|_| store.read_file(id, &format!("{path}.png")))
else {
let bytes = prefixes.iter().find_map(|prefix| {
["", ".png", ".jpg", ".jpeg", ".bmp"]
.iter()
.find_map(|suffix| store.read_file(id, &format!("{prefix}{path}{suffix}")).ok())
});
let Some(bytes) = bytes else {
continue;
};
let Ok(decoded) = image::load_from_memory(&bytes) else {