From 5978175ef8a1932ea6386abc3d49231ac7955a5c Mon Sep 17 00:00:00 2001 From: Vincent Wei Date: Mon, 3 May 2021 19:31:46 +0800 Subject: [PATCH] handle zero width/height for BitBlt and StretchBlt --- src/newgdi/bitmap.c | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/src/newgdi/bitmap.c b/src/newgdi/bitmap.c index 2e51167c..1702aa72 100644 --- a/src/newgdi/bitmap.c +++ b/src/newgdi/bitmap.c @@ -1112,6 +1112,8 @@ void GUIAPI BitBlt (HDC hsdc, int sx, int sy, int sw, int sh, sw += sx; sh += sy; coor_LP2SP (psdc, &sx, &sy); coor_LP2SP (psdc, &sw, &sh); + if (sw == sx) sw = sx + RECTW (psdc->DevRC); + if (sh == sy) sh = sy + RECTH (psdc->DevRC); SetRect (&srcOutput, sx, sy, sw, sh); NormalizeRect (&srcOutput); sx = srcOutput.left; sy = srcOutput.top; @@ -1383,6 +1385,8 @@ void GUIAPI StretchBltLegacy (HDC hsdc, int sx, int sy, int sw, int sh, sw += sx; sh += sy; coor_LP2SP(psdc, &sx, &sy); coor_LP2SP(psdc, &sw, &sh); + if (sw == sx) sw = sx + RECTW (psdc->DevRC); + if (sh == sy) sh = sy + RECTH (psdc->DevRC); SetRect (&srcOutput, sx, sy, sw, sh); NormalizeRect (&srcOutput); sx = srcOutput.left; sy = srcOutput.top; @@ -1391,6 +1395,8 @@ void GUIAPI StretchBltLegacy (HDC hsdc, int sx, int sy, int sw, int sh, dw += dx; dh += dy; coor_LP2SP (pddc, &dx, &dy); coor_LP2SP (pddc, &dw, &dh); + if (dw == dx) dw = dx + RECTW (pddc->DevRC); + if (dh == dy) dh = dy + RECTH (pddc->DevRC); SetRect (&dstOutput, dx, dy, dw, dh); NormalizeRect (&dstOutput); dx = dstOutput.left; dy = dstOutput.top; @@ -1491,6 +1497,8 @@ void GUIAPI StretchBlt (HDC hsdc, int sx, int sy, int sw, int sh, sw += sx; sh += sy; coor_LP2SP(psdc, &sx, &sy); coor_LP2SP(psdc, &sw, &sh); + if (sw == sx) sw = sx + RECTW (psdc->DevRC); + if (sh == sy) sh = sy + RECTH (psdc->DevRC); SetRect (&srcOutput, sx, sy, sw, sh); NormalizeRect (&srcOutput); sx = srcOutput.left; sy = srcOutput.top; @@ -1499,6 +1507,8 @@ void GUIAPI StretchBlt (HDC hsdc, int sx, int sy, int sw, int sh, dw += dx; dh += dy; coor_LP2SP (pddc, &dx, &dy); coor_LP2SP (pddc, &dw, &dh); + if (dw == dx) dw = dx + RECTW (pddc->DevRC); + if (dh == dy) dh = dy + RECTH (pddc->DevRC); SetRect (&dstOutput, dx, dy, dw, dh); NormalizeRect (&dstOutput); dx = dstOutput.left; dy = dstOutput.top;