File tree Expand file tree Collapse file tree 2 files changed +17
-2
lines changed Expand file tree Collapse file tree 2 files changed +17
-2
lines changed Original file line number Diff line number Diff line change @@ -791,7 +791,10 @@ def __get_capture_for_comparison(self):
791
791
if self .settings_dict ["capture_method" ] == CaptureMethodEnum .VIDEO_CAPTURE_DEVICE :
792
792
self .live_image .setText ("Waiting for capture device..." )
793
793
else :
794
- self .live_image .setText ("Trying to recover window..." )
794
+ message = "Trying to recover window..."
795
+ if self .settings_dict ["capture_method" ] == CaptureMethodEnum .BITBLT :
796
+ message += "\n (captured window may be incompatible with BitBlt)"
797
+ self .live_image .setText (message )
795
798
recovered = self .capture_method .recover_window (self .settings_dict ["captured_window_title" ])
796
799
if recovered :
797
800
capture , _ = self .capture_method .get_frame ()
Original file line number Diff line number Diff line change 17
17
PW_RENDERFULLCONTENT = 0x00000002
18
18
19
19
20
+ def is_blank (image : MatLike ):
21
+ """
22
+ BitBlt can return a balnk buffer. Either because the target is unsupported,
23
+ or because there's two windows of the same name for the same executable.
24
+ """
25
+ return not image .any ()
26
+
27
+
20
28
class BitBltCaptureMethod (CaptureMethodBase ):
21
29
name = "BitBlt"
22
30
short_description = "fastest, least compatible"
@@ -61,11 +69,15 @@ def get_frame(self) -> tuple[MatLike | None, bool]:
61
69
win32con .SRCCOPY ,
62
70
)
63
71
image = np .frombuffer (cast (bytes , bitmap .GetBitmapBits (True )), dtype = np .uint8 )
64
- image .shape = (selection ["height" ], selection ["width" ], BGRA_CHANNEL_COUNT )
65
72
except (win32ui .error , pywintypes .error ):
66
73
# Invalid handle or the window was closed while it was being manipulated
67
74
return None , False
68
75
76
+ if is_blank (image ):
77
+ image = None
78
+ else :
79
+ image .shape = (selection ["height" ], selection ["width" ], BGRA_CHANNEL_COUNT )
80
+
69
81
# Cleanup DC and handle
70
82
try_delete_dc (dc_object )
71
83
try_delete_dc (compatible_dc )
You can’t perform that action at this time.
0 commit comments