feat: "o" to open image
This commit is contained in:
parent
a786580da2
commit
e9fb349352
1 changed files with 23 additions and 0 deletions
23
src/main.rs
23
src/main.rs
|
|
@ -88,6 +88,29 @@ impl State {
|
||||||
return self.allocate_image();
|
return self.allocate_image();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Key::Character("o") => {
|
||||||
|
let Some(path) = FileDialog::new()
|
||||||
|
.add_filter(
|
||||||
|
"image",
|
||||||
|
&[
|
||||||
|
"png", "PNG", "jpg", "JPG", "jpeg", "JPEG", "avif", "bmp", "exr",
|
||||||
|
"ff", "gif", "hdr", "ico", "pnm", "qoi", "tga", "tiff", "webp",
|
||||||
|
],
|
||||||
|
)
|
||||||
|
.pick_file()
|
||||||
|
else {
|
||||||
|
eprintln!("no path to open provided");
|
||||||
|
return Task::none();
|
||||||
|
};
|
||||||
|
|
||||||
|
self.image = ImageReader::open(path)
|
||||||
|
.unwrap()
|
||||||
|
.decode()
|
||||||
|
.unwrap()
|
||||||
|
.into_rgba8();
|
||||||
|
|
||||||
|
return self.allocate_image();
|
||||||
|
}
|
||||||
Key::Character("s") => {
|
Key::Character("s") => {
|
||||||
let Some(path) = FileDialog::new().save_file() else {
|
let Some(path) = FileDialog::new().save_file() else {
|
||||||
eprintln!("no path to save provided");
|
eprintln!("no path to save provided");
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue