Quellcode durchsuchen

Compositor: Add API to get the color of a pixel

This just returns the color of a given pixel position from the
front bitmap of the corresponding screen.
Mustafa Quraish vor 3 Jahren
Ursprung
Commit
3da4fdd0eb

+ 5 - 0
Userland/Services/WindowServer/Compositor.cpp

@@ -78,6 +78,11 @@ const Gfx::Bitmap& Compositor::front_bitmap_for_screenshot(Badge<ClientConnectio
     return *screen.compositor_screen_data().m_front_bitmap;
 }
 
+Gfx::Color Compositor::color_at_position(Badge<ClientConnection>, Screen& screen, Gfx::IntPoint const& position) const
+{
+    return screen.compositor_screen_data().m_front_bitmap->get_pixel(position);
+}
+
 void CompositorScreenData::init_bitmaps(Compositor& compositor, Screen& screen)
 {
     // Recreate the screen-number overlay as the Screen instances may have changed, or get rid of it if we no longer need it

+ 1 - 0
Userland/Services/WindowServer/Compositor.h

@@ -176,6 +176,7 @@ public:
 
     const Gfx::Bitmap* cursor_bitmap_for_screenshot(Badge<ClientConnection>, Screen&) const;
     const Gfx::Bitmap& front_bitmap_for_screenshot(Badge<ClientConnection>, Screen&) const;
+    Gfx::Color color_at_position(Badge<ClientConnection>, Screen&, Gfx::IntPoint const&) const;
 
     void register_animation(Badge<Animation>, Animation&);
     void unregister_animation(Badge<Animation>, Animation&);