Module: wine Branch: master Commit: 9ab004d56af62ed34c041fa3eff80eca8637b8ac URL: http://source.winehq.org/git/wine.git/?a=commit;h=9ab004d56af62ed34c041fa3ef...
Author: Henri Verbeet hverbeet@codeweavers.com Date: Mon Mar 1 12:39:56 2010 +0100
gdi32: GetObject() should return the DIB's absolute height in dsBmih.biHeight.
---
dlls/gdi32/bitmap.c | 4 +++- dlls/gdi32/tests/bitmap.c | 16 ++++++++++++---- 2 files changed, 15 insertions(+), 5 deletions(-)
diff --git a/dlls/gdi32/bitmap.c b/dlls/gdi32/bitmap.c index 609cc9c..dfb8916 100644 --- a/dlls/gdi32/bitmap.c +++ b/dlls/gdi32/bitmap.c @@ -678,7 +678,9 @@ static INT BITMAP_GetObject( HGDIOBJ handle, INT count, LPVOID buffer ) { if (count >= sizeof(DIBSECTION)) { - memcpy( buffer, bmp->dib, sizeof(DIBSECTION) ); + DIBSECTION *dib = buffer; + *dib = *bmp->dib; + dib->dsBmih.biHeight = abs( dib->dsBmih.biHeight ); ret = sizeof(DIBSECTION); } else /* if (count >= sizeof(BITMAP)) */ diff --git a/dlls/gdi32/tests/bitmap.c b/dlls/gdi32/tests/bitmap.c index ecdf2ac..23762c0 100644 --- a/dlls/gdi32/tests/bitmap.c +++ b/dlls/gdi32/tests/bitmap.c @@ -301,7 +301,7 @@ static void test_dib_info(HBITMAP hbm, const void *bits, const BITMAPINFOHEADER
ok(bm.bmType == 0, "wrong bm.bmType %d\n", bm.bmType); ok(bm.bmWidth == bmih->biWidth, "wrong bm.bmWidth %d\n", bm.bmWidth); - ok(bm.bmHeight == bmih->biHeight, "wrong bm.bmHeight %d\n", bm.bmHeight); + ok(bm.bmHeight == abs(bmih->biHeight), "wrong bm.bmHeight %d\n", bm.bmHeight); dib_width_bytes = DIB_GetWidthBytes(bm.bmWidth, bm.bmBitsPixel); bm_width_bytes = BITMAP_GetWidthBytes(bm.bmWidth, bm.bmBitsPixel); if (bm.bmWidthBytes != dib_width_bytes) /* Win2k bug */ @@ -332,7 +332,7 @@ static void test_dib_info(HBITMAP hbm, const void *bits, const BITMAPINFOHEADER ret = GetObject(hbm, sizeof(*bma) * 2, bma); ok(ret == sizeof(*bma) || broken(ret == sizeof(*bma) * 2 /* Win9x */), "wrong size %d\n", ret); ok(bm.bmWidth == bmih->biWidth, "wrong bm.bmWidth %d\n", bm.bmWidth); - ok(bm.bmHeight == bmih->biHeight, "wrong bm.bmHeight %d\n", bm.bmHeight); + ok(bm.bmHeight == abs(bmih->biHeight), "wrong bm.bmHeight %d\n", bm.bmHeight); ok(bm.bmBits == bits, "wrong bm.bmBits %p != %p\n", bm.bmBits, bits);
ret = GetObject(hbm, sizeof(bm) / 2, &bm); @@ -364,7 +364,7 @@ static void test_dib_info(HBITMAP hbm, const void *bits, const BITMAPINFOHEADER
ok(ds.dsBmih.biSize == bmih->biSize, "%u != %u\n", ds.dsBmih.biSize, bmih->biSize); ok(ds.dsBmih.biWidth == bmih->biWidth, "%d != %d\n", ds.dsBmih.biWidth, bmih->biWidth); - ok(ds.dsBmih.biHeight == bmih->biHeight, "%d != %d\n", ds.dsBmih.biHeight, bmih->biHeight); + ok(ds.dsBmih.biHeight == abs(bmih->biHeight), "%d != %d\n", ds.dsBmih.biHeight, abs(bmih->biHeight)); ok(ds.dsBmih.biPlanes == bmih->biPlanes, "%u != %u\n", ds.dsBmih.biPlanes, bmih->biPlanes); ok(ds.dsBmih.biBitCount == bmih->biBitCount, "%u != %u\n", ds.dsBmih.biBitCount, bmih->biBitCount); ok(ds.dsBmih.biCompression == bmih->biCompression, "%u != %u\n", ds.dsBmih.biCompression, bmih->biCompression); @@ -376,7 +376,7 @@ static void test_dib_info(HBITMAP hbm, const void *bits, const BITMAPINFOHEADER ret = GetObject(hbm, sizeof(ds) - 4, &ds); ok(ret == sizeof(ds.dsBm) || broken(ret == (sizeof(ds) - 4) /* Win9x */), "wrong size %d\n", ret); ok(ds.dsBm.bmWidth == bmih->biWidth, "%d != %d\n", ds.dsBmih.biWidth, bmih->biWidth); - ok(ds.dsBm.bmHeight == bmih->biHeight, "%d != %d\n", ds.dsBmih.biHeight, bmih->biHeight); + ok(ds.dsBm.bmHeight == abs(bmih->biHeight), "%d != %d\n", ds.dsBmih.biHeight, abs(bmih->biHeight)); ok(ds.dsBm.bmBits == bits, "%p != %p\n", ds.dsBm.bmBits, bits);
ret = GetObject(hbm, 0, &ds); @@ -525,6 +525,14 @@ static void test_dibsections(void) test_dib_info(hdib, bits, &pbmi->bmiHeader); DeleteObject(hdib);
+ /* Test a top-down DIB. */ + pbmi->bmiHeader.biHeight = -100; + hdib = CreateDIBSection(hdc, pbmi, DIB_RGB_COLORS, (void**)&bits, NULL, 0); + ok(hdib != NULL, "CreateDIBSection error %d\n", GetLastError()); + test_dib_info(hdib, bits, &pbmi->bmiHeader); + DeleteObject(hdib); + + pbmi->bmiHeader.biHeight = 100; pbmi->bmiHeader.biBitCount = 8; pbmi->bmiHeader.biCompression = BI_RLE8; SetLastError(0xdeadbeef);