SFML community forums

General => SFML projects => Topic started by: spacechase0 on October 25, 2012, 06:17:29 pm

Title: QuickSnap - Screenshot program
Post by: spacechase0 on October 25, 2012, 06:17:29 pm
(Not sure if anything else uses that name. It was the first thing I thought of. :P)

This is just a quick little tool to take screenshots. An IM program called Trillian allows me to directly paste an image from my clipboard into chat. I got tired doing this every time I wanted to screenshot something:


So, I made this. :) It works with multiple monitors (or at least, two same-sized monitors).

Starting the program appears to do nothing. Instead, it needs to be activated by a key combination:

Pressing Ctrl+PAGE_UP will lighten the entire screen, and a small black circle will follow your mouse. Now, click and drag, and a black rectangle will show the selection area. If you aren't happy with that rectangle, you can choose another. Once you've chosen an area, press enter. The white area and black rectangle should disappear, and the new screenshot will appear in your clipboard. It is also saved to "%APPDATA%/quicksnap".

If you want to close it for some reason, press Ctrl+PAGE_DOWN. A window should show up like this:

(http://tools.spacechase0.com/files/2012/10/quicksnap-close.png)

Pressing the red "No" button will let it continue running, and pressing the green "Yes" button will close it. Once it is closed, you can't do Ctrl+PAGE_UP anymore.

If you hadn't guessed by the "%APPDATA%" comment earlier, it's Windows-only (although it should be fairly easy to port). It would probably work great as a startup program though!

Download
Version 0.1.1: Download (http://tools.spacechase0.com/files/2012/10/0.1.1-Quicksnap.zip)
Version 0.1.0: Download (http://tools.spacechase0.com/files/2012/10/QuickSnap.zip)

The source code is here (https://github.com/spacechase0/QuickSnap).

Changelog
Quote
[10/25/2012] Initial Release
[11/5/2012] Fixed issue with images being washed out on some computers.
Title: Re: QuickSnap - Screenshot program
Post by: Mario on October 26, 2012, 03:44:44 pm
Sounds a lot like Microsoft's Clipping Tool.

More interesting question: How far is SFML involved? Would it work cross-platform, etc.?
Title: Re: QuickSnap - Screenshot program
Post by: spacechase0 on October 26, 2012, 04:47:48 pm
Never heard of Microsoft's program. :P

At the moment SFML is used for for the global keyboard shortcuts (sf::Keyboard), opening the windows (and drawing on them), and saving the screenshot (sf::Image).

Currently, the windows API is used for:

I think Laurent has some of these (ie. multiple monitor support) planned, but I thought I saw at one point other things probably wouldn't happen (transparent windows, clipboard).

It should be fairly easy to port though, since I have everything OS-specific in separate functions.
Title: Re: QuickSnap - Screenshot program
Post by: Foaly on October 26, 2012, 05:52:50 pm
Very nice. I would love to take a look at the source code.
Title: Re: QuickSnap - Screenshot program
Post by: Mario on October 27, 2012, 03:55:59 pm
Microsoft's program has been part of OneNote's systray icon, which is now the standalone "Clipping Tool". There's no real UI to copy or show though (other than selecting how/where to save).
Title: Re: QuickSnap - Screenshot program
Post by: spacechase0 on October 27, 2012, 04:36:06 pm
Added the source code here (https://github.com/spacechase0/QuickSnap).

I didn't end up actually cleaning it up much, just organizing it into multiple files. :P
Title: Re: QuickSnap - Screenshot program
Post by: Krofna on October 27, 2012, 09:49:08 pm
main.cpp, line 10:
Where did you get those numbers from?!?! Hex editor?
Title: Re: QuickSnap - Screenshot program
Post by: eXpl0it3r on October 27, 2012, 11:33:53 pm
main.cpp, line 10:
Where did you get those numbers from?!?! Hex editor?
Which numbers? I don't see anything, see here (https://github.com/spacechase0/QuickSnap/blob/master/src/main.cpp#L10).
Title: Re: QuickSnap - Screenshot program
Post by: FRex on October 27, 2012, 11:39:48 pm
There are hex numbers there as const sf::Uint8 FONT[] to use load from memory on them, a bit like what sfml did before default font removal.
Title: Re: QuickSnap - Screenshot program
Post by: eXpl0it3r on October 27, 2012, 11:42:10 pm
There are hex numbers there as const sf::Uint8 FONT[] to use load from memory on them, a bit like what sfml did before default font removal.
Oh GitHub simply suppressed that in the normal view. The RAW output (https://raw.github.com/spacechase0/QuickSnap/master/src/main.cpp) shows it though.
Title: Re: QuickSnap - Screenshot program
Post by: spacechase0 on October 28, 2012, 01:10:44 am
main.cpp, line 10:
Where did you get those numbers from?!?! Hex editor?
At one point Laurent had posted a code snippet that would dump a file like that. It had a few issues though, at least for me (sometimes it printed 3 extra bytes for a single 0x, which made a bunch of warnings :P), so I had to tweak it some.

Here's the tweaked code: http://pastebin.com/tZYQfeCS (http://pastebin.com/tZYQfeCS)
Title: Re: QuickSnap - Screenshot program
Post by: spacechase0 on November 05, 2012, 05:30:53 pm
Uploaded a new version which fixes an issue with washed-out images on some computers.