Module: wine Branch: master Commit: d086af1d365f92e23d0d9d93f2e0af2f41c62877 URL: http://source.winehq.org/git/wine.git/?a=commit;h=d086af1d365f92e23d0d9d93f2...
Author: Vincent Povirk vincent@codeweavers.com Date: Thu Feb 24 16:04:04 2011 -0600
gdiplus: Test writes with conversion and without a user buffer.
---
dlls/gdiplus/tests/image.c | 18 ++++++++++++++++++ 1 files changed, 18 insertions(+), 0 deletions(-)
diff --git a/dlls/gdiplus/tests/image.c b/dlls/gdiplus/tests/image.c index fb2ec28..dde040a 100644 --- a/dlls/gdiplus/tests/image.c +++ b/dlls/gdiplus/tests/image.c @@ -517,6 +517,7 @@ static void test_LockBits(void) BitmapData bd; const INT WIDTH = 10, HEIGHT = 20; ARGB color; + int y;
bm = NULL; stat = GdipCreateBitmapFromScan0(WIDTH, HEIGHT, 0, PixelFormat24bppRGB, NULL, &bm); @@ -645,6 +646,7 @@ static void test_LockBits(void)
if (stat == Ok) { expect(0xff, ((BYTE*)bd.Scan0)[2]); + ((BYTE*)bd.Scan0)[1] = 0x88; if (0) /* Areas outside the rectangle appear to be uninitialized */ ok(0xc3 != ((BYTE*)bd.Scan0)[2 + bd.Stride * 5], "original image bits are readable\n"); @@ -653,6 +655,10 @@ static void test_LockBits(void) expect(Ok, stat); }
+ stat = GdipBitmapGetPixel(bm, 2, 3, &color); + expect(Ok, stat); + todo_wine expect(0xffff8800, color); + /* write, conversion */ stat = GdipBitmapLockBits(bm, &rect, ImageLockModeWrite, PixelFormat32bppARGB, &bd); expect(Ok, stat); @@ -665,10 +671,22 @@ static void test_LockBits(void) ok(0xc3 != ((BYTE*)bd.Scan0)[2 + bd.Stride * 5], "original image bits are readable\n"); }
+ /* Initialize the buffer so the unlock doesn't access undefined memory */ + for (y=0; y<5; y++) + memset(((BYTE*)bd.Scan0) + bd.Stride * y, 0, 12); + + ((BYTE*)bd.Scan0)[0] = 0x12; + ((BYTE*)bd.Scan0)[1] = 0x34; + ((BYTE*)bd.Scan0)[2] = 0x56; + stat = GdipBitmapUnlockBits(bm, &bd); expect(Ok, stat); }
+ stat = GdipBitmapGetPixel(bm, 2, 3, &color); + expect(Ok, stat); + expect(0xff563412, color); + stat = GdipDisposeImage((GpImage*)bm); expect(Ok, stat); stat = GdipCreateBitmapFromScan0(WIDTH, HEIGHT, 0, PixelFormat24bppRGB, NULL, &bm);