Alexandre Julliard : gdi32: Replicate a Windows bug in StretchDIBits for top-down bitmaps in the non-stretching case .

Alexandre Julliard julliard at winehq.org
Tue Oct 5 14:41:45 CDT 2010


Module: wine
Branch: stable
Commit: d2755f23183a470e36054de9e6347f9423ed0985
URL:    http://source.winehq.org/git/wine.git/?a=commit;h=d2755f23183a470e36054de9e6347f9423ed0985

Author: Alexandre Julliard <julliard at winehq.org>
Date:   Fri Jul 30 14:19:25 2010 +0200

gdi32: Replicate a Windows bug in StretchDIBits for top-down bitmaps in the non-stretching case.

Found by Mathias Kosch.
(cherry picked from commit c68589e3dddcd93171b8af12e55b540689946d33)

---

 dlls/gdi32/dib.c          |    8 ++++++++
 dlls/gdi32/tests/bitmap.c |    2 +-
 2 files changed, 9 insertions(+), 1 deletions(-)

diff --git a/dlls/gdi32/dib.c b/dlls/gdi32/dib.c
index ce5ab8b..b95aee2 100644
--- a/dlls/gdi32/dib.c
+++ b/dlls/gdi32/dib.c
@@ -227,6 +227,14 @@ INT WINAPI StretchDIBits(HDC hdc, INT xDst, INT yDst, INT widthDst,
             return 0;
         }
 
+        if (xSrc == 0 && ySrc == 0 && widthDst == widthSrc && heightDst == heightSrc &&
+            info->bmiHeader.biCompression == BI_RGB)
+        {
+            /* Windows appears to have a fast case optimization
+             * that uses the wrong origin for top-down DIBs */
+            if (height < 0 && heightSrc < abs(height)) ySrc = abs(height) - heightSrc;
+        }
+
         hBitmap = GetCurrentObject(hdc, OBJ_BITMAP);
 
         if (xDst == 0 && yDst == 0 && xSrc == 0 && ySrc == 0 &&
diff --git a/dlls/gdi32/tests/bitmap.c b/dlls/gdi32/tests/bitmap.c
index 8e5ad2e..e141f1d 100644
--- a/dlls/gdi32/tests/bitmap.c
+++ b/dlls/gdi32/tests/bitmap.c
@@ -2813,7 +2813,7 @@ static void test_StretchDIBits(void)
     expected[2] = 0x00000000, expected[3] = 0x00000000;
     legacy_expected[0] = 0xFEDCBA98, legacy_expected[1] = 0x00000000;
     legacy_expected[2] = 0x00000000, legacy_expected[3] = 0x00000000;
-    todo_wine check_StretchDIBits_stretch(hdcDst, dstBuffer, srcBuffer,
+    check_StretchDIBits_stretch(hdcDst, dstBuffer, srcBuffer,
                                 0, 0, 1, 1, 0, 0, 1, 1, expected, legacy_expected, __LINE__);
 
     expected[0] = 0xFEDCBA98, expected[1] = 0xFEDCBA98;




More information about the wine-cvs mailing list