mirror of
https://github.com/reactos/wine.git
synced 2024-11-25 04:39:45 +00:00
When creating DIBs with a color depth <= 8, always set biClrUsed field
to the number of entries in the color table.
This commit is contained in:
parent
deaae4b8d1
commit
c9e02e117f
@ -1180,6 +1180,10 @@ HBITMAP DIB_CreateDIBSection(HDC hdc, const BITMAPINFO *bmi, UINT usage,
|
|||||||
dib->dsBmih.biSize = sizeof(BITMAPINFOHEADER);
|
dib->dsBmih.biSize = sizeof(BITMAPINFOHEADER);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* set number of entries in bmi.bmiColors table */
|
||||||
|
if( bpp <= 8 )
|
||||||
|
dib->dsBmih.biClrUsed = 1 << bpp;
|
||||||
|
|
||||||
/* only use sizeImage if it's valid and we're dealing with a compressed bitmap */
|
/* only use sizeImage if it's valid and we're dealing with a compressed bitmap */
|
||||||
if (sizeImage && (compression == BI_RLE4 || compression == BI_RLE8))
|
if (sizeImage && (compression == BI_RLE4 || compression == BI_RLE8))
|
||||||
dib->dsBmih.biSizeImage = sizeImage;
|
dib->dsBmih.biSizeImage = sizeImage;
|
||||||
|
@ -194,6 +194,7 @@ static void test_dibsections(void)
|
|||||||
WORD *index;
|
WORD *index;
|
||||||
DWORD *bits32;
|
DWORD *bits32;
|
||||||
HPALETTE hpal, oldpal;
|
HPALETTE hpal, oldpal;
|
||||||
|
DIBSECTION dibsec;
|
||||||
COLORREF c0, c1;
|
COLORREF c0, c1;
|
||||||
int i;
|
int i;
|
||||||
int screen_depth;
|
int screen_depth;
|
||||||
@ -216,6 +217,9 @@ static void test_dibsections(void)
|
|||||||
|
|
||||||
hdib = CreateDIBSection(hdc, pbmi, DIB_RGB_COLORS, (void**)&bits, NULL, 0);
|
hdib = CreateDIBSection(hdc, pbmi, DIB_RGB_COLORS, (void**)&bits, NULL, 0);
|
||||||
ok(hdib != NULL, "CreateDIBSection failed\n");
|
ok(hdib != NULL, "CreateDIBSection failed\n");
|
||||||
|
ok(GetObject(hdib, sizeof(DIBSECTION), &dibsec) != 0, "GetObject failed for DIBSection\n");
|
||||||
|
ok(dibsec.dsBmih.biClrUsed == 2,
|
||||||
|
"created DIBSection: wrong biClrUsed field: %lu, should be: %u\n", dibsec.dsBmih.biClrUsed, 2);
|
||||||
|
|
||||||
/* Test if the old BITMAPCOREINFO structure is supported */
|
/* Test if the old BITMAPCOREINFO structure is supported */
|
||||||
|
|
||||||
@ -280,6 +284,19 @@ static void test_dibsections(void)
|
|||||||
SelectObject(hdcmem, oldbm);
|
SelectObject(hdcmem, oldbm);
|
||||||
DeleteObject(hdib);
|
DeleteObject(hdib);
|
||||||
|
|
||||||
|
pbmi->bmiHeader.biBitCount = 4;
|
||||||
|
for (i = 0; i < 16; i++) {
|
||||||
|
pbmi->bmiColors[i].rgbRed = i;
|
||||||
|
pbmi->bmiColors[i].rgbGreen = 16-i;
|
||||||
|
pbmi->bmiColors[i].rgbBlue = 0;
|
||||||
|
}
|
||||||
|
hdib = CreateDIBSection(hdcmem, pbmi, DIB_RGB_COLORS, (void**)&bits, NULL, 0);
|
||||||
|
ok(hdib != NULL, "CreateDIBSection failed\n");
|
||||||
|
ok(GetObject(hdib, sizeof(DIBSECTION), &dibsec) != 0, "GetObject failed for DIB Section\n");
|
||||||
|
ok(dibsec.dsBmih.biClrUsed == 16,
|
||||||
|
"created DIBSection: wrong biClrUsed field: %lu, should be: %u\n", dibsec.dsBmih.biClrUsed, 16);
|
||||||
|
DeleteObject(hdib);
|
||||||
|
|
||||||
pbmi->bmiHeader.biBitCount = 8;
|
pbmi->bmiHeader.biBitCount = 8;
|
||||||
|
|
||||||
for (i = 0; i < 128; i++) {
|
for (i = 0; i < 128; i++) {
|
||||||
@ -292,6 +309,10 @@ static void test_dibsections(void)
|
|||||||
}
|
}
|
||||||
hdib = CreateDIBSection(hdcmem, pbmi, DIB_RGB_COLORS, (void**)&bits, NULL, 0);
|
hdib = CreateDIBSection(hdcmem, pbmi, DIB_RGB_COLORS, (void**)&bits, NULL, 0);
|
||||||
ok(hdib != NULL, "CreateDIBSection failed\n");
|
ok(hdib != NULL, "CreateDIBSection failed\n");
|
||||||
|
ok(GetObject(hdib, sizeof(DIBSECTION), &dibsec) != 0, "GetObject failed for DIB Section\n");
|
||||||
|
ok(dibsec.dsBmih.biClrUsed == 256,
|
||||||
|
"created DIBSection: wrong biClrUsed field: %lu, should be: %u\n", dibsec.dsBmih.biClrUsed, 256);
|
||||||
|
|
||||||
oldbm = SelectObject(hdcmem, hdib);
|
oldbm = SelectObject(hdcmem, hdib);
|
||||||
|
|
||||||
for (i = 0; i < 256; i++) {
|
for (i = 0; i < 256; i++) {
|
||||||
@ -322,6 +343,9 @@ static void test_dibsections(void)
|
|||||||
oldpal = SelectPalette(hdc, hpal, TRUE);
|
oldpal = SelectPalette(hdc, hpal, TRUE);
|
||||||
hdib = CreateDIBSection(hdc, pbmi, DIB_PAL_COLORS, (void**)&bits, NULL, 0);
|
hdib = CreateDIBSection(hdc, pbmi, DIB_PAL_COLORS, (void**)&bits, NULL, 0);
|
||||||
ok(hdib != NULL, "CreateDIBSection failed\n");
|
ok(hdib != NULL, "CreateDIBSection failed\n");
|
||||||
|
ok(GetObject(hdib, sizeof(DIBSECTION), &dibsec) != 0, "GetObject failed for DIB Section\n");
|
||||||
|
ok(dibsec.dsBmih.biClrUsed == 2,
|
||||||
|
"created DIBSection: wrong biClrUsed field: %lu, should be: %u\n", dibsec.dsBmih.biClrUsed, 2);
|
||||||
|
|
||||||
/* The colour table has already been grabbed from the dc, so we select back the
|
/* The colour table has already been grabbed from the dc, so we select back the
|
||||||
old palette */
|
old palette */
|
||||||
@ -409,6 +433,9 @@ static void test_dibsections(void)
|
|||||||
oldpal = SelectPalette(hdc, hpal, TRUE);
|
oldpal = SelectPalette(hdc, hpal, TRUE);
|
||||||
hdib = CreateDIBSection(hdc, pbmi, DIB_PAL_COLORS, (void**)&bits, NULL, 0);
|
hdib = CreateDIBSection(hdc, pbmi, DIB_PAL_COLORS, (void**)&bits, NULL, 0);
|
||||||
ok(hdib != NULL, "CreateDIBSection failed\n");
|
ok(hdib != NULL, "CreateDIBSection failed\n");
|
||||||
|
ok(GetObject(hdib, sizeof(DIBSECTION), &dibsec) != 0, "GetObject failed for DIB Section\n");
|
||||||
|
ok(dibsec.dsBmih.biClrUsed == 256,
|
||||||
|
"created DIBSection: wrong biClrUsed field: %lu, should be: %u\n", dibsec.dsBmih.biClrUsed, 256);
|
||||||
|
|
||||||
SelectPalette(hdc, oldpal, TRUE);
|
SelectPalette(hdc, oldpal, TRUE);
|
||||||
oldbm = SelectObject(hdcmem, hdib);
|
oldbm = SelectObject(hdcmem, hdib);
|
||||||
|
Loading…
Reference in New Issue
Block a user