-
Notifications
You must be signed in to change notification settings - Fork 9
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Does the get_image Method Support Windows? #8
Comments
@whwanyt |
Maybe I am not compatible with all image formats, you can provide
|
@ChurchTao I will reply to the code result at night because I am not in front of the computer right now. |
@whwanyt |
I may have guessed your problem. If you use the const TMP_PATH: &str = "C:\\Windows\\Temp\\test.png"; I optimized the demo code so that it can run directly in Windows. You can take a look. 8058263#diff-7bf759a09f1216d26074fca12a9e8a2aac8ca2d0392e34ed84fa6974d988aa9bR3 |
I used the following sample code to get the clipboard picture and convert it to a base64 character string: use base64::{engine::general_purpose, Engine as _};
use clipboard_rs::{common::RustImage, Clipboard, ClipboardContext};
fn main() {
let ctx = ClipboardContext::new().unwrap();
let image = ctx.get_image().unwrap();
match image.to_png() {
Ok(res) => {
let image_bytes = res.get_bytes();
let base64_str = general_purpose::STANDARD_NO_PAD.encode(&image_bytes);
println!("{}", base64_str);
}
Err(e) => {
println!("err: {}", e)
}
}
} The output is as follows:
I use electron _ screenshot this plugin to achieve screenshots to the clipboard |
Thank you for your reply, my goal is to get the image of the screen captured using the plugin by get_image method and convert it to base64 format |
@whwanyt |
The print type results are as follows
|
@whwanyt |
@whwanyt |
The new version has been released. I will close this issue for now. If there are any problems, just reopen it. |
Hello,
I'm experiencing an issue with the clipboard_rs crate on Windows 10, where I'm unable to retrieve an image from the clipboard using the provided example code. Despite having used the clipboard image tool to copy an image to the clipboard, the result returned by
get_image
is an empty image.Here is the code snippet I'm using:
The text was updated successfully, but these errors were encountered: