Commit 48f083b3 authored by Huw Davies's avatar Huw Davies Committed by Alexandre Julliard

gdi32: Don't set the bitfields when the dib section is BI_RGB.

parent bb28917b
...@@ -1216,8 +1216,9 @@ HBITMAP WINAPI CreateDIBSection(HDC hdc, CONST BITMAPINFO *bmi, UINT usage, ...@@ -1216,8 +1216,9 @@ HBITMAP WINAPI CreateDIBSection(HDC hdc, CONST BITMAPINFO *bmi, UINT usage,
if (!(dib = HeapAlloc( GetProcessHeap(), 0, sizeof(*dib) ))) return 0; if (!(dib = HeapAlloc( GetProcessHeap(), 0, sizeof(*dib) ))) return 0;
TRACE("format (%d,%d), planes %d, bpp %d, size %d, %s\n", TRACE("format (%d,%d), planes %d, bpp %d, %s, size %d %s\n",
width, height, planes, bpp, sizeImage, usage == DIB_PAL_COLORS? "PAL" : "RGB"); width, height, planes, bpp, compression == BI_BITFIELDS? "BI_BITFIELDS" : "BI_RGB",
sizeImage, usage == DIB_PAL_COLORS? "PAL" : "RGB");
dib->dsBm.bmType = 0; dib->dsBm.bmType = 0;
dib->dsBm.bmWidth = width; dib->dsBm.bmWidth = width;
...@@ -1255,24 +1256,24 @@ HBITMAP WINAPI CreateDIBSection(HDC hdc, CONST BITMAPINFO *bmi, UINT usage, ...@@ -1255,24 +1256,24 @@ HBITMAP WINAPI CreateDIBSection(HDC hdc, CONST BITMAPINFO *bmi, UINT usage,
dib->dsBmih.biSizeImage = dib->dsBm.bmWidthBytes * dib->dsBm.bmHeight; dib->dsBmih.biSizeImage = dib->dsBm.bmWidthBytes * dib->dsBm.bmHeight;
/* set dsBitfields values */ /* set dsBitfields values */
if (usage == DIB_PAL_COLORS || bpp <= 8) dib->dsBitfields[0] = dib->dsBitfields[1] = dib->dsBitfields[2] = 0;
if((bpp == 15 || bpp == 16) && compression == BI_RGB)
{ {
dib->dsBitfields[0] = dib->dsBitfields[1] = dib->dsBitfields[2] = 0; /* In this case Windows changes biCompression to BI_BITFIELDS,
however for now we won't do this, as there are a lot
of places where BI_BITFIELDS is currently unsupported. */
/* dib->dsBmih.biCompression = compression = BI_BITFIELDS;*/
dib->dsBitfields[0] = 0x7c00;
dib->dsBitfields[1] = 0x03e0;
dib->dsBitfields[2] = 0x001f;
} }
else switch( bpp ) else if(compression == BI_BITFIELDS)
{ {
case 15: dib->dsBitfields[0] = *(const DWORD *)bmi->bmiColors;
case 16: dib->dsBitfields[1] = *((const DWORD *)bmi->bmiColors + 1);
dib->dsBitfields[0] = (compression == BI_BITFIELDS) ? *(const DWORD *)bmi->bmiColors : 0x7c00; dib->dsBitfields[2] = *((const DWORD *)bmi->bmiColors + 2);
dib->dsBitfields[1] = (compression == BI_BITFIELDS) ? *((const DWORD *)bmi->bmiColors + 1) : 0x03e0;
dib->dsBitfields[2] = (compression == BI_BITFIELDS) ? *((const DWORD *)bmi->bmiColors + 2) : 0x001f;
break;
case 24:
case 32:
dib->dsBitfields[0] = (compression == BI_BITFIELDS) ? *(const DWORD *)bmi->bmiColors : 0xff0000;
dib->dsBitfields[1] = (compression == BI_BITFIELDS) ? *((const DWORD *)bmi->bmiColors + 1) : 0x00ff00;
dib->dsBitfields[2] = (compression == BI_BITFIELDS) ? *((const DWORD *)bmi->bmiColors + 2) : 0x0000ff;
break;
} }
/* get storage location for DIB bits */ /* get storage location for DIB bits */
......
...@@ -204,10 +204,14 @@ static void test_simple_graphics(void) ...@@ -204,10 +204,14 @@ static void test_simple_graphics(void)
{ {
char bmibuf[sizeof(BITMAPINFO) + 256 * sizeof(RGBQUAD)]; char bmibuf[sizeof(BITMAPINFO) + 256 * sizeof(RGBQUAD)];
BITMAPINFO *bmi = (BITMAPINFO *)bmibuf; BITMAPINFO *bmi = (BITMAPINFO *)bmibuf;
DWORD *bit_fields = (DWORD*)(bmibuf + sizeof(BITMAPINFOHEADER));
HDC mem_dc; HDC mem_dc;
BYTE *bits; BYTE *bits;
HBITMAP dib, orig_bm; HBITMAP dib, orig_bm;
const char **sha1; const char **sha1;
DIBSECTION ds;
mem_dc = CreateCompatibleDC(NULL);
/* a8r8g8b8 */ /* a8r8g8b8 */
trace("8888\n"); trace("8888\n");
...@@ -221,7 +225,12 @@ static void test_simple_graphics(void) ...@@ -221,7 +225,12 @@ static void test_simple_graphics(void)
dib = CreateDIBSection(0, bmi, DIB_RGB_COLORS, (void**)&bits, NULL, 0); dib = CreateDIBSection(0, bmi, DIB_RGB_COLORS, (void**)&bits, NULL, 0);
ok(dib != NULL, "ret NULL\n"); ok(dib != NULL, "ret NULL\n");
mem_dc = CreateCompatibleDC(NULL); ok(GetObjectW( dib, sizeof(ds), &ds ), "GetObject failed\n");
ok(ds.dsBitfields[0] == 0, "got %08x\n", ds.dsBitfields[0]);
ok(ds.dsBitfields[1] == 0, "got %08x\n", ds.dsBitfields[1]);
ok(ds.dsBitfields[2] == 0, "got %08x\n", ds.dsBitfields[2]);
ok(ds.dsBmih.biCompression == BI_RGB, "got %x\n", ds.dsBmih.biCompression);
orig_bm = SelectObject(mem_dc, dib); orig_bm = SelectObject(mem_dc, dib);
sha1 = sha1_graphics_a8r8g8b8; sha1 = sha1_graphics_a8r8g8b8;
...@@ -229,6 +238,47 @@ static void test_simple_graphics(void) ...@@ -229,6 +238,47 @@ static void test_simple_graphics(void)
SelectObject(mem_dc, orig_bm); SelectObject(mem_dc, orig_bm);
DeleteObject(dib); DeleteObject(dib);
/* a8r8g8b8 - bitfields. Should be the same as the regular 32 bit case.*/
trace("8888 - bitfields\n");
bmi->bmiHeader.biBitCount = 32;
bmi->bmiHeader.biCompression = BI_BITFIELDS;
bit_fields[0] = 0xff0000;
bit_fields[1] = 0x00ff00;
bit_fields[2] = 0x0000ff;
dib = CreateDIBSection(mem_dc, bmi, DIB_RGB_COLORS, (void**)&bits, NULL, 0);
ok(dib != NULL, "ret NULL\n");
ok(GetObjectW( dib, sizeof(ds), &ds ), "GetObject failed\n");
ok(ds.dsBitfields[0] == 0xff0000, "got %08x\n", ds.dsBitfields[0]);
ok(ds.dsBitfields[1] == 0x00ff00, "got %08x\n", ds.dsBitfields[1]);
ok(ds.dsBitfields[2] == 0x0000ff, "got %08x\n", ds.dsBitfields[2]);
ok(ds.dsBmih.biCompression == BI_BITFIELDS, "got %x\n", ds.dsBmih.biCompression);
orig_bm = SelectObject(mem_dc, dib);
sha1 = sha1_graphics_a8r8g8b8;
draw_graphics(mem_dc, bmi, bits, &sha1);
SelectObject(mem_dc, orig_bm);
DeleteObject(dib);
/* r5g5b5 */
bmi->bmiHeader.biBitCount = 16;
bmi->bmiHeader.biCompression = BI_RGB;
dib = CreateDIBSection(0, bmi, DIB_RGB_COLORS, (void**)&bits, NULL, 0);
ok(dib != NULL, "ret NULL\n");
ok(GetObjectW( dib, sizeof(ds), &ds ), "GetObject failed\n");
ok(ds.dsBitfields[0] == 0x7c00, "got %08x\n", ds.dsBitfields[0]);
ok(ds.dsBitfields[1] == 0x03e0, "got %08x\n", ds.dsBitfields[1]);
ok(ds.dsBitfields[2] == 0x001f, "got %08x\n", ds.dsBitfields[2]);
todo_wine
ok(ds.dsBmih.biCompression == BI_BITFIELDS, "got %x\n", ds.dsBmih.biCompression);
DeleteObject(dib);
DeleteDC(mem_dc); DeleteDC(mem_dc);
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment