Navigation Menu

Skip to content
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

Add API to read CF_BITMAP #12

Closed
DoumanAsh opened this issue Feb 18, 2020 · 11 comments
Closed

Add API to read CF_BITMAP #12

DoumanAsh opened this issue Feb 18, 2020 · 11 comments

Comments

@DoumanAsh
Copy link
Owner

subj

@skygate2012
Copy link

Is it possible to write an image file to clipboard currently?

@DoumanAsh
Copy link
Owner Author

Sadly no, I'm only able to read BMP as CF_DIB

I wasn't sure how to write it so I left it for now.
I would welcome help because I'm really not familiar with these aspects on winapi

@vamolessa
Copy link
Contributor

Is it correct that I saw that the image module is not exposed (even included) in the library?
I've recently managed to extract a CF_BITMAP from the clipboard. You can check the code here (the get_clipboard_bitmap function):
https://github.com/matheuslessarodrigues/copycat/blob/master/src/main.rs

I'm too not familiar with using winapi from rust, but maybe we can work together to implement this feature?
Anyways, thanks for the crate!

@auyer
Copy link

auyer commented Jun 5, 2020

I've been having such a hard time placing an image into the clipboard, that I've decided to wait.
At first I was trying to do this with the API directly, but it's really not straight forward.
Since I'm new to both Rust and the winapi, I wont be much help implementing it, but I totally support you guys !
I'll be a day one user !

@DoumanAsh
Copy link
Owner Author

Ok, I'll give it a try on this weekend and will try to implement simple API to serialize BMP into suitable format for clipboard

@DoumanAsh
Copy link
Owner Author

DoumanAsh commented Jun 5, 2020

@matheuslessarodrigues I wasn't able to make CF_BITMAP work and only CF_DIB works via https://docs.rs/clipboard-win/3.0.2/clipboard_win/struct.Clipboard.html#method.get_dib

I'll give your code a try on this weekend

@vamolessa
Copy link
Contributor

I tired using CF_DIB however it almost worked: I could not get to generate valid bmp from a print from ShareX.

Also, sorry about this but I just dicovered that the code I posted does NOT work in release mode.
Oh well, I'll try to fix it before you try it.

@vamolessa
Copy link
Contributor

Just updated the code in https://github.com/matheuslessarodrigues/copycat/blob/master/src/main.rs
After wrapping some unsafe code, I managed to make it work in release mode as well. I think rust was trying to deallocate some
memory twice.

Btw, that code was translated from this: https://docs.microsoft.com/en-us/windows/win32/gdi/storing-an-image

@DoumanAsh
Copy link
Owner Author

hm you probably could just make PR? :)
I'd just review your code

@vamolessa
Copy link
Contributor

Just made one! #13

@DoumanAsh
Copy link
Owner Author

Released as part of 3.1.0

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants