From: Bernhard Übelacker <bernhardu@mailbox.org> Wine-Bug: https://bugs.winehq.org/show_bug.cgi?id=59362 --- dlls/gdiplus/image.c | 2 +- dlls/gdiplus/tests/image.c | 60 ++++++++++++++++++++++++++++++++++++++ 2 files changed, 61 insertions(+), 1 deletion(-) diff --git a/dlls/gdiplus/image.c b/dlls/gdiplus/image.c index 2449e2ec863..035db159d5b 100644 --- a/dlls/gdiplus/image.c +++ b/dlls/gdiplus/image.c @@ -1125,7 +1125,7 @@ GpStatus WINGDIPAPI GdipBitmapLockBits(GpBitmap* bitmap, GDIPCONST GpRect* rect, if(rect){ if(rect->X < 0 || rect->Y < 0 || (rect->X + rect->Width > bitmap->width) || - (rect->Y + rect->Height > bitmap->height) || !flags) + (rect->Y + rect->Height > bitmap->height)) { image_unlock(&bitmap->image); return InvalidParameter; diff --git a/dlls/gdiplus/tests/image.c b/dlls/gdiplus/tests/image.c index e3602ceb505..72b71a5dc86 100644 --- a/dlls/gdiplus/tests/image.c +++ b/dlls/gdiplus/tests/image.c @@ -901,6 +901,48 @@ static void test_LockBits(void) stat = GdipBitmapSetPixel(bm, 2, 8, 0xff480000); expect(Ok, stat); + /* no read/write flags, no conversion */ + stat = GdipBitmapLockBits(bm, &rect, 0, PixelFormat24bppRGB, &bd); + expect(Ok, stat); + + if (stat == Ok) { + expect(0xc3, ((BYTE*)bd.Scan0)[2]); + expect(0x48, ((BYTE*)bd.Scan0)[2 + bd.Stride * 5]); + + ((char*)bd.Scan0)[2] = 0xfd; + + stat = GdipBitmapUnlockBits(bm, &bd); + expect(Ok, stat); + } + + stat = GdipBitmapGetPixel(bm, 2, 3, &color); + expect(Ok, stat); + expect(0xfffd0000, color); + + stat = GdipBitmapSetPixel(bm, 2, 3, 0xffc30000); + expect(Ok, stat); + + /* no read/write flags, conversion */ + stat = GdipBitmapLockBits(bm, &rect, 0, PixelFormat32bppARGB, &bd); + expect(Ok, stat); + + if (stat == Ok) { + /* bits appear to be uninitialized */ + + ((char*)bd.Scan0)[2] = 0xfe; + + stat = GdipBitmapUnlockBits(bm, &bd); + expect(Ok, stat); + } + + /* writes do not work if there was a conversion */ + stat = GdipBitmapGetPixel(bm, 2, 3, &color); + expect(Ok, stat); + expect(0xffc30000, color); + + stat = GdipBitmapSetPixel(bm, 2, 3, 0xffc30000); + expect(Ok, stat); + /* read-only */ stat = GdipBitmapLockBits(bm, &rect, ImageLockModeRead, PixelFormat24bppRGB, &bd); expect(Ok, stat); @@ -1142,6 +1184,24 @@ static void test_LockBits_UserBuf(void) bd.Scan0 = &bits[2+3*WIDTH]; bd.Reserved = 0xaaaaaaaa; + /* no read/write flags, no conversion */ + stat = GdipBitmapLockBits(bm, &rect, ImageLockModeUserInputBuf, PixelFormat32bppARGB, &bd); + expect(Ok, stat); + + expect(0xaaaaaaaa, bits[0]); + expect(0xaaaaaaaa, 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); + /* read-only */ stat = GdipBitmapLockBits(bm, &rect, ImageLockModeRead|ImageLockModeUserInputBuf, PixelFormat32bppARGB, &bd); expect(Ok, stat); -- GitLab https://gitlab.winehq.org/wine/wine/-/merge_requests/10022