Vincent Povirk : gdiplus: Handle negative stride in GdipCreateBitmapFromScan0.

Alexandre Julliard julliard at winehq.org
Wed Feb 18 10:15:25 CST 2009


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

Author: Vincent Povirk <vincent at codeweavers.com>
Date:   Tue Feb 17 14:05:37 2009 -0600

gdiplus: Handle negative stride in GdipCreateBitmapFromScan0.

---

 dlls/gdiplus/image.c       |   25 ++++++++++++++++---------
 dlls/gdiplus/tests/image.c |    6 ++----
 2 files changed, 18 insertions(+), 13 deletions(-)

diff --git a/dlls/gdiplus/image.c b/dlls/gdiplus/image.c
index 9944322..ab70354 100644
--- a/dlls/gdiplus/image.c
+++ b/dlls/gdiplus/image.c
@@ -496,12 +496,6 @@ GpStatus WINGDIPAPI GdipCreateBitmapFromScan0(INT width, INT height, INT stride,
     if(scan0 && !stride)
         return InvalidParameter;
 
-    /* FIXME: windows allows negative stride (reads backwards from scan0) */
-    if(stride < 0){
-        FIXME("negative stride\n");
-        return InvalidParameter;
-    }
-
     *bitmap = GdipAlloc(sizeof(GpBitmap));
     if(!*bitmap)    return OutOfMemory;
 
@@ -527,16 +521,29 @@ GpStatus WINGDIPAPI GdipCreateBitmapFromScan0(INT width, INT height, INT stride,
 
     bmih->biSize            = sizeof(BITMAPINFOHEADER);
     bmih->biWidth           = width;
-    bmih->biHeight          = -height;
     /* FIXME: use the rest of the data from format */
     bmih->biBitCount        = PIXELFORMATBPP(format);
     bmih->biCompression     = BI_RGB;
     bmih->biSizeImage       = datalen;
 
-    if(scan0)
-        memcpy(bmih + 1, scan0, datalen);
+    if (scan0)
+    {
+        if (stride > 0)
+        {
+            bmih->biHeight = -height;
+            memcpy(bmih + 1, scan0, datalen);
+        }
+        else
+        {
+            bmih->biHeight = height;
+            memcpy(bmih + 1, scan0 + stride * (height - 1), datalen);
+        }
+    }
     else
+    {
+        bmih->biHeight = height;
         memset(bmih + 1, 0, datalen);
+    }
 
     if(CreateStreamOnHGlobal(buff, TRUE, &stream) != S_OK){
         ERR("could not make stream\n");
diff --git a/dlls/gdiplus/tests/image.c b/dlls/gdiplus/tests/image.c
index f6a3bab..12fab7c 100644
--- a/dlls/gdiplus/tests/image.c
+++ b/dlls/gdiplus/tests/image.c
@@ -129,10 +129,8 @@ static void test_Scan0(void)
 
     bm = NULL;
     stat = GdipCreateBitmapFromScan0(10, 10, -8, PixelFormat24bppRGB, buff, &bm);
-    todo_wine{
-        expect(Ok, stat);
-        ok(NULL != bm, "Expected bitmap to be initialized\n");
-    }
+    expect(Ok, stat);
+    ok(NULL != bm, "Expected bitmap to be initialized\n");
     if (stat == Ok)
         GdipDisposeImage((GpImage*)bm);
 




More information about the wine-cvs mailing list