From 94fffb701ce88adf7398fb37a007a04c08f1ca6f Mon Sep 17 00:00:00 2001 From: ManoloFLTK <41016272+ManoloFLTK@users.noreply.github.com> Date: Thu, 6 Jun 2019 18:28:49 +0200 Subject: Add one argument to Fl_Screen_Driver::read_win_rectangle() The new argument gives the window to be captured, or NULL to indicate capture from the current offscreen. Calling this function becomes easier because less dependent on global variables. --- src/drivers/WinAPI/Fl_WinAPI_Screen_Driver.H | 4 ++-- src/drivers/WinAPI/Fl_WinAPI_Screen_Driver.cxx | 8 +++++--- 2 files changed, 7 insertions(+), 5 deletions(-) (limited to 'src/drivers/WinAPI') diff --git a/src/drivers/WinAPI/Fl_WinAPI_Screen_Driver.H b/src/drivers/WinAPI/Fl_WinAPI_Screen_Driver.H index 16bf3ebdf..605f3bffd 100644 --- a/src/drivers/WinAPI/Fl_WinAPI_Screen_Driver.H +++ b/src/drivers/WinAPI/Fl_WinAPI_Screen_Driver.H @@ -75,8 +75,8 @@ public: virtual void remove_timeout(Fl_Timeout_Handler cb, void *argp); virtual int dnd(int unused); virtual int compose(int &del); - virtual Fl_RGB_Image *read_win_rectangle(int X, int Y, int w, int h); - Fl_RGB_Image *read_win_rectangle_unscaled(int X, int Y, int w, int h); + virtual Fl_RGB_Image *read_win_rectangle(int X, int Y, int w, int h, Fl_Window *win); + Fl_RGB_Image *read_win_rectangle_unscaled(int X, int Y, int w, int h, Fl_Window *win); virtual int get_mouse(int &x, int &y); virtual void enable_im(); virtual void disable_im(); diff --git a/src/drivers/WinAPI/Fl_WinAPI_Screen_Driver.cxx b/src/drivers/WinAPI/Fl_WinAPI_Screen_Driver.cxx index 147933446..f390a4f50 100644 --- a/src/drivers/WinAPI/Fl_WinAPI_Screen_Driver.cxx +++ b/src/drivers/WinAPI/Fl_WinAPI_Screen_Driver.cxx @@ -501,7 +501,8 @@ Fl_WinAPI_Screen_Driver::read_win_rectangle( int X, // I - Left position int Y, // I - Top position int w, // I - Width of area to read - int h) // I - Height of area to read + int h, // I - Height of area to read + Fl_Window *win) // I - window to capture from or NULL to capture from current offscreen { float s = Fl_Surface_Device::surface()->driver()->scale(); int ws, hs; @@ -512,10 +513,10 @@ Fl_WinAPI_Screen_Driver::read_win_rectangle( if (ws < 1) ws = 1; if (hs < 1) hs = 1; } - return read_win_rectangle_unscaled(X*s, Y*s, ws, hs); + return read_win_rectangle_unscaled(X*s, Y*s, ws, hs, win); } -Fl_RGB_Image *Fl_WinAPI_Screen_Driver::read_win_rectangle_unscaled(int X, int Y, int w, int h) +Fl_RGB_Image *Fl_WinAPI_Screen_Driver::read_win_rectangle_unscaled(int X, int Y, int w, int h, Fl_Window *win) { int d = 3; // Depth of image int alpha = 0; uchar *p = NULL; @@ -569,6 +570,7 @@ Fl_RGB_Image *Fl_WinAPI_Screen_Driver::read_win_rectangle_unscaled(int X, int Y, bi.bmiHeader.biClrImportant = 0; // copy bitmap from original DC (Window, Fl_Offscreen, ...) + if (win && Fl_Window::current() != win) win->make_current(); HDC gc = (HDC)fl_graphics_driver->gc(); HDC hdc = CreateCompatibleDC(gc); HBITMAP hbm = CreateCompatibleBitmap(gc,w,h); -- cgit v1.2.3