1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-05-14 09:04:59 +00:00

shot: Get only cropped region from WindowServer

Previously, we were always getting the full screen(s) bitmap from
the WindowServer and cropping it manually. The `get_screen_bitmap`
function already took in a `crop_region`, so we are now utilizing
that.
This commit is contained in:
Mustafa Quraish 2021-08-27 23:03:21 -04:00 committed by Linus Groh
parent 5f23958abd
commit 2dea772d48

View file

@ -131,7 +131,7 @@ int main(int argc, char** argv)
if (screen >= 0)
screen_index = (u32)screen;
dbgln("getting screenshot...");
auto shared_bitmap = GUI::WindowServerConnection::the().get_screen_bitmap({}, screen_index);
auto shared_bitmap = GUI::WindowServerConnection::the().get_screen_bitmap(crop_region, screen_index);
dbgln("got screenshot");
RefPtr<Gfx::Bitmap> bitmap = shared_bitmap.bitmap();
@ -140,10 +140,6 @@ int main(int argc, char** argv)
return 1;
}
if (select_region) {
bitmap = bitmap->cropped(crop_region);
}
if (output_to_clipboard) {
GUI::Clipboard::the().set_bitmap(*bitmap);
return 0;