Commit aa34b2fb authored by Huw Davies's avatar Huw Davies Committed by Alexandre Julliard

gdi32: Construct the EGA palette from the default palette.

parent 8669fa73
...@@ -415,32 +415,6 @@ UINT WINAPI GetDIBColorTable( HDC hdc, UINT startpos, UINT entries, RGBQUAD *col ...@@ -415,32 +415,6 @@ UINT WINAPI GetDIBColorTable( HDC hdc, UINT startpos, UINT entries, RGBQUAD *col
return result; return result;
} }
/* FIXME the following two structs should be combined with __sysPalTemplate in
objects/color.c - this should happen after de-X11-ing both of these
files.
NB. RGBQUAD and PALETTEENTRY have different orderings of red, green
and blue - sigh */
static const RGBQUAD EGAColorsQuads[16] = {
/* rgbBlue, rgbGreen, rgbRed, rgbReserved */
{ 0x00, 0x00, 0x00, 0x00 },
{ 0x00, 0x00, 0x80, 0x00 },
{ 0x00, 0x80, 0x00, 0x00 },
{ 0x00, 0x80, 0x80, 0x00 },
{ 0x80, 0x00, 0x00, 0x00 },
{ 0x80, 0x00, 0x80, 0x00 },
{ 0x80, 0x80, 0x00, 0x00 },
{ 0x80, 0x80, 0x80, 0x00 },
{ 0xc0, 0xc0, 0xc0, 0x00 },
{ 0x00, 0x00, 0xff, 0x00 },
{ 0x00, 0xff, 0x00, 0x00 },
{ 0x00, 0xff, 0xff, 0x00 },
{ 0xff, 0x00, 0x00, 0x00 },
{ 0xff, 0x00, 0xff, 0x00 },
{ 0xff, 0xff, 0x00, 0x00 },
{ 0xff, 0xff, 0xff, 0x00 }
};
static const RGBQUAD DefLogPaletteQuads[20] = { /* Copy of Default Logical Palette */ static const RGBQUAD DefLogPaletteQuads[20] = { /* Copy of Default Logical Palette */
/* rgbBlue, rgbGreen, rgbRed, rgbReserved */ /* rgbBlue, rgbGreen, rgbRed, rgbReserved */
{ 0x00, 0x00, 0x00, 0x00 }, { 0x00, 0x00, 0x00, 0x00 },
...@@ -635,7 +609,12 @@ INT WINAPI GetDIBits( ...@@ -635,7 +609,12 @@ INT WINAPI GetDIBits(
break; break;
case 4: case 4:
memcpy(rgbQuads, EGAColorsQuads, sizeof(EGAColorsQuads)); /* The EGA palette is the first and last 8 colours of the default palette
with the innermost pair swapped */
memcpy(rgbQuads, DefLogPaletteQuads, 7 * sizeof(RGBQUAD));
memcpy(rgbQuads + 7, DefLogPaletteQuads + 12, 1 * sizeof(RGBQUAD));
memcpy(rgbQuads + 8, DefLogPaletteQuads + 7, 1 * sizeof(RGBQUAD));
memcpy(rgbQuads + 9, DefLogPaletteQuads + 13, 7 * sizeof(RGBQUAD));
break; break;
case 8: case 8:
......
...@@ -1534,7 +1534,7 @@ static void test_GetDIBits(void) ...@@ -1534,7 +1534,7 @@ static void test_GetDIBits(void)
BYTE buf[1024]; BYTE buf[1024];
char bi_buf[sizeof(BITMAPINFOHEADER) + sizeof(RGBQUAD) * 256]; char bi_buf[sizeof(BITMAPINFOHEADER) + sizeof(RGBQUAD) * 256];
BITMAPINFO *bi = (BITMAPINFO *)bi_buf; BITMAPINFO *bi = (BITMAPINFO *)bi_buf;
PALETTEENTRY pal_ents[32]; PALETTEENTRY pal_ents[20];
hdc = GetDC(0); hdc = GetDC(0);
...@@ -1723,6 +1723,44 @@ todo_wine ...@@ -1723,6 +1723,44 @@ todo_wine
for (i = 2; i < 256; i++) for (i = 2; i < 256; i++)
ok(((WORD*)bi->bmiColors)[i] == 0xAAAA, "Color %d is %d\n", i, ((WORD*)bi->bmiColors)[i]); ok(((WORD*)bi->bmiColors)[i] == 0xAAAA, "Color %d is %d\n", i, ((WORD*)bi->bmiColors)[i]);
/* retrieve 4-bit DIB data */
memset(bi, 0, sizeof(*bi));
bi->bmiHeader.biSize = sizeof(BITMAPINFOHEADER);
bi->bmiHeader.biWidth = bm.bmWidth;
bi->bmiHeader.biHeight = bm.bmHeight;
bi->bmiHeader.biPlanes = 1;
bi->bmiHeader.biBitCount = 4;
bi->bmiHeader.biCompression = BI_RGB;
bi->bmiHeader.biSizeImage = 0;
memset(bi->bmiColors, 0xAA, sizeof(RGBQUAD) * 256);
memset(buf, 0xAA, sizeof(buf));
SetLastError(0xdeadbeef);
lines = GetDIBits(hdc, hbmp, 0, bm.bmHeight, buf, bi, DIB_RGB_COLORS);
ok(lines == bm.bmHeight, "GetDIBits copied %d lines of %d, error %u\n",
lines, bm.bmHeight, GetLastError());
GetPaletteEntries( GetStockObject(DEFAULT_PALETTE), 0, 20, pal_ents );
for (i = 0; i < 16; i++)
{
RGBQUAD expect;
int entry = i < 8 ? i : i + 4;
if(entry == 7) entry = 12;
else if(entry == 12) entry = 7;
expect.rgbRed = pal_ents[entry].peRed;
expect.rgbGreen = pal_ents[entry].peGreen;
expect.rgbBlue = pal_ents[entry].peBlue;
expect.rgbReserved = 0;
ok(!memcmp(bi->bmiColors + i, &expect, sizeof(expect)),
"expected bmiColors[%d] %x %x %x %x - got %x %x %x %x\n", i,
expect.rgbRed, expect.rgbGreen, expect.rgbBlue, expect.rgbReserved,
bi->bmiColors[i].rgbRed, bi->bmiColors[i].rgbGreen,
bi->bmiColors[i].rgbBlue, bi->bmiColors[i].rgbReserved);
}
/* retrieve 8-bit DIB data */ /* retrieve 8-bit DIB data */
memset(bi, 0, sizeof(*bi)); memset(bi, 0, sizeof(*bi));
bi->bmiHeader.biSize = sizeof(BITMAPINFOHEADER); bi->bmiHeader.biSize = sizeof(BITMAPINFOHEADER);
...@@ -1739,7 +1777,7 @@ todo_wine ...@@ -1739,7 +1777,7 @@ todo_wine
ok(lines == bm.bmHeight, "GetDIBits copied %d lines of %d, error %u\n", ok(lines == bm.bmHeight, "GetDIBits copied %d lines of %d, error %u\n",
lines, bm.bmHeight, GetLastError()); lines, bm.bmHeight, GetLastError());
GetPaletteEntries( GetStockObject(DEFAULT_PALETTE), 0, 32, pal_ents ); GetPaletteEntries( GetStockObject(DEFAULT_PALETTE), 0, 20, pal_ents );
for (i = 0; i < 256; i++) for (i = 0; i < 256; i++)
{ {
......
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