Fixed Windows bitmap copy #501

This commit is contained in:
vcaesar 2022-06-23 21:11:41 -07:00
parent e08e05307e
commit 1934220f50
2 changed files with 5 additions and 3 deletions

View File

@ -11,6 +11,7 @@ struct _MMBitmap {
uint8_t *imageBuffer; /* Pixels stored in Quad I format; */
int32_t width; /* Never 0, unless image is NULL. */
int32_t height; /* Never 0, unless image is NULL. */
int32_t bytewidth; /* The aligned width (width + padding). */
uint8_t bitsPerPixel; /* Should be either 24 or 32. */
uint8_t bytesPerPixel; /* For convenience; should be bitsPerPixel / 8. */

View File

@ -98,10 +98,11 @@ MMBitmapRef copyMMBitmapFromDisplayInRect(MMRectInt32 rect, int32_t display_id)
dib = CreateDIBSection(screen, &bi, DIB_RGB_COLORS, &data, NULL, 0);
/* Copy the data into a bitmap struct. */
BOOL smem = (screenMem = CreateCompatibleDC(screen)) == NULL;
BOOL bitb = BitBlt(screenMem, (int)0, (int)0, (int)rect.size.w, (int)rect.size.h,
BOOL b = (screenMem = CreateCompatibleDC(screen)) == 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);
if (smem || SelectObject(screenMem, dib) == NULL || !bitb) {
if (b) {
/* Error copying data. */
ReleaseDC(hwnd, screen);
DeleteObject(dib);