diff --git "a/win32ss/gdi/gdi32/objects/bitmap.c" "b/win32ss/gdi/gdi32/objects/bitmap.c" index 332aacb31ec..d2960e2919d 100644 --- "a/win32ss/gdi/gdi32/objects/bitmap.c" +++ "b/win32ss/gdi/gdi32/objects/bitmap.c" @@ -727,12 +727,12 @@ SetDIBitsToDevice( UINT cjBmpScanSize = 0; BOOL Hit = FALSE; PVOID pvSafeBits = (PVOID) Bits; - UINT bmiHeight; + UINT bmiHeight, ScanLinesOrig = ScanLines, ImageSizeOrig; BOOL top_down; INT src_y = 0; ULONG iFormat, cBitsPixel, cjBits, cjWidth; - #define MaxScanLines 1000 + #define MaxScanLines 6000 #define MaxHeight 2000 #define MaxSourceHeight 2000 #define IS_ALIGNED(Pointer, Alignment) \ @@ -741,13 +741,16 @@ SetDIBitsToDevice( if (!ScanLines || !lpbmi || !Bits) return 0; - DPRINT("ScanLines %d Height %d Width %d biHeight %d biWidth %d\n" - " lpbmi '%p' ColorUse '%d' SizeImage '%d' StartScan %d\n" - " biCompression '%d' biBitCount '%d'\n", - ScanLines, Height, Width, lpbmi->bmiHeader.biHeight, - lpbmi->bmiHeader.biWidth, lpbmi, ColorUse, - lpbmi->bmiHeader.biSizeImage, StartScan, - lpbmi->bmiHeader.biCompression, lpbmi->bmiHeader.biBitCount); + DPRINT("hdc %p, XDest %d, YDest, %d, Width %d, Height %d\n" + " XSrc %d, YSrc %d, StartScan %d, ScanLines %d, ColorUse %d\n" + " biHeight %d, biWidth %d\n" + " lpbmi %p, SizeImage %d\n" + " biCompression %d, biBitCount %d\n", + hdc, XDest, YDest, Width, Height, + XSrc, YSrc, StartScan, ScanLines, ColorUse, + lpbmi->bmiHeader.biHeight, lpbmi->bmiHeader.biWidth, + lpbmi, lpbmi->bmiHeader.biSizeImage, + lpbmi->bmiHeader.biCompression, lpbmi->bmiHeader.biBitCount); if (lpbmi->bmiHeader.biWidth < 0) return 0; @@ -765,6 +768,8 @@ SetDIBitsToDevice( goto Exit; } + ImageSizeOrig = pConvertedInfo->bmiHeader.biSizeImage; + bmiHeight = abs(pConvertedInfo->bmiHeader.biHeight); top_down = (pConvertedInfo->bmiHeader.biHeight < 0); if ((StartScan > bmiHeight) && (ScanLines > bmiHeight)) @@ -1028,15 +1033,15 @@ SetDIBitsToDevice( LinesCopied = bmiHeight; } - if (pConvertedInfo->bmiHeader.biHeight < 0) + if (pConvertedInfo->bmiHeader.biHeight < 0 && YDest >= 0) { - if (pConvertedInfo->bmiHeader.biHeight < -MaxSourceHeight || YDest >= 0) + if (Height * ScanLinesOrig > ImageSizeOrig && ImageSizeOrig != 0) { - LinesCopied = ScanLines + src_y; + LinesCopied = 0; } else { - LinesCopied = ScanLines; + LinesCopied = ScanLinesOrig; } }