From 46beb9ab86b30796e3797f76a6fb0a19ef1db956 Mon Sep 17 00:00:00 2001 From: Vincent Povirk Date: Mon, 14 Feb 2011 16:39:35 -0600 Subject: [PATCH 2/3] gdiplus: Add test for ImageLockModeUserInputBuf. --- dlls/gdiplus/tests/image.c | 85 ++++++++++++++++++++++++++++++++++++++++++++ 1 files changed, 85 insertions(+), 0 deletions(-) diff --git a/dlls/gdiplus/tests/image.c b/dlls/gdiplus/tests/image.c index 6e62178..41d9426 100644 --- a/dlls/gdiplus/tests/image.c +++ b/dlls/gdiplus/tests/image.c @@ -621,6 +621,90 @@ static void test_LockBits(void) expect(Ok, stat); } +static void test_LockBits_UserBuf(void) +{ + GpStatus stat; + GpBitmap *bm; + GpRect rect; + BitmapData bd; + const INT WIDTH = 10, HEIGHT = 20; + DWORD bits[200]; + ARGB color; + + bm = NULL; + stat = GdipCreateBitmapFromScan0(WIDTH, HEIGHT, 0, PixelFormat32bppARGB, NULL, &bm); + expect(Ok, stat); + + memset(bits, 0xaa, sizeof(bits)); + + rect.X = 2; + rect.Y = 3; + rect.Width = 4; + rect.Height = 5; + + bd.Width = 4; + bd.Height = 6; + bd.Stride = WIDTH * 4; + bd.PixelFormat = PixelFormat32bppARGB; + bd.Scan0 = &bits[2+3*WIDTH]; + bd.Reserved = 0xaaaaaaaa; + + /* read-only */ + stat = GdipBitmapLockBits(bm, &rect, ImageLockModeRead|ImageLockModeUserInputBuf, PixelFormat32bppARGB, &bd); + todo_wine expect(Ok, stat); + + expect(0xaaaaaaaa, bits[0]); + todo_wine expect(0, bits[2+3*WIDTH]); + + bits[2+3*WIDTH] = 0xdeadbeef; + + if (stat == Ok) { + stat = GdipBitmapUnlockBits(bm, &bd); + expect(Ok, stat); + } + + stat = GdipBitmapGetPixel(bm, 2, 3, &color); + expect(Ok, stat); + expect(0, color); + + /* write-only */ + stat = GdipBitmapLockBits(bm, &rect, ImageLockModeWrite|ImageLockModeUserInputBuf, PixelFormat32bppARGB, &bd); + todo_wine expect(Ok, stat); + + expect(0xdeadbeef, bits[2+3*WIDTH]); + bits[2+3*WIDTH] = 0x12345678; + + if (stat == Ok) { + stat = GdipBitmapUnlockBits(bm, &bd); + expect(Ok, stat); + } + + stat = GdipBitmapGetPixel(bm, 2, 3, &color); + expect(Ok, stat); + todo_wine expect(0x12345678, color); + + bits[2+3*WIDTH] = 0; + + /* read/write */ + stat = GdipBitmapLockBits(bm, &rect, ImageLockModeRead|ImageLockModeWrite|ImageLockModeUserInputBuf, PixelFormat32bppARGB, &bd); + todo_wine expect(Ok, stat); + + todo_wine expect(0x12345678, bits[2+3*WIDTH]); + bits[2+3*WIDTH] = 0xdeadbeef; + + if (stat == Ok) { + stat = GdipBitmapUnlockBits(bm, &bd); + expect(Ok, stat); + } + + stat = GdipBitmapGetPixel(bm, 2, 3, &color); + expect(Ok, stat); + todo_wine expect(0xdeadbeef, color); + + stat = GdipDisposeImage((GpImage*)bm); + expect(Ok, stat); +} + static void test_GdipCreateBitmapFromHBITMAP(void) { GpBitmap* gpbm = NULL; @@ -2295,6 +2379,7 @@ START_TEST(image) test_SavingImages(); test_encoders(); test_LockBits(); + test_LockBits_UserBuf(); test_GdipCreateBitmapFromHBITMAP(); test_GdipGetImageFlags(); test_GdipCloneImage(); -- 1.7.1