From baceb8d07e0ae08a00aaaac39c15b14f872c9d97 Mon Sep 17 00:00:00 2001 From: Alexandre Julliard Date: Mon, 21 Apr 2008 11:57:30 +0200 Subject: [PATCH] gdi32: Return bitmask for 32-bit bitmaps too in GetDIBits. --- dlls/gdi32/dib.c | 18 +++++++++++++----- dlls/gdi32/tests/bitmap.c | 6 ++++-- 2 files changed, 17 insertions(+), 7 deletions(-) diff --git a/dlls/gdi32/dib.c b/dlls/gdi32/dib.c index caf3e6ca9ab..de5a5a46c96 100644 --- a/dlls/gdi32/dib.c +++ b/dlls/gdi32/dib.c @@ -640,19 +640,17 @@ INT WINAPI GetDIBits( DIB_GetDIBImageBytes( bmp->bitmap.bmWidth, bmp->bitmap.bmHeight, bmp->bitmap.bmBitsPixel ); + info->bmiHeader.biCompression = (bmp->bitmap.bmBitsPixel > 8) ? BI_BITFIELDS : BI_RGB; switch(bmp->bitmap.bmBitsPixel) { case 15: info->bmiHeader.biBitCount = 16; - info->bmiHeader.biCompression = BI_RGB; break; - case 16: - info->bmiHeader.biBitCount = 16; - info->bmiHeader.biCompression = BI_BITFIELDS; + case 24: + info->bmiHeader.biBitCount = 32; break; default: info->bmiHeader.biBitCount = bmp->bitmap.bmBitsPixel; - info->bmiHeader.biCompression = BI_RGB; break; } info->bmiHeader.biXPelsPerMeter = 0; @@ -824,6 +822,16 @@ INT WINAPI GetDIBits( ((PDWORD)info->bmiColors)[2] = 0x001f; } break; + + case 24: + case 32: + if (info->bmiHeader.biCompression == BI_BITFIELDS) + { + ((PDWORD)info->bmiColors)[0] = 0xff0000; + ((PDWORD)info->bmiColors)[1] = 0x00ff00; + ((PDWORD)info->bmiColors)[2] = 0x0000ff; + } + break; } if (bits && lines) diff --git a/dlls/gdi32/tests/bitmap.c b/dlls/gdi32/tests/bitmap.c index 15a463b0175..f7bfdfdb27d 100644 --- a/dlls/gdi32/tests/bitmap.c +++ b/dlls/gdi32/tests/bitmap.c @@ -1623,11 +1623,13 @@ static void test_GetDIBits_BI_BITFIELDS(void) /* Call GetDIBits to fill in bmiHeader. */ ret = GetDIBits(hdc, hbm, 0, 1, NULL, dibinfo, DIB_RGB_COLORS); ok(ret == 1, "GetDIBits failed\n"); - if (dibinfo->bmiHeader.biBitCount == 16 && - dibinfo->bmiHeader.biCompression == BI_BITFIELDS) + if (dibinfo->bmiHeader.biBitCount > 8) { DWORD *bitmasks = (DWORD *)dibinfo->bmiColors; + ok( dibinfo->bmiHeader.biCompression == BI_BITFIELDS, + "compression is %u\n", dibinfo->bmiHeader.biCompression ); + ok( !bitmasks[0], "red mask is set\n" ); ok( !bitmasks[1], "green mask is set\n" ); ok( !bitmasks[2], "blue mask is set\n" );