ShareXin / screenshot-rs

Simple library that allows for simple method of asking for screenshots from various Linux/BSD desktops
GNU General Public License v3.0
9 stars 3 forks source link

Feature request : Get image back instead of saving to file #3

Closed Hultan closed 5 years ago

Hultan commented 5 years ago

I need a way to get a screenshot, without saving it to a file first. Sure I can save it to a temporary file and then read it back, but that is a waste (performance wise).

I believe that the default, at least for gnome-screenshot, without the -f option is to copy it to the copy buffer. Maybe you could add functions for that? Or preferably returning an Image object so that we don't have to access the copy buffer?

thebitstick commented 5 years ago

With gnome-screenshot, not passing -f saves the image to the default location (usually $XDG_PICTURES_DIR or something). It does have -c for storing it in the clipboard, but not every screenshot-ing tool has this option so it would be a very fragmented solution. Also somehow copying the contents of the clipboard into some vector in Rust might work on X11, but probably not on Wayland. Also copying to clipboard is something I think should be avoided even on X11 because it may interfere with whatever a user may have been storing there. Also I believe /tmp (tmpfs) is actually stored in memory, so while technically saving an image to /tmp is a file operation, it's all in memory, so it isn't that different performance wise.

I don't think there is a solution to this so I'll be closing this issue. Sorry...

Hultan commented 5 years ago

Thank you for reminding me about saving a file /tmp actually being a memory operation, I have heard of that before but had completely forgotten that. The weird thing is that it took several seconds grabbing a screenshot using screenshot-rs, and I just assumed that it was because I have three screens and because it was a file operation. The file is only 500 kb though, and I have a SSD, so a little bit weird still. There must be something else taking time then, I'll have to investigate exactly what is happening in my code.

Anyway, I completely understand why you are closing this, thank you for your time (and for screenshot-rs)...