mirror of https://github.com/Aloxaf/silicon
Fix
This commit is contained in:
parent
db13d66f58
commit
57c85c0dae
|
@ -3,15 +3,18 @@ use image::DynamicImage;
|
|||
|
||||
#[cfg(target_os = "windows")]
|
||||
pub fn dump_image_to_clipboard(image: &DynamicImage) -> Result<(), Error> {
|
||||
use clipboard_win::{Clipboard, formats};
|
||||
use std::ffi::c_void;
|
||||
use clipboard_win::{Clipboard, formats, image::Bitmap};
|
||||
use image::ImageOutputFormat;
|
||||
|
||||
let mut buffer = vec![];
|
||||
image.write_to(&mut buffer, ImageOutputFormat::BMP)?;
|
||||
|
||||
let bmp = Bitmap::new(buffer.as_mut_ptr() as *mut c_void)?;
|
||||
|
||||
Clipboard::new()
|
||||
.unwrap()
|
||||
.set(formats::CF_BITMAP, &buffer)
|
||||
.set(formats::CF_BITMAP, bmp.as_bytes())
|
||||
.map_err(|e| format_err!("Failed to copy image to clipboard: {}", e))?;
|
||||
|
||||
Ok(())
|
||||
|
|
Loading…
Reference in New Issue