feat: simple rotation
This commit is contained in:
parent
c362e7c735
commit
9da1395f8e
1 changed files with 10 additions and 1 deletions
11
src/main.rs
11
src/main.rs
|
|
@ -5,7 +5,7 @@ use iced::{
|
||||||
keyboard::{self, Key, key},
|
keyboard::{self, Key, key},
|
||||||
theme, widget, window,
|
theme, widget, window,
|
||||||
};
|
};
|
||||||
use image::{EncodableLayout, ImageReader, RgbaImage};
|
use image::{EncodableLayout, ImageReader, RgbaImage, imageops};
|
||||||
|
|
||||||
#[derive(Clone, Debug)]
|
#[derive(Clone, Debug)]
|
||||||
enum Message {
|
enum Message {
|
||||||
|
|
@ -57,6 +57,15 @@ impl State {
|
||||||
|
|
||||||
Key::Character("q") => return window::latest().and_then(window::close),
|
Key::Character("q") => return window::latest().and_then(window::close),
|
||||||
|
|
||||||
|
Key::Character("r") => {
|
||||||
|
self.image = imageops::rotate90(&self.image);
|
||||||
|
self.image_handle = widget::image::Handle::from_rgba(
|
||||||
|
self.image.width(),
|
||||||
|
self.image.height(),
|
||||||
|
unsafe { std::mem::transmute::<_, &'static [u8]>(self.image.as_bytes()) },
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
// ignore unused keys
|
// ignore unused keys
|
||||||
_ => {}
|
_ => {}
|
||||||
},
|
},
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue