[gimp] Bug 793722 - Capture screenshot of single window fails if...
- From: Jehan Pagès <jehanp src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gimp] Bug 793722 - Capture screenshot of single window fails if...
- Date: Fri, 23 Feb 2018 17:22:18 +0000 (UTC)
commit 14236761cdf528f4a7493a1c9f781c7909687923
Author: Simon Mueller <s mueller hn web de>
Date: Fri Feb 23 16:39:13 2018 +0100
Bug 793722 - Capture screenshot of single window fails if...
... thewindow is IE 11.
The screenshot plugin for windows had a problem when capturing
applications that use hardware rendering acceleration (e.g.
Chromium-based Apps, IE11). Those applications seem to render their
content to a device context (DC) that is different from the one that can
be retrieved via GetDCEx(hWnd). So a screenshot that simply copies the
main window DC will be incomplete (see bug attachment) or just plain
black.
This patch removes the code that uses GetDCEx for single window
screenshots and always uses the display device context instead. This
makes sure that all window contents are actually visible in the
screenshot. With this change, we now have to set the source coordinates
in the call to BitBlt() to the window's coordinates to exclude
everything that isn't the window from the screenshot when doing a single
window screenshot.
Review comment by Jehan: as Simon notes in bug 793722, there is a
regression though, which is that this new code cannot capture any part
of a window which is not in any screen. This is still an improvement
because at least for what is on screen, we always get exactly the same
as what is displayed. This is especially true since hardware-accelerated
applications are more and more common. So let's push this first commit
and hope for further improvements.
plug-ins/screenshot/screenshot-win32.c | 29 +++++++++--------------------
1 files changed, 9 insertions(+), 20 deletions(-)
---
diff --git a/plug-ins/screenshot/screenshot-win32.c b/plug-ins/screenshot/screenshot-win32.c
index 277f9a5..2fe1ef6 100644
--- a/plug-ins/screenshot/screenshot-win32.c
+++ b/plug-ins/screenshot/screenshot-win32.c
@@ -407,7 +407,7 @@ primDoWindowCapture (HDC hdcWindow,
*/
if (!BitBlt(hdcCompat, 0,0,
width, height,
- hdcWindow, 0,0,
+ hdcWindow, rect.left, rect.top,
SRCCOPY))
{
formatWindowsError (buffer, sizeof buffer);
@@ -433,7 +433,6 @@ doCapture (HWND selectedHwnd)
{
HDC hdcSrc;
HDC hdcCompat;
- HRGN capRegion;
HWND oldForeground;
RECT rect;
HBITMAP hbm;
@@ -443,10 +442,17 @@ doCapture (HWND selectedHwnd)
*/
Sleep (500 + winsnapvals.delay * 1000);
+ /* Get the device context for the whole screen
+ * even if we just want to capture a window.
+ * this will allow to capture applications that
+ * don't render to their main window's device
+ * context (e.g. browsers).
+ */
+ hdcSrc = CreateDC (TEXT("DISPLAY"), NULL, NULL, NULL);
+
/* Are we capturing a window or the whole screen */
if (selectedHwnd)
{
-
/* Set to foreground window */
oldForeground = GetForegroundWindow ();
SetForegroundWindow (selectedHwnd);
@@ -456,27 +462,10 @@ doCapture (HWND selectedHwnd)
/* Build a region for the capture */
GetWindowRect (selectedHwnd, &rect);
- capRegion = CreateRectRgn (rect.left, rect.top,
- rect.right, rect.bottom);
- if (!capRegion)
- {
- formatWindowsError (buffer, sizeof buffer);
- g_error ("Error creating region: %s", buffer);
- return FALSE;
- }
- /* Get the device context for the selected
- * window. Create a memory DC to use for the
- * Bit copy.
- */
- hdcSrc = GetDCEx (selectedHwnd, capRegion,
- DCX_WINDOW | DCX_PARENTCLIP | DCX_INTERSECTRGN);
}
else
{
- /* Get the device context for the whole screen */
- hdcSrc = CreateDC ("DISPLAY", NULL, NULL, NULL);
-
/* Get the screen's rectangle */
rect.top = 0;
rect.bottom = GetDeviceCaps (hdcSrc, VERTRES);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]