feat: image copy and paste
This commit is contained in:
parent
1f909904c2
commit
cb5e1d837a
5 changed files with 155 additions and 2 deletions
21
src/utils.rs
21
src/utils.rs
|
|
@ -1,4 +1,7 @@
|
|||
use std::path::{Path, PathBuf};
|
||||
use std::{
|
||||
borrow::Cow,
|
||||
path::{Path, PathBuf},
|
||||
};
|
||||
|
||||
use iced::widget;
|
||||
use image::{DynamicImage, ImageDecoder, ImageReader, ImageResult, RgbaImage};
|
||||
|
|
@ -52,3 +55,19 @@ pub const fn string_from_filter_type(f: widget::image::FilterMethod) -> &'static
|
|||
widget::image::FilterMethod::Nearest => "nearest neighbor",
|
||||
}
|
||||
}
|
||||
|
||||
pub fn arboard_from_rgbaimage<'a>(image: &'a RgbaImage) -> arboard::ImageData<'a> {
|
||||
arboard::ImageData {
|
||||
width: image.width() as usize,
|
||||
height: image.height() as usize,
|
||||
bytes: Cow::Borrowed(image.as_ref()),
|
||||
}
|
||||
}
|
||||
pub fn rgbaimage_from_arboard(image: arboard::ImageData) -> RgbaImage {
|
||||
RgbaImage::from_raw(
|
||||
image.width as u32,
|
||||
image.height as u32,
|
||||
image.bytes.into_owned(),
|
||||
)
|
||||
.unwrap()
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue