feat: raster image render pipeline (IMAGE command + GPU textured quad)
- Add IMAGE / IMAGEATTACH / IM command with async file-picker (rfd) - src/scene/image_model.rs: ImageModel with RGBA pixel data + quad corners - src/scene/pipeline/image_gpu.rs: ImageGpu with wgpu texture, sampler, opacity uniform - src/scene/pipeline/mod.rs: image render pipeline (pass 2, between hatches and meshes) - src/scene/render.rs: include images in Primitive, call upload_images in prepare - src/scene/mod.rs: images HashMap, populate_images_from_document, cache on add_entity - src/modules/home/draw/raster_image.rs: ImageCommand (two-click: origin + width, aspect-correct preview) - src/io/mod.rs: pick_image_file() async helper (file dialog + dimension decode) - app: ImagePick / ImagePickResult messages, populate on file open and undo/redo Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
parent
3d1f355a5c
commit
4312b6c3a5
39 changed files with 702 additions and 15 deletions
|
|
@ -113,6 +113,26 @@ pub async fn pick_plot_style() -> Option<plot_style::PlotStyleTable> {
|
|||
plot_style::PlotStyleTable::load(handle.path()).ok()
|
||||
}
|
||||
|
||||
// ── Image file picker ─────────────────────────────────────────────────────
|
||||
|
||||
/// Show a file-open dialog for raster images and decode the selected file.
|
||||
/// Returns `(path, pixel_width, pixel_height)` or an error string.
|
||||
pub async fn pick_image_file() -> Result<(PathBuf, u32, u32), String> {
|
||||
let handle = rfd::AsyncFileDialog::new()
|
||||
.set_title("Select Image File")
|
||||
.add_filter("Images", &["png", "jpg", "jpeg", "bmp", "tiff", "tif"])
|
||||
.add_filter("PNG", &["png"])
|
||||
.add_filter("JPEG", &["jpg", "jpeg"])
|
||||
.add_filter("All Files", &["*"])
|
||||
.pick_file()
|
||||
.await
|
||||
.ok_or_else(|| "Cancelled".to_string())?;
|
||||
let path = handle.path().to_path_buf();
|
||||
let img = image::open(&path).map_err(|e| e.to_string())?;
|
||||
let (w, h) = image::GenericImageView::dimensions(&img);
|
||||
Ok((path, w, h))
|
||||
}
|
||||
|
||||
// ── Save ──────────────────────────────────────────────────────────────────
|
||||
|
||||
/// Save the document to the given path.
|
||||
|
|
|
|||
Loading…
Reference in a new issue