Merge pull request #554 from go-vgo/bitmap-pr

Fix: fixed mac multi screen capture
This commit is contained in:
Evans 2023-01-11 16:10:44 -08:00 committed by GitHub
commit 4bc64ebf67
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -20,7 +20,7 @@ MMBitmapRef copyMMBitmapFromDisplayInRect(MMRectInt32 rect, int32_t display_id)
size_t bufferSize = 0;
CGDirectDisplayID displayID = (CGDirectDisplayID) display_id;
if (displayID == -1) {
if (displayID == -1 || displayID == 0) {
displayID = CGMainDisplayID();
}
@ -94,11 +94,13 @@ MMBitmapRef copyMMBitmapFromDisplayInRect(MMRectInt32 rect, int32_t display_id)
}
if (screen == NULL) { return NULL; }
// Todo:
screenMem = CreateCompatibleDC(screen);
/* Get screen data in display device context. */
dib = CreateDIBSection(screen, &bi, DIB_RGB_COLORS, &data, NULL, 0);
/* Copy the data into a bitmap struct. */
BOOL b = (screenMem = CreateCompatibleDC(screen)) == NULL ||
BOOL b = (screenMem == NULL) ||
SelectObject(screenMem, dib) == NULL ||
!BitBlt(screenMem, (int)0, (int)0, (int)rect.size.w, (int)rect.size.h,
screen, rect.origin.x, rect.origin.y, SRCCOPY);