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

Alexandre Julliard julliard at winehq.org
Fri Jul 30 10:24:16 CDT 2010


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

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.

---

 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 bf36986..c799ea3 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 3be5734..aa723bd 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