Akihiro Sagawa : msvfw32: Drawdib doesn't support inverted DIBs.

Alexandre Julliard julliard at winehq.org
Fri May 2 11:50:37 CDT 2014


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

Author: Akihiro Sagawa <sagawa.aki at gmail.com>
Date:   Fri May  2 22:14:22 2014 +0900

msvfw32: Drawdib doesn't support inverted DIBs.

---

 dlls/msvfw32/drawdib.c       |   17 ++++++++++++++---
 dlls/msvfw32/tests/drawdib.c |    7 +++++++
 2 files changed, 21 insertions(+), 3 deletions(-)

diff --git a/dlls/msvfw32/drawdib.c b/dlls/msvfw32/drawdib.c
index 9877e62..2916126 100644
--- a/dlls/msvfw32/drawdib.c
+++ b/dlls/msvfw32/drawdib.c
@@ -246,9 +246,18 @@ BOOL VFWAPI DrawDibBegin(HDRAWDIB hdd,
         DWORD dwSize;
         /* No compression */
         TRACE("Not compressed!\n");
-        dwSize = lpbi->biSize + num_colours(lpbi)*sizeof(RGBQUAD);
-        whdd->lpbiOut = HeapAlloc(GetProcessHeap(), 0, dwSize);
-        memcpy(whdd->lpbiOut, lpbi, dwSize);
+        if (lpbi->biHeight <= 0)
+        {
+            /* we don't draw inverted DIBs */
+            TRACE("detected inverted DIB\n");
+            ret = FALSE;
+        }
+        else
+        {
+            dwSize = lpbi->biSize + num_colours(lpbi)*sizeof(RGBQUAD);
+            whdd->lpbiOut = HeapAlloc(GetProcessHeap(), 0, dwSize);
+            memcpy(whdd->lpbiOut, lpbi, dwSize);
+        }
     }
 
     if (ret) 
@@ -332,6 +341,8 @@ BOOL VFWAPI DrawDibDraw(HDRAWDIB hdd, HDC hdc,
     {
         TRACE("Something changed!\n");
         ret = DrawDibBegin(hdd, hdc, dxDst, dyDst, lpbi, dxSrc, dySrc, 0);
+        if (!ret)
+            return ret;
     }
 
 #undef CHANGED
diff --git a/dlls/msvfw32/tests/drawdib.c b/dlls/msvfw32/tests/drawdib.c
index 54dd813..24d8631 100644
--- a/dlls/msvfw32/tests/drawdib.c
+++ b/dlls/msvfw32/tests/drawdib.c
@@ -98,6 +98,13 @@ static void test_DrawDib_sizeimage(void)
         {  WIDTH,   HEIGHT, WIDTH * HEIGHT * sizeof(RGBQUAD), "bc943d5ab024b8b0118d0a80aa283055d39942b8" },
         /* [1] zero size */
         {  WIDTH,   HEIGHT, 0, "bc943d5ab024b8b0118d0a80aa283055d39942b8" },
+        /* error patterns */
+        {  WIDTH,  -HEIGHT, 0, "" },
+        { -WIDTH,   HEIGHT, 0, "" },
+        { -WIDTH,  -HEIGHT, 0, "" },
+        {      0,        0, 0, "" },
+        {      0,   HEIGHT, 0, "" },
+        {  WIDTH,        0, 0, "" },
     };
     HDC hdc;
     DWORD src_dib_size, dst_dib_size;




More information about the wine-cvs mailing list