mirror of
https://github.com/RGBCube/serenity
synced 2025-07-27 03:37:45 +00:00
shot: Added option to output to clipboard instead of file
This allows screenshots to be easily used in PixelPaint for example :^)
This commit is contained in:
parent
c01f4c3ed8
commit
f4bd095aa3
1 changed files with 9 additions and 0 deletions
|
@ -29,6 +29,7 @@
|
|||
#include <LibCore/DateTime.h>
|
||||
#include <LibCore/File.h>
|
||||
#include <LibGUI/Application.h>
|
||||
#include <LibGUI/Clipboard.h>
|
||||
#include <LibGUI/WindowServerConnection.h>
|
||||
#include <LibGfx/PNGWriter.h>
|
||||
|
||||
|
@ -37,7 +38,10 @@ int main(int argc, char** argv)
|
|||
Core::ArgsParser args_parser;
|
||||
|
||||
String output_path;
|
||||
bool output_to_clipboard = false;
|
||||
|
||||
args_parser.add_positional_argument(output_path, "Output filename", "output", Core::ArgsParser::Required::No);
|
||||
args_parser.add_option(output_to_clipboard, "Output to clipboard", "clipboard", 'c');
|
||||
|
||||
args_parser.parse(argc, argv);
|
||||
|
||||
|
@ -54,6 +58,11 @@ int main(int argc, char** argv)
|
|||
return 1;
|
||||
}
|
||||
|
||||
if (output_to_clipboard) {
|
||||
GUI::Clipboard::the().set_bitmap(*bitmap);
|
||||
return 0;
|
||||
}
|
||||
|
||||
Gfx::PNGWriter writer;
|
||||
auto encoded_bitmap = writer.write(bitmap);
|
||||
if (encoded_bitmap.is_empty()) {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue