CrossCopy / tauri-plugin-clipboard

A Tauri clipboard plugin with text, files, html, RTF, and image support. Clipboard content update monitoring is also supported.
https://crosscopy.github.io/tauri-plugin-clipboard/
MIT License
122 stars 6 forks source link

write_image_binary does nothing #35

Closed SirRonBird closed 3 weeks ago

SirRonBird commented 1 month ago

Greetings,

Iam working on a project with Tauri and I want to wrte an image to the clipboard on Windows:

let mut img_bytes = Vec::new();
img.read_to_end(&mut img_bytes).unwrap();
let clipboard = app.state::<tauri_plugin_clipboard::ClipboardManager>();
let res = clipboard.write_image_binary(img_bytes);

match res {
    Ok(_) => println!("Image added to clipboard"),
    Err(e) => println!("Error {}, e);
}

The only response iam getting is "wrting bin image to clipboard" but neither the res is evaluated, it seems like the function wrtie_image_binary is just doing nothing...

Did i something wrong?

HuakunShen commented 3 weeks ago

It works me. The image has to be png file. If the demo app works for you, then the rust code must work. You may have wrong format.

I read image bytes like this let img_bytes = std::fs::read("screenshot.png").unwrap();

In rust you could also use the clipboard-rs crate directly which is the underlying library for this plugin.

SirRonBird commented 2 weeks ago

Its working.. I was dumb and throught the copied image can be pasted like a file...