diff --git a/rostests/winetests/gdi32/bitmap.c b/rostests/winetests/gdi32/bitmap.c index b0b85621811..d4a6e3a6376 100755 --- a/rostests/winetests/gdi32/bitmap.c +++ b/rostests/winetests/gdi32/bitmap.c @@ -33,10 +33,9 @@ #include "wine/test.h" static BOOL (WINAPI *pGdiAlphaBlend)(HDC,int,int,int,int,HDC,int,int,int,int,BLENDFUNCTION); +static BOOL (WINAPI *pGdiGradientFill)(HDC,TRIVERTEX*,ULONG,void*,ULONG,ULONG); static DWORD (WINAPI *pSetLayout)(HDC hdc, DWORD layout); -#define expect_eq(expr, value, type, format) { type ret = (expr); ok((value) == ret, #expr " expected " format " got " format "\n", value, ret); } - static inline int get_bitmap_stride( int width, int bpp ) { return ((width * bpp + 15) >> 3) & ~1; @@ -340,21 +339,15 @@ static void test_dib_info(HBITMAP hbm, const void *bits, const BITMAPINFOHEADER ok(ret == 0, "%d != 0\n", ret); } -#define test_color_todo(got, exp, txt, todo) \ - if (!todo && got != exp && screen_depth < 24) { \ - todo_wine ok(0, #txt " failed at %d-bit screen depth: got 0x%06x expected 0x%06x - skipping DIB tests\n", \ - screen_depth, (UINT)got, (UINT)exp); \ - return; \ - } else if (todo) todo_wine { ok(got == exp, #txt " failed: got 0x%06x expected 0x%06x\n", (UINT)got, (UINT)exp); } \ - else ok(got == exp, #txt " failed: got 0x%06x expected 0x%06x\n", (UINT)got, (UINT)exp) \ - -#define test_color(hdc, color, exp, todo_setp, todo_getp) \ +#define test_color(hdc, color, exp) \ { \ COLORREF c; \ c = SetPixel(hdc, 0, 0, color); \ - test_color_todo(c, exp, SetPixel, todo_setp); \ + ok(c == exp, "SetPixel failed: got 0x%06x expected 0x%06x\n", c, (UINT)exp); \ c = GetPixel(hdc, 0, 0); \ - test_color_todo(c, exp, GetPixel, todo_getp); \ + ok(c == exp, "GetPixel failed: got 0x%06x expected 0x%06x\n", c, (UINT)exp); \ + c = GetNearestColor(hdc, color); \ + ok(c == exp, "GetNearestColor failed: got 0x%06x expected 0x%06x\n", c, (UINT)exp); \ } static void test_dib_bits_access( HBITMAP hdib, void *bits ) @@ -424,6 +417,8 @@ static void test_dibsections(void) char bcibuf[sizeof(BITMAPCOREINFO) + 256 * sizeof(RGBTRIPLE)]; BITMAPINFO *pbmi = (BITMAPINFO *)bmibuf; BITMAPCOREINFO *pbci = (BITMAPCOREINFO *)bcibuf; + RGBQUAD *colors = pbmi->bmiColors; + RGBTRIPLE *ccolors = pbci->bmciColors; HBITMAP hcoredib; char coreBits[256]; BYTE *bits; @@ -431,17 +426,16 @@ static void test_dibsections(void) int ret; char logpalbuf[sizeof(LOGPALETTE) + 256 * sizeof(PALETTEENTRY)]; LOGPALETTE *plogpal = (LOGPALETTE*)logpalbuf; + PALETTEENTRY *palent = plogpal->palPalEntry; WORD *index; DWORD *bits32; HPALETTE hpal, oldpal; DIBSECTION dibsec; COLORREF c0, c1; int i; - int screen_depth; MEMORY_BASIC_INFORMATION info; hdc = GetDC(0); - screen_depth = GetDeviceCaps(hdc, BITSPIXEL) * GetDeviceCaps(hdc, PLANES); memset(pbmi, 0, sizeof(bmibuf)); pbmi->bmiHeader.biSize = sizeof(pbmi->bmiHeader); @@ -525,12 +519,12 @@ static void test_dibsections(void) pbmi->bmiHeader.biBitCount = 1; pbmi->bmiHeader.biPlanes = 1; pbmi->bmiHeader.biCompression = BI_RGB; - pbmi->bmiColors[0].rgbRed = 0xff; - pbmi->bmiColors[0].rgbGreen = 0; - pbmi->bmiColors[0].rgbBlue = 0; - pbmi->bmiColors[1].rgbRed = 0; - pbmi->bmiColors[1].rgbGreen = 0; - pbmi->bmiColors[1].rgbBlue = 0xff; + colors[0].rgbRed = 0xff; + colors[0].rgbGreen = 0; + colors[0].rgbBlue = 0; + colors[1].rgbRed = 0; + colors[1].rgbGreen = 0; + colors[1].rgbBlue = 0xff; hdib = CreateDIBSection(hdc, pbmi, DIB_RGB_COLORS, (void**)&bits, NULL, 0); ok(hdib != NULL, "CreateDIBSection failed\n"); @@ -551,20 +545,20 @@ static void test_dibsections(void) ret = GetDIBits(hdc, hdib, 0, 16, &coreBits, (BITMAPINFO*) pbci, DIB_RGB_COLORS); ok(ret, "GetDIBits doesn't work with a BITMAPCOREHEADER\n"); - ok((pbci->bmciColors[0].rgbtRed == 0xff) && (pbci->bmciColors[0].rgbtGreen == 0) && - (pbci->bmciColors[0].rgbtBlue == 0) && (pbci->bmciColors[1].rgbtRed == 0) && - (pbci->bmciColors[1].rgbtGreen == 0) && (pbci->bmciColors[1].rgbtBlue == 0xff), + ok((ccolors[0].rgbtRed == 0xff) && (ccolors[0].rgbtGreen == 0) && + (ccolors[0].rgbtBlue == 0) && (ccolors[1].rgbtRed == 0) && + (ccolors[1].rgbtGreen == 0) && (ccolors[1].rgbtBlue == 0xff), "The color table has not been translated to the old BITMAPCOREINFO format\n"); hcoredib = CreateDIBSection(hdc, (BITMAPINFO*) pbci, DIB_RGB_COLORS, (void**)&bits, NULL, 0); ok(hcoredib != NULL, "CreateDIBSection failed with a BITMAPCOREINFO\n"); - ZeroMemory(pbci->bmciColors, 256 * sizeof(RGBTRIPLE)); + ZeroMemory(ccolors, 256 * sizeof(RGBTRIPLE)); ret = GetDIBits(hdc, hcoredib, 0, 16, &coreBits, (BITMAPINFO*) pbci, DIB_RGB_COLORS); ok(ret, "GetDIBits doesn't work with a BITMAPCOREHEADER\n"); - ok((pbci->bmciColors[0].rgbtRed == 0xff) && (pbci->bmciColors[0].rgbtGreen == 0) && - (pbci->bmciColors[0].rgbtBlue == 0) && (pbci->bmciColors[1].rgbtRed == 0) && - (pbci->bmciColors[1].rgbtGreen == 0) && (pbci->bmciColors[1].rgbtBlue == 0xff), + ok((ccolors[0].rgbtRed == 0xff) && (ccolors[0].rgbtGreen == 0) && + (ccolors[0].rgbtBlue == 0) && (ccolors[1].rgbtRed == 0) && + (ccolors[1].rgbtGreen == 0) && (ccolors[1].rgbtBlue == 0xff), "The color table has not been translated to the old BITMAPCOREINFO format\n"); DeleteObject(hcoredib); @@ -579,32 +573,30 @@ static void test_dibsections(void) rgb[0].rgbRed, rgb[0].rgbGreen, rgb[0].rgbBlue, rgb[0].rgbReserved, rgb[1].rgbRed, rgb[1].rgbGreen, rgb[1].rgbBlue, rgb[1].rgbReserved); - c0 = RGB(pbmi->bmiColors[0].rgbRed, pbmi->bmiColors[0].rgbGreen, pbmi->bmiColors[0].rgbBlue); - c1 = RGB(pbmi->bmiColors[1].rgbRed, pbmi->bmiColors[1].rgbGreen, pbmi->bmiColors[1].rgbBlue); + c0 = RGB(colors[0].rgbRed, colors[0].rgbGreen, colors[0].rgbBlue); + c1 = RGB(colors[1].rgbRed, colors[1].rgbGreen, colors[1].rgbBlue); - test_color(hdcmem, DIBINDEX(0), c0, 0, 1); - test_color(hdcmem, DIBINDEX(1), c1, 0, 1); - test_color(hdcmem, DIBINDEX(2), c0, 1, 1); - test_color(hdcmem, PALETTEINDEX(0), c0, 1, 1); - test_color(hdcmem, PALETTEINDEX(1), c0, 1, 1); - test_color(hdcmem, PALETTEINDEX(2), c0, 1, 1); - test_color(hdcmem, PALETTERGB(pbmi->bmiColors[0].rgbRed, pbmi->bmiColors[0].rgbGreen, - pbmi->bmiColors[0].rgbBlue), c0, 1, 1); - test_color(hdcmem, PALETTERGB(pbmi->bmiColors[1].rgbRed, pbmi->bmiColors[1].rgbGreen, - pbmi->bmiColors[1].rgbBlue), c1, 1, 1); - test_color(hdcmem, PALETTERGB(0, 0, 0), c0, 1, 1); - test_color(hdcmem, PALETTERGB(0xff, 0xff, 0xff), c0, 1, 1); - test_color(hdcmem, PALETTERGB(0, 0, 0xfe), c1, 1, 1); + test_color(hdcmem, DIBINDEX(0), c0); + test_color(hdcmem, DIBINDEX(1), c1); + test_color(hdcmem, DIBINDEX(2), c0); + test_color(hdcmem, PALETTEINDEX(0), c0); + test_color(hdcmem, PALETTEINDEX(1), c0); + test_color(hdcmem, PALETTEINDEX(2), c0); + test_color(hdcmem, PALETTERGB(colors[0].rgbRed, colors[0].rgbGreen, colors[0].rgbBlue), c0); + test_color(hdcmem, PALETTERGB(colors[1].rgbRed, colors[1].rgbGreen, colors[1].rgbBlue), c1); + test_color(hdcmem, PALETTERGB(0, 0, 0), c0); + test_color(hdcmem, PALETTERGB(0xff, 0xff, 0xff), c0); + test_color(hdcmem, PALETTERGB(0, 0, 0xfe), c1); SelectObject(hdcmem, oldbm); DeleteObject(hdib); - pbmi->bmiColors[0].rgbRed = 0xff; - pbmi->bmiColors[0].rgbGreen = 0xff; - pbmi->bmiColors[0].rgbBlue = 0xff; - pbmi->bmiColors[1].rgbRed = 0; - pbmi->bmiColors[1].rgbGreen = 0; - pbmi->bmiColors[1].rgbBlue = 0; + colors[0].rgbRed = 0xff; + colors[0].rgbGreen = 0xff; + colors[0].rgbBlue = 0xff; + colors[1].rgbRed = 0; + colors[1].rgbGreen = 0; + colors[1].rgbBlue = 0; hdib = CreateDIBSection(hdc, pbmi, DIB_RGB_COLORS, (void**)&bits, NULL, 0); ok(hdib != NULL, "CreateDIBSection failed\n"); @@ -615,7 +607,7 @@ static void test_dibsections(void) ret = GetDIBColorTable(hdcmem, 0, 2, rgb); ok(ret == 2, "GetDIBColorTable returned %d\n", ret); - ok(!memcmp(rgb, pbmi->bmiColors, 2 * sizeof(RGBQUAD)), + ok(!memcmp(rgb, colors, 2 * sizeof(RGBQUAD)), "GetDIBColorTable returns table 0: r%02x g%02x b%02x res%02x 1: r%02x g%02x b%02x res%02x\n", rgb[0].rgbRed, rgb[0].rgbGreen, rgb[0].rgbBlue, rgb[0].rgbReserved, rgb[1].rgbRed, rgb[1].rgbGreen, rgb[1].rgbBlue, rgb[1].rgbReserved); @@ -626,9 +618,9 @@ static void test_dibsections(void) 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; + colors[i].rgbRed = i; + colors[i].rgbGreen = 16-i; + colors[i].rgbBlue = 0; } hdib = CreateDIBSection(hdcmem, pbmi, DIB_RGB_COLORS, (void**)&bits, NULL, 0); ok(hdib != NULL, "CreateDIBSection failed\n"); @@ -641,12 +633,12 @@ static void test_dibsections(void) pbmi->bmiHeader.biBitCount = 8; for (i = 0; i < 128; i++) { - pbmi->bmiColors[i].rgbRed = 255 - i * 2; - pbmi->bmiColors[i].rgbGreen = i * 2; - pbmi->bmiColors[i].rgbBlue = 0; - pbmi->bmiColors[255 - i].rgbRed = 0; - pbmi->bmiColors[255 - i].rgbGreen = i * 2; - pbmi->bmiColors[255 - i].rgbBlue = 255 - i * 2; + colors[i].rgbRed = 255 - i * 2; + colors[i].rgbGreen = i * 2; + colors[i].rgbBlue = 0; + colors[255 - i].rgbRed = 0; + colors[255 - i].rgbGreen = i * 2; + colors[255 - i].rgbBlue = 255 - i * 2; } hdib = CreateDIBSection(hdcmem, pbmi, DIB_RGB_COLORS, (void**)&bits, NULL, 0); ok(hdib != NULL, "CreateDIBSection failed\n"); @@ -657,10 +649,9 @@ static void test_dibsections(void) oldbm = SelectObject(hdcmem, hdib); for (i = 0; i < 256; i++) { - test_color(hdcmem, DIBINDEX(i), - RGB(pbmi->bmiColors[i].rgbRed, pbmi->bmiColors[i].rgbGreen, pbmi->bmiColors[i].rgbBlue), 0, 0); - test_color(hdcmem, PALETTERGB(pbmi->bmiColors[i].rgbRed, pbmi->bmiColors[i].rgbGreen, pbmi->bmiColors[i].rgbBlue), - RGB(pbmi->bmiColors[i].rgbRed, pbmi->bmiColors[i].rgbGreen, pbmi->bmiColors[i].rgbBlue), 0, 0); + test_color(hdcmem, DIBINDEX(i), RGB(colors[i].rgbRed, colors[i].rgbGreen, colors[i].rgbBlue)); + test_color(hdcmem, PALETTERGB(colors[i].rgbRed, colors[i].rgbGreen, colors[i].rgbBlue), + RGB(colors[i].rgbRed, colors[i].rgbGreen, colors[i].rgbBlue)); } SelectObject(hdcmem, oldbm); @@ -673,9 +664,9 @@ static void test_dibsections(void) memset(plogpal, 0, sizeof(logpalbuf)); plogpal->palVersion = 0x300; plogpal->palNumEntries = 2; - plogpal->palPalEntry[0].peRed = 0xff; - plogpal->palPalEntry[0].peBlue = 0xff; - plogpal->palPalEntry[1].peGreen = 0xff; + palent[0].peRed = 0xff; + palent[0].peBlue = 0xff; + palent[1].peGreen = 0xff; index = (WORD*)pbmi->bmiColors; *index++ = 0; @@ -703,25 +694,23 @@ static void test_dibsections(void) rgb[0].rgbRed, rgb[0].rgbGreen, rgb[0].rgbBlue, rgb[0].rgbReserved, rgb[1].rgbRed, rgb[1].rgbGreen, rgb[1].rgbBlue, rgb[1].rgbReserved); - c0 = RGB(plogpal->palPalEntry[0].peRed, plogpal->palPalEntry[0].peGreen, plogpal->palPalEntry[0].peBlue); - c1 = RGB(plogpal->palPalEntry[1].peRed, plogpal->palPalEntry[1].peGreen, plogpal->palPalEntry[1].peBlue); + c0 = RGB(palent[0].peRed, palent[0].peGreen, palent[0].peBlue); + c1 = RGB(palent[1].peRed, palent[1].peGreen, palent[1].peBlue); - test_color(hdcmem, DIBINDEX(0), c0, 0, 1); - test_color(hdcmem, DIBINDEX(1), c1, 0, 1); - test_color(hdcmem, DIBINDEX(2), c0, 1, 1); - test_color(hdcmem, PALETTEINDEX(0), c0, 0, 1); - test_color(hdcmem, PALETTEINDEX(1), c1, 0, 1); - test_color(hdcmem, PALETTEINDEX(2), c0, 1, 1); - test_color(hdcmem, PALETTERGB(plogpal->palPalEntry[0].peRed, plogpal->palPalEntry[0].peGreen, - plogpal->palPalEntry[0].peBlue), c0, 1, 1); - test_color(hdcmem, PALETTERGB(plogpal->palPalEntry[1].peRed, plogpal->palPalEntry[1].peGreen, - plogpal->palPalEntry[1].peBlue), c1, 1, 1); - test_color(hdcmem, PALETTERGB(0, 0, 0), c1, 1, 1); - test_color(hdcmem, PALETTERGB(0xff, 0xff, 0xff), c0, 1, 1); - test_color(hdcmem, PALETTERGB(0, 0, 0xfe), c0, 1, 1); - test_color(hdcmem, PALETTERGB(0, 1, 0), c1, 1, 1); - test_color(hdcmem, PALETTERGB(0x3f, 0, 0x3f), c1, 1, 1); - test_color(hdcmem, PALETTERGB(0x40, 0, 0x40), c0, 1, 1); + test_color(hdcmem, DIBINDEX(0), c0); + test_color(hdcmem, DIBINDEX(1), c1); + test_color(hdcmem, DIBINDEX(2), c0); + test_color(hdcmem, PALETTEINDEX(0), c0); + test_color(hdcmem, PALETTEINDEX(1), c1); + test_color(hdcmem, PALETTEINDEX(2), c0); + test_color(hdcmem, PALETTERGB(palent[0].peRed, palent[0].peGreen, palent[0].peBlue), c0); + test_color(hdcmem, PALETTERGB(palent[1].peRed, palent[1].peGreen, palent[1].peBlue), c1); + test_color(hdcmem, PALETTERGB(0, 0, 0), c1); + test_color(hdcmem, PALETTERGB(0xff, 0xff, 0xff), c0); + test_color(hdcmem, PALETTERGB(0, 0, 0xfe), c0); + test_color(hdcmem, PALETTERGB(0, 1, 0), c1); + test_color(hdcmem, PALETTERGB(0x3f, 0, 0x3f), c1); + test_color(hdcmem, PALETTERGB(0x40, 0, 0x40), c0); /* Bottom and 2nd row from top green, everything else magenta */ bits[0] = bits[1] = 0xff; @@ -758,12 +747,12 @@ static void test_dibsections(void) plogpal->palNumEntries = 256; for (i = 0; i < 128; i++) { - plogpal->palPalEntry[i].peRed = 255 - i * 2; - plogpal->palPalEntry[i].peBlue = i * 2; - plogpal->palPalEntry[i].peGreen = 0; - plogpal->palPalEntry[255 - i].peRed = 0; - plogpal->palPalEntry[255 - i].peGreen = i * 2; - plogpal->palPalEntry[255 - i].peBlue = 255 - i * 2; + palent[i].peRed = 255 - i * 2; + palent[i].peBlue = i * 2; + palent[i].peGreen = 0; + palent[255 - i].peRed = 0; + palent[255 - i].peGreen = i * 2; + palent[255 - i].peBlue = 255 - i * 2; } index = (WORD*)pbmi->bmiColors; @@ -788,20 +777,18 @@ static void test_dibsections(void) ret = GetDIBColorTable(hdcmem, 0, 256, rgb); ok(ret == 256, "GetDIBColorTable returned %d\n", ret); for (i = 0; i < 256; i++) { - ok(rgb[i].rgbRed == plogpal->palPalEntry[i].peRed && - rgb[i].rgbBlue == plogpal->palPalEntry[i].peBlue && - rgb[i].rgbGreen == plogpal->palPalEntry[i].peGreen, + ok(rgb[i].rgbRed == palent[i].peRed && + rgb[i].rgbBlue == palent[i].peBlue && + rgb[i].rgbGreen == palent[i].peGreen, "GetDIBColorTable returns table %d: r%02x g%02x b%02x res%02x\n", i, rgb[i].rgbRed, rgb[i].rgbGreen, rgb[i].rgbBlue, rgb[i].rgbReserved); } for (i = 0; i < 256; i++) { - test_color(hdcmem, DIBINDEX(i), - RGB(plogpal->palPalEntry[i].peRed, plogpal->palPalEntry[i].peGreen, plogpal->palPalEntry[i].peBlue), 0, 0); - test_color(hdcmem, PALETTEINDEX(i), - RGB(plogpal->palPalEntry[i].peRed, plogpal->palPalEntry[i].peGreen, plogpal->palPalEntry[i].peBlue), 0, 0); - test_color(hdcmem, PALETTERGB(plogpal->palPalEntry[i].peRed, plogpal->palPalEntry[i].peGreen, plogpal->palPalEntry[i].peBlue), - RGB(plogpal->palPalEntry[i].peRed, plogpal->palPalEntry[i].peGreen, plogpal->palPalEntry[i].peBlue), 0, 0); + test_color(hdcmem, DIBINDEX(i), RGB(palent[i].peRed, palent[i].peGreen, palent[i].peBlue)); + test_color(hdcmem, PALETTEINDEX(i), RGB(palent[i].peRed, palent[i].peGreen, palent[i].peBlue)); + test_color(hdcmem, PALETTERGB(palent[i].peRed, palent[i].peGreen, palent[i].peBlue), + RGB(palent[i].peRed, palent[i].peGreen, palent[i].peBlue)); } SelectPalette(hdcmem, oldpal, TRUE); @@ -809,6 +796,79 @@ static void test_dibsections(void) DeleteObject(hdib); DeleteObject(hpal); + plogpal->palNumEntries = 37; + hpal = CreatePalette(plogpal); + ok(hpal != NULL, "CreatePalette failed\n"); + oldpal = SelectPalette(hdc, hpal, TRUE); + pbmi->bmiHeader.biClrUsed = 142; + hdib = CreateDIBSection(hdc, pbmi, DIB_PAL_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 == 256, "created DIBSection: wrong biClrUsed field: %u, should be: %u\n", dibsec.dsBmih.biClrUsed, 256); + + test_dib_info(hdib, bits, &pbmi->bmiHeader); + + SelectPalette(hdc, oldpal, TRUE); + oldbm = SelectObject(hdcmem, hdib); + + memset( rgb, 0xcc, sizeof(rgb) ); + ret = GetDIBColorTable(hdcmem, 0, 256, rgb); + ok(ret == 256, "GetDIBColorTable returned %d\n", ret); + for (i = 0; i < 256; i++) + { + if (i < pbmi->bmiHeader.biClrUsed) + { + ok(rgb[i].rgbRed == palent[i % 37].peRed && + rgb[i].rgbBlue == palent[i % 37].peBlue && + rgb[i].rgbGreen == palent[i % 37].peGreen, + "GetDIBColorTable returns table %d: r %02x g %02x b %02x res%02x\n", + i, rgb[i].rgbRed, rgb[i].rgbGreen, rgb[i].rgbBlue, rgb[i].rgbReserved); + test_color(hdcmem, DIBINDEX(i), + RGB(palent[i % 37].peRed, palent[i % 37].peGreen, palent[i % 37].peBlue)); + } + else + { + ok(rgb[i].rgbRed == 0 && rgb[i].rgbBlue == 0 && rgb[i].rgbGreen == 0, + "GetDIBColorTable returns table %d: r %02x g %02x b %02x res%02x\n", + i, rgb[i].rgbRed, rgb[i].rgbGreen, rgb[i].rgbBlue, rgb[i].rgbReserved); + test_color(hdcmem, DIBINDEX(i), 0 ); + } + } + pbmi->bmiHeader.biClrUsed = 173; + memset( pbmi->bmiColors, 0xcc, 256 * sizeof(RGBQUAD) ); + GetDIBits( hdc, hdib, 0, 1, bits, pbmi, DIB_RGB_COLORS ); + ok( pbmi->bmiHeader.biClrUsed == 0, "wrong colors %u\n", pbmi->bmiHeader.biClrUsed ); + for (i = 0; i < 256; i++) + { + if (i < 142) + ok(colors[i].rgbRed == palent[i % 37].peRed && + colors[i].rgbBlue == palent[i % 37].peBlue && + colors[i].rgbGreen == palent[i % 37].peGreen, + "GetDIBits returns table %d: r %02x g %02x b %02x res%02x\n", + i, colors[i].rgbRed, colors[i].rgbGreen, colors[i].rgbBlue, colors[i].rgbReserved); + else + ok(colors[i].rgbRed == 0 && colors[i].rgbBlue == 0 && colors[i].rgbGreen == 0, + "GetDIBits returns table %d: r %02x g %02x b %02x res%02x\n", + i, colors[i].rgbRed, colors[i].rgbGreen, colors[i].rgbBlue, colors[i].rgbReserved); + } + + SelectObject(hdcmem, oldbm); + DeleteObject(hdib); + DeleteObject(hpal); + + /* ClrUsed ignored on > 8bpp */ + pbmi->bmiHeader.biBitCount = 16; + pbmi->bmiHeader.biClrUsed = 37; + hdib = CreateDIBSection(hdc, pbmi, DIB_PAL_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 == 0, "created DIBSection: wrong biClrUsed field: %u\n", dibsec.dsBmih.biClrUsed); + oldbm = SelectObject(hdcmem, hdib); + ret = GetDIBColorTable(hdcmem, 0, 256, rgb); + ok(ret == 0, "GetDIBColorTable returned %d\n", ret); + SelectObject(hdcmem, oldbm); + DeleteObject(hdib); + DeleteDC(hdcmem); DeleteDC(hdcmem2); ReleaseDC(0, hdc); @@ -819,7 +879,7 @@ static void test_dib_formats(void) BITMAPINFO *bi; char data[256]; void *bits; - //int planes, bpp, compr; + //int planes, bpp, compr, format; HBITMAP hdib, hbmp; HDC hdc, memdc; UINT ret; @@ -839,158 +899,133 @@ static void test_dib_formats(void) { for (compr = 0; compr < 8; compr++) { - switch (bpp) + for (format = DIB_RGB_COLORS; format <= DIB_PAL_COLORS; format++) { - case 1: - case 4: - case 8: - case 24: expect_ok = (compr == BI_RGB); break; - case 16: - case 32: expect_ok = (compr == BI_RGB || compr == BI_BITFIELDS); break; - default: expect_ok = FALSE; break; - } - todo = (compr == BI_BITFIELDS); /* wine doesn't like strange bitfields */ + switch (bpp) + { + case 1: + case 4: + case 8: + case 24: expect_ok = (compr == BI_RGB); break; + case 16: + case 32: expect_ok = (compr == BI_RGB || compr == BI_BITFIELDS); break; + default: expect_ok = FALSE; break; + } - memset( bi, 0, sizeof(bi->bmiHeader) ); - bi->bmiHeader.biSize = sizeof(BITMAPINFOHEADER); - bi->bmiHeader.biWidth = 2; - bi->bmiHeader.biHeight = 2; - bi->bmiHeader.biPlanes = planes; - bi->bmiHeader.biBitCount = bpp; - bi->bmiHeader.biCompression = compr; - bi->bmiHeader.biSizeImage = 0; - memset( bi->bmiColors, 0xaa, sizeof(RGBQUAD) * 256 ); - ret = GetDIBits(hdc, hbmp, 0, 0, data, bi, DIB_RGB_COLORS); - if (expect_ok || (!bpp && compr != BI_JPEG && compr != BI_PNG) || - (bpp == 4 && compr == BI_RLE4) || (bpp == 8 && compr == BI_RLE8)) - ok( ret, "GetDIBits failed for %u/%u/%u\n", bpp, planes, compr ); - else - ok( !ret || broken(!bpp && (compr == BI_JPEG || compr == BI_PNG)), /* nt4 */ - "GetDIBits succeeded for %u/%u/%u\n", bpp, planes, compr ); - - /* all functions check planes except GetDIBits with 0 lines */ - if (!planes) expect_ok = FALSE; - memset( bi, 0, sizeof(bi->bmiHeader) ); - bi->bmiHeader.biSize = sizeof(BITMAPINFOHEADER); - bi->bmiHeader.biWidth = 2; - bi->bmiHeader.biHeight = 2; - bi->bmiHeader.biPlanes = planes; - bi->bmiHeader.biBitCount = bpp; - bi->bmiHeader.biCompression = compr; - bi->bmiHeader.biSizeImage = 0; - memset( bi->bmiColors, 0xaa, sizeof(RGBQUAD) * 256 ); - - hdib = CreateDIBSection(hdc, bi, DIB_RGB_COLORS, &bits, NULL, 0); - if (expect_ok && (planes == 1 || planes * bpp <= 16)) - ok( hdib != NULL, "CreateDIBSection failed for %u/%u/%u\n", bpp, planes, compr ); - else - ok( hdib == NULL, "CreateDIBSection succeeded for %u/%u/%u\n", bpp, planes, compr ); - if (hdib) DeleteObject( hdib ); - - hdib = CreateDIBitmap( hdc, &bi->bmiHeader, 0, data, bi, DIB_RGB_COLORS ); - /* no sanity checks in CreateDIBitmap except compression */ - if (compr == BI_JPEG || compr == BI_PNG) - ok( hdib == NULL || broken(hdib != NULL), /* nt4 */ - "CreateDIBitmap succeeded for %u/%u/%u\n", bpp, planes, compr ); - else - ok( hdib != NULL, "CreateDIBitmap failed for %u/%u/%u\n", bpp, planes, compr ); - if (hdib) DeleteObject( hdib ); - - /* RLE needs a size */ - bi->bmiHeader.biSizeImage = 0; - ret = SetDIBits(hdc, hbmp, 0, 1, data, bi, DIB_RGB_COLORS); - if (expect_ok) - { - if (todo) - todo_wine ok( ret, "SetDIBits failed for %u/%u/%u\n", bpp, planes, compr ); + memset( bi, 0, sizeof(bi->bmiHeader) ); + bi->bmiHeader.biSize = sizeof(BITMAPINFOHEADER); + bi->bmiHeader.biWidth = 2; + bi->bmiHeader.biHeight = 2; + bi->bmiHeader.biPlanes = planes; + bi->bmiHeader.biBitCount = bpp; + bi->bmiHeader.biCompression = compr; + bi->bmiHeader.biSizeImage = 0; + memset( bi->bmiColors, 0xaa, sizeof(RGBQUAD) * 256 ); + ret = GetDIBits(hdc, hbmp, 0, 0, data, bi, format); + if (expect_ok || (!bpp && compr != BI_JPEG && compr != BI_PNG) || + (bpp == 4 && compr == BI_RLE4) || (bpp == 8 && compr == BI_RLE8)) + ok( ret, "GetDIBits failed for %u/%u/%u/%u\n", bpp, planes, compr, format ); else - ok( ret, "SetDIBits failed for %u/%u/%u\n", bpp, planes, compr ); - } - else - ok( !ret || - broken((bpp == 4 && compr == BI_RLE4) || (bpp == 8 && compr == BI_RLE8)), /* nt4 */ - "SetDIBits succeeded for %u/%u/%u\n", bpp, planes, compr ); - ret = SetDIBitsToDevice( memdc, 0, 0, 1, 1, 0, 0, 0, 1, data, bi, DIB_RGB_COLORS ); - if (expect_ok) - { - if (todo) - todo_wine ok( ret, "SetDIBitsToDevice failed for %u/%u/%u\n", bpp, planes, compr ); - else - ok( ret, "SetDIBitsToDevice failed for %u/%u/%u\n", bpp, planes, compr ); - } - else - ok( !ret || - broken((bpp == 4 && compr == BI_RLE4) || (bpp == 8 && compr == BI_RLE8)), /* nt4 */ - "SetDIBitsToDevice succeeded for %u/%u/%u\n", bpp, planes, compr ); - ret = StretchDIBits( memdc, 0, 0, 1, 1, 0, 0, 1, 1, data, bi, DIB_RGB_COLORS, SRCCOPY ); - if (expect_ok) - { - if (todo) - todo_wine ok( ret, "StretchDIBits failed for %u/%u/%u\n", bpp, planes, compr ); - else - ok( ret, "StretchDIBits failed for %u/%u/%u\n", bpp, planes, compr ); - } - else - ok( !ret || - broken((bpp == 4 && compr == BI_RLE4) || (bpp == 8 && compr == BI_RLE8)), /* nt4 */ - "StretchDIBits succeeded for %u/%u/%u\n", bpp, planes, compr ); + ok( !ret || broken(!bpp && (compr == BI_JPEG || compr == BI_PNG)), /* nt4 */ + "GetDIBits succeeded for %u/%u/%u/%u\n", bpp, planes, compr, format ); - ret = GetDIBits(hdc, hbmp, 0, 2, data, bi, DIB_RGB_COLORS); - if (expect_ok) - ok( ret, "GetDIBits failed for %u/%u/%u\n", bpp, planes, compr ); - else - ok( !ret, "GetDIBits succeeded for %u/%u/%u\n", bpp, planes, compr ); - ok( bi->bmiHeader.biBitCount == bpp, "GetDIBits modified bpp %u/%u\n", - bpp, bi->bmiHeader.biBitCount ); + /* all functions check planes except GetDIBits with 0 lines */ + format_ok = expect_ok; + if (!planes) expect_ok = FALSE; + memset( bi, 0, sizeof(bi->bmiHeader) ); + bi->bmiHeader.biSize = sizeof(BITMAPINFOHEADER); + bi->bmiHeader.biWidth = 2; + bi->bmiHeader.biHeight = 2; + bi->bmiHeader.biPlanes = planes; + bi->bmiHeader.biBitCount = bpp; + bi->bmiHeader.biCompression = compr; + bi->bmiHeader.biSizeImage = 0; + memset( bi->bmiColors, 0xaa, sizeof(RGBQUAD) * 256 ); - bi->bmiHeader.biSize = sizeof(BITMAPINFOHEADER); - bi->bmiHeader.biWidth = 2; - bi->bmiHeader.biHeight = 2; - bi->bmiHeader.biPlanes = planes; - bi->bmiHeader.biBitCount = bpp; - bi->bmiHeader.biCompression = compr; - bi->bmiHeader.biSizeImage = 1; - memset( bi->bmiColors, 0xaa, sizeof(RGBQUAD) * 256 ); - /* RLE allowed with valid biSizeImage */ - if ((bpp == 4 && compr == BI_RLE4) || (bpp == 8 && compr == BI_RLE8)) expect_ok = TRUE; + hdib = CreateDIBSection(hdc, bi, format, &bits, NULL, 0); + if (expect_ok && (planes == 1 || planes * bpp <= 16) && + (compr != BI_BITFIELDS || format != DIB_PAL_COLORS)) + ok( hdib != NULL, "CreateDIBSection failed for %u/%u/%u/%u\n", bpp, planes, compr, format ); + else + ok( hdib == NULL, "CreateDIBSection succeeded for %u/%u/%u/%u\n", bpp, planes, compr, format ); + if (hdib) DeleteObject( hdib ); - ret = SetDIBits(hdc, hbmp, 0, 1, data, bi, DIB_RGB_COLORS); - if (expect_ok) - { - if (todo) - todo_wine ok( ret, "SetDIBits failed for %u/%u/%u\n", bpp, planes, compr ); + hdib = CreateDIBitmap( hdc, &bi->bmiHeader, 0, data, bi, format ); + /* no sanity checks in CreateDIBitmap except compression */ + if (compr == BI_JPEG || compr == BI_PNG) + ok( hdib == NULL || broken(hdib != NULL), /* nt4 */ + "CreateDIBitmap succeeded for %u/%u/%u/%u\n", bpp, planes, compr, format ); else - ok( ret, "SetDIBits failed for %u/%u/%u\n", bpp, planes, compr ); - } - else - ok( !ret, "SetDIBits succeeded for %u/%u/%u\n", bpp, planes, compr ); - ret = SetDIBitsToDevice( memdc, 0, 0, 1, 1, 0, 0, 0, 1, data, bi, DIB_RGB_COLORS ); - if (expect_ok) - { - if (todo) - todo_wine ok( ret, "SetDIBitsToDevice failed for %u/%u/%u\n", bpp, planes, compr ); - else - ok( ret, "SetDIBitsToDevice failed for %u/%u/%u\n", bpp, planes, compr ); - } - else - ok( !ret, "SetDIBitsToDevice succeeded for %u/%u/%u\n", bpp, planes, compr ); - ret = StretchDIBits( memdc, 0, 0, 1, 1, 0, 0, 1, 1, data, bi, DIB_RGB_COLORS, SRCCOPY ); - if (expect_ok) - { - if (todo) - todo_wine ok( ret, "StretchDIBits failed for %u/%u/%u\n", bpp, planes, compr ); - else - ok( ret, "StretchDIBits failed for %u/%u/%u\n", bpp, planes, compr ); - } - else - ok( !ret, "StretchDIBits succeeded for %u/%u/%u\n", bpp, planes, compr ); + ok( hdib != NULL, "CreateDIBitmap failed for %u/%u/%u/%u\n", bpp, planes, compr, format ); + if (hdib) DeleteObject( hdib ); - bi->bmiHeader.biSizeImage = 0; - ret = GetDIBits(hdc, hbmp, 0, 2, NULL, bi, DIB_RGB_COLORS); - if (expect_ok || !bpp) - ok( ret, "GetDIBits failed for %u/%u/%u\n", bpp, planes, compr ); - else - ok( !ret, "GetDIBits succeeded for %u/%u/%u\n", bpp, planes, compr ); + /* RLE needs a size */ + bi->bmiHeader.biSizeImage = 0; + ret = SetDIBits(hdc, hbmp, 0, 1, data, bi, format); + if (expect_ok) + ok( ret, "SetDIBits failed for %u/%u/%u/%u\n", bpp, planes, compr, format ); + else + ok( !ret || + broken((bpp == 4 && compr == BI_RLE4) || (bpp == 8 && compr == BI_RLE8)), /* nt4 */ + "SetDIBits succeeded for %u/%u/%u/%u\n", bpp, planes, compr, format ); + ret = SetDIBitsToDevice( memdc, 0, 0, 1, 1, 0, 0, 0, 1, data, bi, format ); + if (expect_ok) + ok( ret, "SetDIBitsToDevice failed for %u/%u/%u/%u\n", bpp, planes, compr, format ); + else + ok( !ret || + broken((bpp == 4 && compr == BI_RLE4) || (bpp == 8 && compr == BI_RLE8)), /* nt4 */ + "SetDIBitsToDevice succeeded for %u/%u/%u/%u\n", bpp, planes, compr, format ); + ret = StretchDIBits( memdc, 0, 0, 1, 1, 0, 0, 1, 1, data, bi, format, SRCCOPY ); + if (expect_ok) + ok( ret, "StretchDIBits failed for %u/%u/%u/%u\n", bpp, planes, compr, format ); + else + ok( !ret || + broken((bpp == 4 && compr == BI_RLE4) || (bpp == 8 && compr == BI_RLE8)), /* nt4 */ + "StretchDIBits succeeded for %u/%u/%u/%u\n", bpp, planes, compr, format ); + + ret = GetDIBits(hdc, hbmp, 0, 2, data, bi, format); + if (expect_ok) + ok( ret, "GetDIBits failed for %u/%u/%u/%u\n", bpp, planes, compr, format ); + else + ok( !ret, "GetDIBits succeeded for %u/%u/%u/%u\n", bpp, planes, compr, format ); + ok( bi->bmiHeader.biBitCount == bpp, "GetDIBits modified bpp %u/%u\n", + bpp, bi->bmiHeader.biBitCount ); + + bi->bmiHeader.biSize = sizeof(BITMAPINFOHEADER); + bi->bmiHeader.biWidth = 2; + bi->bmiHeader.biHeight = 2; + bi->bmiHeader.biPlanes = planes; + bi->bmiHeader.biBitCount = bpp; + bi->bmiHeader.biCompression = compr; + bi->bmiHeader.biSizeImage = 1; + memset( bi->bmiColors, 0xaa, sizeof(RGBQUAD) * 256 ); + /* RLE allowed with valid biSizeImage */ + if ((bpp == 4 && compr == BI_RLE4) || (bpp == 8 && compr == BI_RLE8)) expect_ok = TRUE; + + ret = SetDIBits(hdc, hbmp, 0, 1, data, bi, format); + if (expect_ok) + ok( ret, "SetDIBits failed for %u/%u/%u/%u\n", bpp, planes, compr, format ); + else + ok( !ret, "SetDIBits succeeded for %u/%u/%u/%u\n", bpp, planes, compr, format ); + ret = SetDIBitsToDevice( memdc, 0, 0, 1, 1, 0, 0, 0, 1, data, bi, format ); + if (expect_ok) + ok( ret, "SetDIBitsToDevice failed for %u/%u/%u/%u\n", bpp, planes, compr, format ); + else + ok( !ret, "SetDIBitsToDevice succeeded for %u/%u/%u/%u\n", bpp, planes, compr, format ); + ret = StretchDIBits( memdc, 0, 0, 1, 1, 0, 0, 1, 1, data, bi, format, SRCCOPY ); + if (expect_ok) + ok( ret, "StretchDIBits failed for %u/%u/%u/%u\n", bpp, planes, compr, format ); + else + ok( !ret, "StretchDIBits succeeded for %u/%u/%u/%u\n", bpp, planes, compr, format ); + + bi->bmiHeader.biSizeImage = 0; + ret = GetDIBits(hdc, hbmp, 0, 2, NULL, bi, format); + if (expect_ok || !bpp) + ok( ret, "GetDIBits failed for %u/%u/%u/%u\n", bpp, planes, compr, format ); + else + ok( !ret || broken(format_ok && !planes), /* nt4 */ + "GetDIBits succeeded for %u/%u/%u/%u\n", bpp, planes, compr, format ); + } } } } @@ -1017,9 +1052,9 @@ static void test_dib_formats(void) ok( hdib != NULL, "CreateDIBitmap failed with null bitfields\n" ); DeleteObject( hdib ); ret = SetDIBitsToDevice( memdc, 0, 0, 1, 1, 0, 0, 0, 1, data, bi, DIB_RGB_COLORS ); - todo_wine ok( ret, "SetDIBitsToDevice failed with null bitfields\n" ); + ok( ret, "SetDIBitsToDevice failed with null bitfields\n" ); ret = StretchDIBits( memdc, 0, 0, 1, 1, 0, 0, 1, 1, data, bi, DIB_RGB_COLORS, SRCCOPY ); - todo_wine ok( ret, "StretchDIBits failed with null bitfields\n" ); + ok( ret, "StretchDIBits failed with null bitfields\n" ); ret = GetDIBits(hdc, hbmp, 0, 2, data, bi, DIB_RGB_COLORS); ok( ret, "GetDIBits failed with null bitfields\n" ); bi->bmiHeader.biPlanes = 1; @@ -1049,7 +1084,7 @@ static void test_dib_formats(void) ok( hdib != NULL, "CreateDIBSection failed with bad bitfields\n" ); if (hdib) DeleteObject( hdib ); ret = SetDIBits(hdc, hbmp, 0, 1, data, bi, DIB_RGB_COLORS); - todo_wine ok( ret, "SetDIBits failed with bad bitfields\n" ); + ok( ret, "SetDIBits failed with bad bitfields\n" ); bi->bmiHeader.biWidth = -2; bi->bmiHeader.biHeight = 2; @@ -1122,6 +1157,56 @@ static void test_dib_formats(void) ret = GetDIBits(hdc, hbmp, 0, 2, NULL, bi, DIB_RGB_COLORS); ok( !ret || broken(ret), /* nt4 */ "GetDIBits succeeded with zero height\n" ); + /* some functions accept DIB_PAL_COLORS+1, but not beyond */ + + bi->bmiHeader.biWidth = 2; + bi->bmiHeader.biHeight = 2; + bi->bmiHeader.biBitCount = 1; + bi->bmiHeader.biCompression = BI_RGB; + hdib = CreateDIBSection(hdc, bi, DIB_PAL_COLORS+1, &bits, NULL, 0); + ok( hdib == NULL, "CreateDIBSection succeeded with DIB_PAL_COLORS+1\n" ); + hdib = CreateDIBitmap( hdc, &bi->bmiHeader, 0, bits, bi, DIB_PAL_COLORS+1 ); + ok( hdib != NULL, "CreateDIBitmap failed with DIB_PAL_COLORS+1\n" ); + DeleteObject( hdib ); + ret = SetDIBits(hdc, hbmp, 0, 1, data, bi, DIB_PAL_COLORS+1); + ok( !ret, "SetDIBits succeeded with DIB_PAL_COLORS+1\n" ); + ret = SetDIBitsToDevice( memdc, 0, 0, 1, 1, 0, 0, 0, 1, data, bi, DIB_PAL_COLORS+1 ); + ok( ret, "SetDIBitsToDevice failed with DIB_PAL_COLORS+1\n" ); + ret = StretchDIBits( memdc, 0, 0, 1, 1, 0, 0, 1, 1, data, bi, DIB_PAL_COLORS+1, SRCCOPY ); + ok( ret, "StretchDIBits failed with DIB_PAL_COLORS+1\n" ); + ret = GetDIBits(hdc, hbmp, 0, 2, data, bi, DIB_PAL_COLORS+1); + ok( !ret, "GetDIBits succeeded with DIB_PAL_COLORS+1\n" ); + bi->bmiHeader.biWidth = 2; + bi->bmiHeader.biHeight = 2; + bi->bmiHeader.biBitCount = 1; + bi->bmiHeader.biCompression = BI_RGB; + ret = GetDIBits(hdc, hbmp, 0, 0, NULL, bi, DIB_PAL_COLORS+1); + ok( !ret, "GetDIBits succeeded with DIB_PAL_COLORS+1\n" ); + + bi->bmiHeader.biWidth = 2; + bi->bmiHeader.biHeight = 2; + bi->bmiHeader.biBitCount = 1; + bi->bmiHeader.biCompression = BI_RGB; + hdib = CreateDIBSection(hdc, bi, DIB_PAL_COLORS+2, &bits, NULL, 0); + ok( hdib == NULL, "CreateDIBSection succeeded with DIB_PAL_COLORS+2\n" ); + hdib = CreateDIBitmap( hdc, &bi->bmiHeader, 0, bits, bi, DIB_PAL_COLORS+2 ); + ok( hdib == NULL, "CreateDIBitmap succeeded with DIB_PAL_COLORS+2\n" ); + DeleteObject( hdib ); + ret = SetDIBits(hdc, hbmp, 0, 1, data, bi, DIB_PAL_COLORS+2); + ok( !ret, "SetDIBits succeeded with DIB_PAL_COLORS+2\n" ); + ret = SetDIBitsToDevice( memdc, 0, 0, 1, 1, 0, 0, 0, 1, data, bi, DIB_PAL_COLORS+2 ); + ok( !ret, "SetDIBitsToDevice succeeded with DIB_PAL_COLORS+2\n" ); + ret = StretchDIBits( memdc, 0, 0, 1, 1, 0, 0, 1, 1, data, bi, DIB_PAL_COLORS+2, SRCCOPY ); + ok( !ret, "StretchDIBits succeeded with DIB_PAL_COLORS+2\n" ); + ret = GetDIBits(hdc, hbmp, 0, 2, data, bi, DIB_PAL_COLORS+2); + ok( !ret, "GetDIBits succeeded with DIB_PAL_COLORS+2\n" ); + bi->bmiHeader.biWidth = 2; + bi->bmiHeader.biHeight = 2; + bi->bmiHeader.biBitCount = 1; + bi->bmiHeader.biCompression = BI_RGB; + ret = GetDIBits(hdc, hbmp, 0, 0, NULL, bi, DIB_PAL_COLORS+2); + ok( !ret, "GetDIBits succeeded with DIB_PAL_COLORS+2\n" ); + DeleteDC( memdc ); DeleteObject( hbmp ); ReleaseDC( 0, hdc ); @@ -1134,6 +1219,7 @@ static void test_mono_dibsection(void) HBITMAP old_bm, mono_ds; char bmibuf[sizeof(BITMAPINFO) + 256 * sizeof(RGBQUAD)]; BITMAPINFO *pbmi = (BITMAPINFO *)bmibuf; + RGBQUAD *colors = pbmi->bmiColors; BYTE bits[10 * 4]; BYTE *ds_bits; int num; @@ -1149,12 +1235,12 @@ static void test_mono_dibsection(void) pbmi->bmiHeader.biBitCount = 1; pbmi->bmiHeader.biPlanes = 1; pbmi->bmiHeader.biCompression = BI_RGB; - pbmi->bmiColors[0].rgbRed = 0xff; - pbmi->bmiColors[0].rgbGreen = 0xff; - pbmi->bmiColors[0].rgbBlue = 0xff; - pbmi->bmiColors[1].rgbRed = 0x0; - pbmi->bmiColors[1].rgbGreen = 0x0; - pbmi->bmiColors[1].rgbBlue = 0x0; + colors[0].rgbRed = 0xff; + colors[0].rgbGreen = 0xff; + colors[0].rgbBlue = 0xff; + colors[1].rgbRed = 0x0; + colors[1].rgbGreen = 0x0; + colors[1].rgbBlue = 0x0; /* * First dib section is 'inverted' ie color[0] is white, color[1] is black @@ -1179,12 +1265,12 @@ static void test_mono_dibsection(void) /* SetDIBitsToDevice with a normal bmi -> inverted dib section */ - pbmi->bmiColors[0].rgbRed = 0x0; - pbmi->bmiColors[0].rgbGreen = 0x0; - pbmi->bmiColors[0].rgbBlue = 0x0; - pbmi->bmiColors[1].rgbRed = 0xff; - pbmi->bmiColors[1].rgbGreen = 0xff; - pbmi->bmiColors[1].rgbBlue = 0xff; + colors[0].rgbRed = 0x0; + colors[0].rgbGreen = 0x0; + colors[0].rgbBlue = 0x0; + colors[1].rgbRed = 0xff; + colors[1].rgbGreen = 0xff; + colors[1].rgbBlue = 0xff; SetDIBitsToDevice(memdc, 0, 0, 10, 10, 0, 0, 0, 10, bits, pbmi, DIB_RGB_COLORS); ok(ds_bits[0] == 0x55, "out_bits %02x\n", ds_bits[0]); @@ -1196,12 +1282,12 @@ static void test_mono_dibsection(void) * Next dib section is 'normal' ie color[0] is black, color[1] is white */ - pbmi->bmiColors[0].rgbRed = 0x0; - pbmi->bmiColors[0].rgbGreen = 0x0; - pbmi->bmiColors[0].rgbBlue = 0x0; - pbmi->bmiColors[1].rgbRed = 0xff; - pbmi->bmiColors[1].rgbGreen = 0xff; - pbmi->bmiColors[1].rgbBlue = 0xff; + colors[0].rgbRed = 0x0; + colors[0].rgbGreen = 0x0; + colors[0].rgbBlue = 0x0; + colors[1].rgbRed = 0xff; + colors[1].rgbGreen = 0xff; + colors[1].rgbBlue = 0xff; mono_ds = CreateDIBSection(hdc, pbmi, DIB_RGB_COLORS, (void**)&ds_bits, NULL, 0); ok(mono_ds != NULL, "CreateDIBSection rets NULL\n"); @@ -1219,12 +1305,12 @@ static void test_mono_dibsection(void) /* SetDIBitsToDevice with a inverted bmi -> normal dib section */ - pbmi->bmiColors[0].rgbRed = 0xff; - pbmi->bmiColors[0].rgbGreen = 0xff; - pbmi->bmiColors[0].rgbBlue = 0xff; - pbmi->bmiColors[1].rgbRed = 0x0; - pbmi->bmiColors[1].rgbGreen = 0x0; - pbmi->bmiColors[1].rgbBlue = 0x0; + colors[0].rgbRed = 0xff; + colors[0].rgbGreen = 0xff; + colors[0].rgbBlue = 0xff; + colors[1].rgbRed = 0x0; + colors[1].rgbGreen = 0x0; + colors[1].rgbBlue = 0x0; SetDIBitsToDevice(memdc, 0, 0, 10, 10, 0, 0, 0, 10, bits, pbmi, DIB_RGB_COLORS); ok(ds_bits[0] == 0x55, "out_bits %02x\n", ds_bits[0]); @@ -1233,13 +1319,13 @@ static void test_mono_dibsection(void) * Take that 'normal' dibsection and change its colour table to an 'inverted' one */ - pbmi->bmiColors[0].rgbRed = 0xff; - pbmi->bmiColors[0].rgbGreen = 0xff; - pbmi->bmiColors[0].rgbBlue = 0xff; - pbmi->bmiColors[1].rgbRed = 0x0; - pbmi->bmiColors[1].rgbGreen = 0x0; - pbmi->bmiColors[1].rgbBlue = 0x0; - num = SetDIBColorTable(memdc, 0, 2, pbmi->bmiColors); + colors[0].rgbRed = 0xff; + colors[0].rgbGreen = 0xff; + colors[0].rgbBlue = 0xff; + colors[1].rgbRed = 0x0; + colors[1].rgbGreen = 0x0; + colors[1].rgbBlue = 0x0; + num = SetDIBColorTable(memdc, 0, 2, colors); ok(num == 2, "num = %d\n", num); /* black border, white interior */ @@ -1257,12 +1343,12 @@ static void test_mono_dibsection(void) /* SetDIBitsToDevice with a normal bmi -> inverted dib section */ - pbmi->bmiColors[0].rgbRed = 0x0; - pbmi->bmiColors[0].rgbGreen = 0x0; - pbmi->bmiColors[0].rgbBlue = 0x0; - pbmi->bmiColors[1].rgbRed = 0xff; - pbmi->bmiColors[1].rgbGreen = 0xff; - pbmi->bmiColors[1].rgbBlue = 0xff; + colors[0].rgbRed = 0x0; + colors[0].rgbGreen = 0x0; + colors[0].rgbBlue = 0x0; + colors[1].rgbRed = 0xff; + colors[1].rgbGreen = 0xff; + colors[1].rgbBlue = 0xff; SetDIBitsToDevice(memdc, 0, 0, 10, 10, 0, 0, 0, 10, bits, pbmi, DIB_RGB_COLORS); ok(ds_bits[0] == 0x55, "out_bits %02x\n", ds_bits[0]); @@ -1274,12 +1360,12 @@ static void test_mono_dibsection(void) * Now a dib section with a strange colour map just for fun. This behaves just like an inverted one. */ - pbmi->bmiColors[0].rgbRed = 0xff; - pbmi->bmiColors[0].rgbGreen = 0x0; - pbmi->bmiColors[0].rgbBlue = 0x0; - pbmi->bmiColors[1].rgbRed = 0xfe; - pbmi->bmiColors[1].rgbGreen = 0x0; - pbmi->bmiColors[1].rgbBlue = 0x0; + colors[0].rgbRed = 0xff; + colors[0].rgbGreen = 0x0; + colors[0].rgbBlue = 0x0; + colors[1].rgbRed = 0xfe; + colors[1].rgbGreen = 0x0; + colors[1].rgbBlue = 0x0; mono_ds = CreateDIBSection(hdc, pbmi, DIB_RGB_COLORS, (void**)&ds_bits, NULL, 0); ok(mono_ds != NULL, "CreateDIBSection rets NULL\n"); @@ -1292,24 +1378,24 @@ static void test_mono_dibsection(void) /* SetDIBitsToDevice with a normal bmi -> inverted dib section */ - pbmi->bmiColors[0].rgbRed = 0x0; - pbmi->bmiColors[0].rgbGreen = 0x0; - pbmi->bmiColors[0].rgbBlue = 0x0; - pbmi->bmiColors[1].rgbRed = 0xff; - pbmi->bmiColors[1].rgbGreen = 0xff; - pbmi->bmiColors[1].rgbBlue = 0xff; + colors[0].rgbRed = 0x0; + colors[0].rgbGreen = 0x0; + colors[0].rgbBlue = 0x0; + colors[1].rgbRed = 0xff; + colors[1].rgbGreen = 0xff; + colors[1].rgbBlue = 0xff; SetDIBitsToDevice(memdc, 0, 0, 10, 10, 0, 0, 0, 10, bits, pbmi, DIB_RGB_COLORS); ok(ds_bits[0] == 0x55, "out_bits %02x\n", ds_bits[0]); /* SetDIBitsToDevice with a inverted bmi -> inverted dib section */ - pbmi->bmiColors[0].rgbRed = 0xff; - pbmi->bmiColors[0].rgbGreen = 0xff; - pbmi->bmiColors[0].rgbBlue = 0xff; - pbmi->bmiColors[1].rgbRed = 0x0; - pbmi->bmiColors[1].rgbGreen = 0x0; - pbmi->bmiColors[1].rgbBlue = 0x0; + colors[0].rgbRed = 0xff; + colors[0].rgbGreen = 0xff; + colors[0].rgbBlue = 0xff; + colors[1].rgbRed = 0x0; + colors[1].rgbGreen = 0x0; + colors[1].rgbBlue = 0x0; SetDIBitsToDevice(memdc, 0, 0, 10, 10, 0, 0, 0, 10, bits, pbmi, DIB_RGB_COLORS); ok(ds_bits[0] == 0xaa, "out_bits %02x\n", ds_bits[0]); @@ -1767,6 +1853,7 @@ static void test_GetDIBits(void) BYTE buf[1024]; char bi_buf[sizeof(BITMAPINFOHEADER) + sizeof(RGBQUAD) * 256]; BITMAPINFO *bi = (BITMAPINFO *)bi_buf; + RGBQUAD *colors = bi->bmiColors; PALETTEENTRY pal_ents[20]; hdc = GetDC(0); @@ -1800,8 +1887,9 @@ static void test_GetDIBits(void) bi->bmiHeader.biPlanes = 1; bi->bmiHeader.biBitCount = 1; bi->bmiHeader.biCompression = BI_RGB; + bi->bmiHeader.biClrUsed = 37; bi->bmiHeader.biSizeImage = 0; - memset(bi->bmiColors, 0xAA, sizeof(RGBQUAD) * 256); + memset(colors, 0xAA, sizeof(RGBQUAD) * 256); SetLastError(0xdeadbeef); lines = GetDIBits(0, hbmp, 0, bm.bmHeight, buf, bi, DIB_RGB_COLORS); ok(lines == 0, "GetDIBits copied %d lines with hdc = 0\n", lines); @@ -1809,6 +1897,8 @@ static void test_GetDIBits(void) broken(GetLastError() == 0xdeadbeef), /* winnt */ "wrong error %u\n", GetLastError()); ok(bi->bmiHeader.biSizeImage == 0, "expected 0, got %u\n", bi->bmiHeader.biSizeImage); + ok(bi->bmiHeader.biClrUsed == 37 || broken(bi->bmiHeader.biClrUsed == 0), + "wrong biClrUsed %u\n", bi->bmiHeader.biClrUsed); memset(buf, 0xAA, sizeof(buf)); SetLastError(0xdeadbeef); @@ -1816,38 +1906,36 @@ static void test_GetDIBits(void) ok(lines == bm.bmHeight, "GetDIBits copied %d lines of %d, error %u\n", lines, bm.bmHeight, GetLastError()); ok(bi->bmiHeader.biSizeImage == sizeof(dib_bits_1), "expected 16*4, got %u\n", bi->bmiHeader.biSizeImage); + ok(bi->bmiHeader.biClrUsed == 0, "wrong biClrUsed %u\n", bi->bmiHeader.biClrUsed); /* the color table consists of black and white */ - ok(bi->bmiColors[0].rgbRed == 0 && bi->bmiColors[0].rgbGreen == 0 && - bi->bmiColors[0].rgbBlue == 0 && bi->bmiColors[0].rgbReserved == 0, + ok(colors[0].rgbRed == 0 && colors[0].rgbGreen == 0 && + colors[0].rgbBlue == 0 && colors[0].rgbReserved == 0, "expected bmiColors[0] 0,0,0,0 - got %x %x %x %x\n", - bi->bmiColors[0].rgbRed, bi->bmiColors[0].rgbGreen, - bi->bmiColors[0].rgbBlue, bi->bmiColors[0].rgbReserved); - ok(bi->bmiColors[1].rgbRed == 0xff && bi->bmiColors[1].rgbGreen == 0xff && - bi->bmiColors[1].rgbBlue == 0xff && bi->bmiColors[1].rgbReserved == 0, + colors[0].rgbRed, colors[0].rgbGreen, colors[0].rgbBlue, colors[0].rgbReserved); + ok(colors[1].rgbRed == 0xff && colors[1].rgbGreen == 0xff && + colors[1].rgbBlue == 0xff && colors[1].rgbReserved == 0, "expected bmiColors[0] 0xff,0xff,0xff,0 - got %x %x %x %x\n", - bi->bmiColors[1].rgbRed, bi->bmiColors[1].rgbGreen, - bi->bmiColors[1].rgbBlue, bi->bmiColors[1].rgbReserved); + colors[1].rgbRed, colors[1].rgbGreen, colors[1].rgbBlue, colors[1].rgbReserved); for (i = 2; i < 256; i++) { - ok(bi->bmiColors[i].rgbRed == 0xAA && bi->bmiColors[i].rgbGreen == 0xAA && - bi->bmiColors[i].rgbBlue == 0xAA && bi->bmiColors[i].rgbReserved == 0xAA, + ok(colors[i].rgbRed == 0xAA && colors[i].rgbGreen == 0xAA && + colors[i].rgbBlue == 0xAA && colors[i].rgbReserved == 0xAA, "expected bmiColors[%d] 0xAA,0xAA,0xAA,0xAA - got %x %x %x %x\n", i, - bi->bmiColors[i].rgbRed, bi->bmiColors[i].rgbGreen, - bi->bmiColors[i].rgbBlue, bi->bmiColors[i].rgbReserved); + colors[i].rgbRed, colors[i].rgbGreen, colors[i].rgbBlue, colors[i].rgbReserved); } /* returned bits are DWORD aligned and upside down */ ok(!memcmp(buf, dib_bits_1, sizeof(dib_bits_1)), "DIB bits don't match\n"); /* Test the palette indices */ - memset(bi->bmiColors, 0xAA, sizeof(RGBQUAD) * 256); + memset(colors, 0xAA, sizeof(RGBQUAD) * 256); SetLastError(0xdeadbeef); lines = GetDIBits(hdc, hbmp, 0, 0, NULL, bi, DIB_PAL_COLORS); - ok(((WORD*)bi->bmiColors)[0] == 0, "Color 0 is %d\n", ((WORD*)bi->bmiColors)[0]); - ok(((WORD*)bi->bmiColors)[1] == 1, "Color 1 is %d\n", ((WORD*)bi->bmiColors)[1]); + ok(((WORD*)colors)[0] == 0, "Color 0 is %d\n", ((WORD*)colors)[0]); + ok(((WORD*)colors)[1] == 1, "Color 1 is %d\n", ((WORD*)colors)[1]); for (i = 2; i < 256; i++) - ok(((WORD*)bi->bmiColors)[i] == 0xAAAA, "Color %d is %d\n", i, ((WORD*)bi->bmiColors)[1]); + ok(((WORD*)colors)[i] == 0xAAAA, "Color %d is %d\n", i, ((WORD*)colors)[1]); /* retrieve 24-bit DIB data */ memset(bi, 0, sizeof(*bi)); @@ -1857,23 +1945,24 @@ static void test_GetDIBits(void) bi->bmiHeader.biPlanes = 1; bi->bmiHeader.biBitCount = 24; bi->bmiHeader.biCompression = BI_RGB; + bi->bmiHeader.biClrUsed = 37; bi->bmiHeader.biSizeImage = 0; - memset(bi->bmiColors, 0xAA, sizeof(RGBQUAD) * 256); + memset(colors, 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()); ok(bi->bmiHeader.biSizeImage == sizeof(dib_bits_24), "expected 16*16*3, got %u\n", bi->bmiHeader.biSizeImage); + ok(bi->bmiHeader.biClrUsed == 0, "wrong biClrUsed %u\n", bi->bmiHeader.biClrUsed); /* the color table doesn't exist for 24-bit images */ for (i = 0; i < 256; i++) { - ok(bi->bmiColors[i].rgbRed == 0xAA && bi->bmiColors[i].rgbGreen == 0xAA && - bi->bmiColors[i].rgbBlue == 0xAA && bi->bmiColors[i].rgbReserved == 0xAA, + ok(colors[i].rgbRed == 0xAA && colors[i].rgbGreen == 0xAA && + colors[i].rgbBlue == 0xAA && colors[i].rgbReserved == 0xAA, "expected bmiColors[%d] 0xAA,0xAA,0xAA,0xAA - got %x %x %x %x\n", i, - bi->bmiColors[i].rgbRed, bi->bmiColors[i].rgbGreen, - bi->bmiColors[i].rgbBlue, bi->bmiColors[i].rgbReserved); + colors[i].rgbRed, colors[i].rgbGreen, colors[i].rgbBlue, colors[i].rgbReserved); } /* returned bits are DWORD aligned and upside down */ @@ -1914,46 +2003,45 @@ static void test_GetDIBits(void) bi->bmiHeader.biPlanes = 1; bi->bmiHeader.biBitCount = 1; bi->bmiHeader.biCompression = BI_RGB; + bi->bmiHeader.biClrUsed = 37; bi->bmiHeader.biSizeImage = 0; - memset(bi->bmiColors, 0xAA, sizeof(RGBQUAD) * 256); + memset(colors, 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()); ok(bi->bmiHeader.biSizeImage == sizeof(dib_bits_1), "expected 16*4, got %u\n", bi->bmiHeader.biSizeImage); + ok(bi->bmiHeader.biClrUsed == 0, "wrong biClrUsed %u\n", bi->bmiHeader.biClrUsed); /* the color table consists of black and white */ - ok(bi->bmiColors[0].rgbRed == 0 && bi->bmiColors[0].rgbGreen == 0 && - bi->bmiColors[0].rgbBlue == 0 && bi->bmiColors[0].rgbReserved == 0, + ok(colors[0].rgbRed == 0 && colors[0].rgbGreen == 0 && + colors[0].rgbBlue == 0 && colors[0].rgbReserved == 0, "expected bmiColors[0] 0,0,0,0 - got %x %x %x %x\n", - bi->bmiColors[0].rgbRed, bi->bmiColors[0].rgbGreen, - bi->bmiColors[0].rgbBlue, bi->bmiColors[0].rgbReserved); - ok(bi->bmiColors[1].rgbRed == 0xff && bi->bmiColors[1].rgbGreen == 0xff && - bi->bmiColors[1].rgbBlue == 0xff && bi->bmiColors[1].rgbReserved == 0, + colors[0].rgbRed, colors[0].rgbGreen, colors[0].rgbBlue, colors[0].rgbReserved); + ok(colors[1].rgbRed == 0xff && colors[1].rgbGreen == 0xff && + colors[1].rgbBlue == 0xff && colors[1].rgbReserved == 0, "expected bmiColors[0] 0xff,0xff,0xff,0 - got %x %x %x %x\n", - bi->bmiColors[1].rgbRed, bi->bmiColors[1].rgbGreen, - bi->bmiColors[1].rgbBlue, bi->bmiColors[1].rgbReserved); + colors[1].rgbRed, colors[1].rgbGreen, colors[1].rgbBlue, colors[1].rgbReserved); for (i = 2; i < 256; i++) { - ok(bi->bmiColors[i].rgbRed == 0xAA && bi->bmiColors[i].rgbGreen == 0xAA && - bi->bmiColors[i].rgbBlue == 0xAA && bi->bmiColors[i].rgbReserved == 0xAA, + ok(colors[i].rgbRed == 0xAA && colors[i].rgbGreen == 0xAA && + colors[i].rgbBlue == 0xAA && colors[i].rgbReserved == 0xAA, "expected bmiColors[%d] 0xAA,0xAA,0xAA,0xAA - got %x %x %x %x\n", i, - bi->bmiColors[i].rgbRed, bi->bmiColors[i].rgbGreen, - bi->bmiColors[i].rgbBlue, bi->bmiColors[i].rgbReserved); + colors[i].rgbRed, colors[i].rgbGreen, colors[i].rgbBlue, colors[i].rgbReserved); } /* returned bits are DWORD aligned and upside down */ ok(!memcmp(buf, dib_bits_1, sizeof(dib_bits_1)), "DIB bits don't match\n"); /* Test the palette indices */ - memset(bi->bmiColors, 0xAA, sizeof(RGBQUAD) * 256); + memset(colors, 0xAA, sizeof(RGBQUAD) * 256); SetLastError(0xdeadbeef); lines = GetDIBits(hdc, hbmp, 0, 0, NULL, bi, DIB_PAL_COLORS); - ok(((WORD*)bi->bmiColors)[0] == 0, "Color 0 is %d\n", ((WORD*)bi->bmiColors)[0]); - ok(((WORD*)bi->bmiColors)[1] == 1, "Color 1 is %d\n", ((WORD*)bi->bmiColors)[1]); + ok(((WORD*)colors)[0] == 0, "Color 0 is %d\n", ((WORD*)colors)[0]); + ok(((WORD*)colors)[1] == 1, "Color 1 is %d\n", ((WORD*)colors)[1]); for (i = 2; i < 256; i++) - ok(((WORD*)bi->bmiColors)[i] == 0xAAAA, "Color %d is %d\n", i, ((WORD*)bi->bmiColors)[i]); + ok(((WORD*)colors)[i] == 0xAAAA, "Color %d is %d\n", i, ((WORD*)colors)[i]); /* retrieve 4-bit DIB data */ memset(bi, 0, sizeof(*bi)); @@ -1963,13 +2051,15 @@ static void test_GetDIBits(void) bi->bmiHeader.biPlanes = 1; bi->bmiHeader.biBitCount = 4; bi->bmiHeader.biCompression = BI_RGB; + bi->bmiHeader.biClrUsed = 37; bi->bmiHeader.biSizeImage = 0; - memset(bi->bmiColors, 0xAA, sizeof(RGBQUAD) * 256); + memset(colors, 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()); + ok(bi->bmiHeader.biClrUsed == 0, "wrong biClrUsed %u\n", bi->bmiHeader.biClrUsed); GetPaletteEntries( GetStockObject(DEFAULT_PALETTE), 0, 20, pal_ents ); @@ -1986,11 +2076,10 @@ static void test_GetDIBits(void) expect.rgbBlue = pal_ents[entry].peBlue; expect.rgbReserved = 0; - ok(!memcmp(bi->bmiColors + i, &expect, sizeof(expect)), + ok(!memcmp(colors + 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); + colors[i].rgbRed, colors[i].rgbGreen, colors[i].rgbBlue, colors[i].rgbReserved); } /* retrieve 8-bit DIB data */ @@ -2001,13 +2090,15 @@ static void test_GetDIBits(void) bi->bmiHeader.biPlanes = 1; bi->bmiHeader.biBitCount = 8; bi->bmiHeader.biCompression = BI_RGB; + bi->bmiHeader.biClrUsed = 37; bi->bmiHeader.biSizeImage = 0; - memset(bi->bmiColors, 0xAA, sizeof(RGBQUAD) * 256); + memset(colors, 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()); + ok(bi->bmiHeader.biClrUsed == 0, "wrong biClrUsed %u\n", bi->bmiHeader.biClrUsed); GetPaletteEntries( GetStockObject(DEFAULT_PALETTE), 0, 20, pal_ents ); @@ -2030,11 +2121,10 @@ static void test_GetDIBits(void) } expect.rgbReserved = 0; - ok(!memcmp(bi->bmiColors + i, &expect, sizeof(expect)), + ok(!memcmp(colors + 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); + colors[i].rgbRed, colors[i].rgbGreen, colors[i].rgbBlue, colors[i].rgbReserved); } /* retrieve 24-bit DIB data */ @@ -2045,23 +2135,24 @@ static void test_GetDIBits(void) bi->bmiHeader.biPlanes = 1; bi->bmiHeader.biBitCount = 24; bi->bmiHeader.biCompression = BI_RGB; + bi->bmiHeader.biClrUsed = 37; bi->bmiHeader.biSizeImage = 0; - memset(bi->bmiColors, 0xAA, sizeof(RGBQUAD) * 256); + memset(colors, 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()); ok(bi->bmiHeader.biSizeImage == sizeof(dib_bits_24), "expected 16*16*3, got %u\n", bi->bmiHeader.biSizeImage); + ok(bi->bmiHeader.biClrUsed == 0, "wrong biClrUsed %u\n", bi->bmiHeader.biClrUsed); /* the color table doesn't exist for 24-bit images */ for (i = 0; i < 256; i++) { - ok(bi->bmiColors[i].rgbRed == 0xAA && bi->bmiColors[i].rgbGreen == 0xAA && - bi->bmiColors[i].rgbBlue == 0xAA && bi->bmiColors[i].rgbReserved == 0xAA, + ok(colors[i].rgbRed == 0xAA && colors[i].rgbGreen == 0xAA && + colors[i].rgbBlue == 0xAA && colors[i].rgbReserved == 0xAA, "expected bmiColors[%d] 0xAA,0xAA,0xAA,0xAA - got %x %x %x %x\n", i, - bi->bmiColors[i].rgbRed, bi->bmiColors[i].rgbGreen, - bi->bmiColors[i].rgbBlue, bi->bmiColors[i].rgbReserved); + colors[i].rgbRed, colors[i].rgbGreen, colors[i].rgbBlue, colors[i].rgbReserved); } /* returned bits are DWORD aligned and upside down */ @@ -2658,7 +2749,6 @@ static void check_BitBlt_pixel(HDC hdcDst, HDC hdcSrc, UINT32 *dstBuffer, UINT32 { *srcBuffer = 0xFEDCBA98; *dstBuffer = 0x89ABCDEF; - Rectangle(hdcSrc, 0, 0, 1, 1); /* A null operation to ensure dibs are coerced to X11 */ BitBlt(hdcDst, 0, 0, 1, 1, hdcSrc, 0, 0, dwRop); ok(expected == *dstBuffer, "BitBlt with dwRop %06X. Expected 0x%08X, got 0x%08X from line %d\n", @@ -2692,7 +2782,7 @@ static void test_BitBlt(void) NULL, 0); oldDst = SelectObject(hdcDst, bmpDst); - hBrush = CreateSolidBrush(0x012345678); + hBrush = CreateSolidBrush(0x12345678); hOldBrush = SelectObject(hdcDst, hBrush); /* Setup the source dib section */ @@ -2770,6 +2860,7 @@ static void test_StretchBlt(void) HBRUSH hBrush, hOldBrush; BITMAPINFO biDst, biSrc; UINT32 expected[256]; + RGBQUAD colors[2]; memset(&biDst, 0, sizeof(BITMAPINFO)); biDst.bmiHeader.biSize = sizeof(BITMAPINFOHEADER); @@ -2874,24 +2965,20 @@ static void test_StretchBlt(void) 0, 0, 1, 1, 0, 0, 2, 1, expected, __LINE__); expected[0] = srcBuffer[0] & srcBuffer[1]; -todo_wine check_StretchBlt_stretch(hdcDst, hdcSrc, &biDst, dstBuffer, srcBuffer, 0, 0, 1, 1, 0, 0, 3, 1, expected, __LINE__); expected[0] = srcBuffer[0] & srcBuffer[1] & srcBuffer[2]; -todo_wine check_StretchBlt_stretch(hdcDst, hdcSrc, &biDst, dstBuffer, srcBuffer, 0, 0, 1, 1, 0, 0, 4, 1, expected, __LINE__); /* this doesn't happen if the src width is -ve */ expected[0] = srcBuffer[1] & srcBuffer[2]; -todo_wine check_StretchBlt_stretch(hdcDst, hdcSrc, &biDst, dstBuffer, srcBuffer, 0, 0, 1, 1, 2, 0, -2, 1, expected, __LINE__); /* when dst width > 1 behaviour reverts to what one would expect */ expected[0] = srcBuffer[0] & srcBuffer[1], expected[1] = srcBuffer[2] & srcBuffer[3]; -todo_wine check_StretchBlt_stretch(hdcDst, hdcSrc, &biDst, dstBuffer, srcBuffer, 0, 0, 2, 1, 0, 0, 4, 1, expected, __LINE__); @@ -2907,7 +2994,6 @@ todo_wine SetViewportExtEx( hdcDst, 100, 100, NULL ); expected[0] = srcBuffer[0] & srcBuffer[1] & srcBuffer[2]; -todo_wine check_StretchBlt_stretch(hdcDst, hdcSrc, &biDst, dstBuffer, srcBuffer, 0, 0, 2, 2, 0, 0, 4, 1, expected, __LINE__); SetMapMode( hdcDst, MM_TEXT ); @@ -3016,6 +3102,48 @@ todo_wine SelectObject(hdcSrc, oldSrc); DeleteObject(bmpSrc); + + biSrc.bmiHeader.biBitCount = 1; + bmpSrc = CreateDIBSection(hdcScreen, &biSrc, DIB_RGB_COLORS, (void**)&srcBuffer, NULL, 0); + oldSrc = SelectObject(hdcSrc, bmpSrc); + *((DWORD *)colors + 0) = 0x123456; + *((DWORD *)colors + 1) = 0x335577; + SetDIBColorTable( hdcSrc, 0, 2, colors ); + srcBuffer[0] = 0x55555555; + memset(dstBuffer, 0xcc, 4 * sizeof(*dstBuffer)); + SetTextColor( hdcDst, 0 ); + SetBkColor( hdcDst, 0 ); + StretchBlt(hdcDst, 0, 0, 4, 1, hdcSrc, 0, 0, 4, 1, SRCCOPY ); + expected[0] = expected[2] = 0x00123456; + expected[1] = expected[3] = 0x00335577; + ok(!memcmp(dstBuffer, expected, 16), + "StretchBlt expected { %08X, %08X, %08X, %08X } got { %08X, %08X, %08X, %08X }\n", + expected[0], expected[1], expected[2], expected[3], + dstBuffer[0], dstBuffer[1], dstBuffer[2], dstBuffer[3] ); + + SelectObject(hdcSrc, oldSrc); + DeleteObject(bmpSrc); + + bmpSrc = CreateBitmap( 16, 16, 1, 1, 0 ); + oldSrc = SelectObject(hdcSrc, bmpSrc); + SetPixel( hdcSrc, 0, 0, 0 ); + SetPixel( hdcSrc, 1, 0, 0xffffff ); + SetPixel( hdcSrc, 2, 0, 0xffffff ); + SetPixel( hdcSrc, 3, 0, 0 ); + memset(dstBuffer, 0xcc, 4 * sizeof(*dstBuffer)); + SetTextColor( hdcDst, RGB(0x22,0x44,0x66) ); + SetBkColor( hdcDst, RGB(0x65,0x43,0x21) ); + StretchBlt(hdcDst, 0, 0, 4, 1, hdcSrc, 0, 0, 4, 1, SRCCOPY ); + expected[0] = expected[3] = 0x00224466; + expected[1] = expected[2] = 0x00654321; + ok(!memcmp(dstBuffer, expected, 16), + "StretchBlt expected { %08X, %08X, %08X, %08X } got { %08X, %08X, %08X, %08X }\n", + expected[0], expected[1], expected[2], expected[3], + dstBuffer[0], dstBuffer[1], dstBuffer[2], dstBuffer[3] ); + + SelectObject(hdcSrc, oldSrc); + DeleteObject(bmpSrc); + DeleteDC(hdcSrc); SelectObject(hdcDst, oldDst); @@ -3051,7 +3179,7 @@ static void check_StretchDIBits_pixel(HDC hdcDst, UINT32 *dstBuffer, UINT32 *src static void check_StretchDIBits_stretch(HDC hdcDst, UINT32 *dstBuffer, UINT32 *srcBuffer, int nXOriginDest, int nYOriginDest, int nWidthDest, int nHeightDest, int nXOriginSrc, int nYOriginSrc, int nWidthSrc, int nHeightSrc, - UINT32 expected[4], UINT32 legacy_expected[4], int line) + UINT32 expected[4], int line) { BITMAPINFO bitmapInfo; @@ -3084,7 +3212,7 @@ static void test_StretchDIBits(void) UINT32 *dstBuffer, srcBuffer[4]; HBRUSH hBrush, hOldBrush; BITMAPINFO biDst; - UINT32 expected[4], legacy_expected[4]; + UINT32 expected[4]; memset(&biDst, 0, sizeof(BITMAPINFO)); biDst.bmiHeader.biSize = sizeof(BITMAPINFOHEADER); @@ -3131,46 +3259,42 @@ static void test_StretchDIBits(void) expected[0] = 0xCAFED00D, expected[1] = 0xFEEDFACE; expected[2] = 0xFEDCBA98, expected[3] = 0x76543210; check_StretchDIBits_stretch(hdcDst, dstBuffer, srcBuffer, - 0, 0, 2, 2, 0, 0, 2, 2, expected, expected, __LINE__); + 0, 0, 2, 2, 0, 0, 2, 2, expected, __LINE__); expected[0] = 0xCAFED00D, expected[1] = 0x00000000; expected[2] = 0x00000000, expected[3] = 0x00000000; - legacy_expected[0] = 0xFEDCBA98, legacy_expected[1] = 0x00000000; - legacy_expected[2] = 0x00000000, legacy_expected[3] = 0x00000000; check_StretchDIBits_stretch(hdcDst, dstBuffer, srcBuffer, - 0, 0, 1, 1, 0, 0, 1, 1, expected, legacy_expected, __LINE__); + 0, 0, 1, 1, 0, 0, 1, 1, expected, __LINE__); expected[0] = 0xFEDCBA98, expected[1] = 0xFEDCBA98; expected[2] = 0xFEDCBA98, expected[3] = 0xFEDCBA98; check_StretchDIBits_stretch(hdcDst, dstBuffer, srcBuffer, - 0, 0, 2, 2, 0, 0, 1, 1, expected, expected, __LINE__); + 0, 0, 2, 2, 0, 0, 1, 1, expected, __LINE__); expected[0] = 0x42441000, expected[1] = 0x00000000; expected[2] = 0x00000000, expected[3] = 0x00000000; - legacy_expected[0] = 0x00543210, legacy_expected[1] = 0x00000000; - legacy_expected[2] = 0x00000000, legacy_expected[3] = 0x00000000; - todo_wine check_StretchDIBits_stretch(hdcDst, dstBuffer, srcBuffer, - 0, 0, 1, 1, 0, 0, 2, 2, expected, legacy_expected, __LINE__); + check_StretchDIBits_stretch(hdcDst, dstBuffer, srcBuffer, + 0, 0, 1, 1, 0, 0, 2, 2, expected, __LINE__); expected[0] = 0x00000000, expected[1] = 0x00000000; expected[2] = 0x00000000, expected[3] = 0x00000000; check_StretchDIBits_stretch(hdcDst, dstBuffer, srcBuffer, - 0, 0, 2, 2, 1, 1, -2, -2, expected, expected, __LINE__); + 0, 0, 2, 2, 1, 1, -2, -2, expected, __LINE__); expected[0] = 0x00000000, expected[1] = 0x00000000; expected[2] = 0x00000000, expected[3] = 0x00000000; check_StretchDIBits_stretch(hdcDst, dstBuffer, srcBuffer, - 0, 0, 2, 2, 1, 1, -2, -2, expected, expected, __LINE__); + 0, 0, 2, 2, 1, 1, -2, -2, expected, __LINE__); expected[0] = 0x00000000, expected[1] = 0x00000000; expected[2] = 0x00000000, expected[3] = 0x00000000; check_StretchDIBits_stretch(hdcDst, dstBuffer, srcBuffer, - 1, 1, -2, -2, 1, 1, -2, -2, expected, expected, __LINE__); + 1, 1, -2, -2, 1, 1, -2, -2, expected, __LINE__); expected[0] = 0x00000000, expected[1] = 0x00000000; expected[2] = 0x00000000, expected[3] = 0xCAFED00D; check_StretchDIBits_stretch(hdcDst, dstBuffer, srcBuffer, - 1, 1, 2, 2, 0, 0, 2, 2, expected, expected, __LINE__); + 1, 1, 2, 2, 0, 0, 2, 2, expected, __LINE__); SelectObject(hdcDst, oldDst); DeleteObject(bmpDst); @@ -3184,7 +3308,7 @@ static void test_StretchDIBits(void) expected[0] = 0xFEDCBA98, expected[1] = 0x76543210; expected[2] = 0xCAFED00D, expected[3] = 0xFEEDFACE; check_StretchDIBits_stretch(hdcDst, dstBuffer, srcBuffer, - 0, 0, 2, 2, 0, 0, 2, 2, expected, expected, __LINE__); + 0, 0, 2, 2, 0, 0, 2, 2, expected, __LINE__); /* Tidy up */ SelectObject(hdcDst, oldDst); @@ -3196,19 +3320,16 @@ static void test_StretchDIBits(void) static void test_GdiAlphaBlend(void) { - /* test out-of-bound parameters for GdiAlphaBlend */ HDC hdcNull; - HDC hdcDst; HBITMAP bmpDst; HBITMAP oldDst; - - BITMAPINFO bmi; + BITMAPINFO *bmi; HDC hdcSrc; HBITMAP bmpSrc; HBITMAP oldSrc; LPVOID bits; - + BOOL ret; BLENDFUNCTION blend; if (!pGdiAlphaBlend) @@ -3222,14 +3343,14 @@ static void test_GdiAlphaBlend(void) bmpDst = CreateCompatibleBitmap(hdcNull, 100, 100); hdcSrc = CreateCompatibleDC(hdcNull); - memset(&bmi, 0, sizeof(bmi)); /* as of Wine 0.9.44 we require the src to be a DIB section */ - bmi.bmiHeader.biSize = sizeof(bmi.bmiHeader); - bmi.bmiHeader.biHeight = 20; - bmi.bmiHeader.biWidth = 20; - bmi.bmiHeader.biBitCount = 32; - bmi.bmiHeader.biPlanes = 1; - bmi.bmiHeader.biCompression = BI_RGB; - bmpSrc = CreateDIBSection(hdcDst, &bmi, DIB_RGB_COLORS, &bits, NULL, 0); + bmi = HeapAlloc( GetProcessHeap(), HEAP_ZERO_MEMORY, FIELD_OFFSET( BITMAPINFO, bmiColors[3] )); + bmi->bmiHeader.biSize = sizeof(bmi->bmiHeader); + bmi->bmiHeader.biHeight = 20; + bmi->bmiHeader.biWidth = 20; + bmi->bmiHeader.biBitCount = 32; + bmi->bmiHeader.biPlanes = 1; + bmi->bmiHeader.biCompression = BI_RGB; + bmpSrc = CreateDIBSection(hdcDst, bmi, DIB_RGB_COLORS, &bits, NULL, 0); ok(bmpSrc != NULL, "Couldn't create source bitmap\n"); oldDst = SelectObject(hdcDst, bmpDst); @@ -3240,26 +3361,179 @@ static void test_GdiAlphaBlend(void) blend.SourceConstantAlpha = 128; blend.AlphaFormat = 0; - expect_eq(pGdiAlphaBlend(hdcDst, 0, 0, 20, 20, hdcSrc, 0, 0, 20, 20, blend), TRUE, BOOL, "%d"); SetLastError(0xdeadbeef); - expect_eq(pGdiAlphaBlend(hdcDst, 0, 0, 20, 20, hdcSrc, -1, 0, 10, 10, blend), FALSE, BOOL, "%d"); - expect_eq(GetLastError(), ERROR_INVALID_PARAMETER, int, "%d"); - expect_eq(pGdiAlphaBlend(hdcDst, 0, 0, 20, 20, hdcSrc, 0, -1, 10, 10, blend), FALSE, BOOL, "%d"); - expect_eq(pGdiAlphaBlend(hdcDst, 0, 0, 20, 20, hdcSrc, 15, 0, 10, 10, blend), FALSE, BOOL, "%d"); - expect_eq(pGdiAlphaBlend(hdcDst, 0, 0, 20, 20, hdcSrc, 10, 10, -2, 3, blend), FALSE, BOOL, "%d"); - expect_eq(pGdiAlphaBlend(hdcDst, 0, 0, 20, 20, hdcSrc, 10, 10, -2, 3, blend), FALSE, BOOL, "%d"); + ret = pGdiAlphaBlend(hdcDst, 0, 0, 20, 20, hdcSrc, 0, 0, 20, 20, blend); + ok( ret, "GdiAlphaBlend failed err %u\n", GetLastError() ); + + SetLastError(0xdeadbeef); + ret = pGdiAlphaBlend(hdcDst, 0, 0, 20, 20, hdcSrc, -1, 0, 10, 10, blend); + ok( !ret, "GdiAlphaBlend succeeded\n" ); + ok( GetLastError() == ERROR_INVALID_PARAMETER, "wrong error %u\n", GetLastError() ); + + ret = pGdiAlphaBlend(hdcDst, 0, 0, 20, 20, hdcSrc, 0, -1, 10, 10, blend); + ok( !ret, "GdiAlphaBlend succeeded\n" ); + ret = pGdiAlphaBlend(hdcDst, 0, 0, 20, 20, hdcSrc, 15, 0, 10, 10, blend); + ok( !ret, "GdiAlphaBlend succeeded\n" ); + ret = pGdiAlphaBlend(hdcDst, 0, 0, 20, 20, hdcSrc, 10, 10, -2, 3, blend); + ok( !ret, "GdiAlphaBlend succeeded\n" ); + ret = pGdiAlphaBlend(hdcDst, 0, 0, 20, 20, hdcSrc, 10, 10, -2, 3, blend); + ok( !ret, "GdiAlphaBlend succeeded\n" ); SetWindowOrgEx(hdcSrc, -10, -10, NULL); - expect_eq(pGdiAlphaBlend(hdcDst, 0, 0, 20, 20, hdcSrc, -1, 0, 10, 10, blend), TRUE, BOOL, "%d"); - expect_eq(pGdiAlphaBlend(hdcDst, 0, 0, 20, 20, hdcSrc, 0, -1, 10, 10, blend), TRUE, BOOL, "%d"); + SetLastError(0xdeadbeef); + ret = pGdiAlphaBlend(hdcDst, 0, 0, 20, 20, hdcSrc, -1, 0, 10, 10, blend); + ok( ret, "GdiAlphaBlend failed err %u\n", GetLastError() ); + SetLastError(0xdeadbeef); + ret = pGdiAlphaBlend(hdcDst, 0, 0, 20, 20, hdcSrc, 0, -1, 10, 10, blend); + ok( ret, "GdiAlphaBlend failed err %u\n", GetLastError() ); SetMapMode(hdcSrc, MM_ANISOTROPIC); ScaleWindowExtEx(hdcSrc, 10, 1, 10, 1, NULL); - expect_eq(pGdiAlphaBlend(hdcDst, 0, 0, 20, 20, hdcSrc, -1, 0, 30, 30, blend), TRUE, BOOL, "%d"); - expect_eq(pGdiAlphaBlend(hdcDst, 0, 0, 20, 20, hdcSrc, 0, -1, 30, 30, blend), TRUE, BOOL, "%d"); + SetLastError(0xdeadbeef); + ret = pGdiAlphaBlend(hdcDst, 0, 0, 20, 20, hdcSrc, -1, 0, 30, 30, blend); + ok( ret, "GdiAlphaBlend failed err %u\n", GetLastError() ); + SetLastError(0xdeadbeef); + ret = pGdiAlphaBlend(hdcDst, 0, 0, 20, 20, hdcSrc, 0, -1, 30, 30, blend); + ok( ret, "GdiAlphaBlend failed err %u\n", GetLastError() ); + + SetMapMode(hdcDst, MM_ANISOTROPIC); + SetViewportExtEx(hdcDst, -1, -1, NULL); + SetLastError(0xdeadbeef); + ret = pGdiAlphaBlend(hdcDst, 0, 0, 20, 20, hdcSrc, 0, -1, 50, 50, blend); + ok( ret, "GdiAlphaBlend failed err %u\n", GetLastError() ); + SetLastError(0xdeadbeef); + ret = pGdiAlphaBlend(hdcDst, -20, -20, 20, 20, hdcSrc, 0, -1, 50, 50, blend); + ok( ret, "GdiAlphaBlend failed err %u\n", GetLastError() ); + SetLastError(0xdeadbeef); + ret = pGdiAlphaBlend(hdcDst, -20, -20, -20, -20, hdcSrc, 0, -1, 50, 50, blend); + ok( !ret, "GdiAlphaBlend succeeded\n" ); + ok( GetLastError() == ERROR_INVALID_PARAMETER, "wrong error %u\n", GetLastError() ); + SetLastError(0xdeadbeef); + ret = pGdiAlphaBlend(hdcDst, -20, 0, -20, 20, hdcSrc, 0, -1, 50, 50, blend); + ok( !ret, "GdiAlphaBlend succeeded\n" ); + ok( GetLastError() == ERROR_INVALID_PARAMETER, "wrong error %u\n", GetLastError() ); + SetLastError(0xdeadbeef); + ret = pGdiAlphaBlend(hdcDst, 0, -20, 20, -20, hdcSrc, 0, -1, 50, 50, blend); + ok( !ret, "GdiAlphaBlend succeeded\n" ); + ok( GetLastError() == ERROR_INVALID_PARAMETER, "wrong error %u\n", GetLastError() ); + SetMapMode(hdcDst, MM_TEXT); + + SetViewportExtEx(hdcSrc, -1, -1, NULL); + SetLastError(0xdeadbeef); + ret = pGdiAlphaBlend(hdcDst, 0, 0, 20, 20, hdcSrc, -20, -20, -30, -30, blend); + ok( !ret, "GdiAlphaBlend succeeded\n" ); + ok( GetLastError() == ERROR_INVALID_PARAMETER, "wrong error %u\n", GetLastError() ); + SetLastError(0xdeadbeef); + ret = pGdiAlphaBlend(hdcDst, 0, 0, 20, 20, hdcSrc, -20, -20, 30, -30, blend); + ok( !ret, "GdiAlphaBlend succeeded\n" ); + ok( GetLastError() == ERROR_INVALID_PARAMETER, "wrong error %u\n", GetLastError() ); + SetLastError(0xdeadbeef); + ret = pGdiAlphaBlend(hdcDst, 0, 0, 20, 20, hdcSrc, -20, -20, -30, 30, blend); + ok( !ret, "GdiAlphaBlend succeeded\n" ); + ok( GetLastError() == ERROR_INVALID_PARAMETER, "wrong error %u\n", GetLastError() ); + SetLastError(0xdeadbeef); + ret = pGdiAlphaBlend(hdcDst, 0, 0, 20, 20, hdcSrc, -20, -20, 30, 30, blend); + ok( !ret, "GdiAlphaBlend succeeded\n" ); + ok( GetLastError() == ERROR_INVALID_PARAMETER, "wrong error %u\n", GetLastError() ); + SetLastError(0xdeadbeef); + ret = pGdiAlphaBlend(hdcDst, 0, 0, 20, 20, hdcSrc, 20, 20, 30, 30, blend); + ok( !ret, "GdiAlphaBlend succeeded\n" ); + ok( GetLastError() == ERROR_INVALID_PARAMETER, "wrong error %u\n", GetLastError() ); + SetLastError(0xdeadbeef); + ret = pGdiAlphaBlend(hdcDst, 0, 0, 20, 20, hdcSrc, -60, -60, 30, 30, blend); + ok( !ret, "GdiAlphaBlend succeeded\n" ); + ok( GetLastError() == ERROR_INVALID_PARAMETER, "wrong error %u\n", GetLastError() ); + SetViewportExtEx(hdcSrc, 1, 1, NULL); SetLastError(0xdeadbeef); - expect_eq(pGdiAlphaBlend(hdcDst, 0, 0, 20, 20, NULL, 0, 0, 20, 20, blend), FALSE, BOOL, "%d"); - expect_eq(GetLastError(), 0xdeadbeef, int, "%d"); + ret = pGdiAlphaBlend(hdcDst, 0, 0, 20, 20, NULL, 0, 0, 20, 20, blend); + ok( !ret, "GdiAlphaBlend succeeded\n" ); + ok( GetLastError() == 0xdeadbeef, "wrong error %u\n", GetLastError() ); + + /* overlapping source and dest not allowed */ + + SetLastError(0xdeadbeef); + ret = pGdiAlphaBlend(hdcDst, 0, 0, 20, 20, hdcDst, 19, 19, 20, 20, blend); + ok( !ret, "GdiAlphaBlend succeeded\n" ); + ok( GetLastError() == ERROR_INVALID_PARAMETER, "wrong error %u\n", GetLastError() ); + + SetLastError(0xdeadbeef); + ret = pGdiAlphaBlend(hdcDst, 20, 20, 20, 20, hdcDst, 1, 1, 20, 20, blend); + ok( !ret, "GdiAlphaBlend succeeded\n" ); + ok( GetLastError() == ERROR_INVALID_PARAMETER, "wrong error %u\n", GetLastError() ); + + SetLastError(0xdeadbeef); + ret = pGdiAlphaBlend(hdcDst, 0, 0, 20, 20, hdcDst, 20, 10, 20, 20, blend); + ok( ret, "GdiAlphaBlend succeeded\n" ); + SetLastError(0xdeadbeef); + ret = pGdiAlphaBlend(hdcDst, 0, 0, 20, 20, hdcDst, 10, 20, 20, 20, blend); + ok( ret, "GdiAlphaBlend succeeded\n" ); + + /* AC_SRC_ALPHA requires 32-bpp BI_RGB format */ + + blend.AlphaFormat = AC_SRC_ALPHA; + SetLastError(0xdeadbeef); + ret = pGdiAlphaBlend(hdcDst, 0, 0, 20, 20, hdcSrc, 0, 0, 20, 20, blend); + ok( ret, "GdiAlphaBlend failed err %u\n", GetLastError() ); + + bmi->bmiHeader.biCompression = BI_BITFIELDS; + ((DWORD *)bmi->bmiColors)[0] = 0xff0000; + ((DWORD *)bmi->bmiColors)[1] = 0x00ff00; + ((DWORD *)bmi->bmiColors)[2] = 0x0000ff; + bmpSrc = CreateDIBSection(hdcDst, bmi, DIB_RGB_COLORS, &bits, NULL, 0); + ok(bmpSrc != NULL, "Couldn't create source bitmap\n"); + oldSrc = SelectObject(hdcSrc, bmpSrc); + DeleteObject( oldSrc ); + + SetLastError(0xdeadbeef); + ret = pGdiAlphaBlend(hdcDst, 0, 0, 20, 20, hdcSrc, 0, 0, 20, 20, blend); + ok( ret, "GdiAlphaBlend failed err %u\n", GetLastError() ); + + bmi->bmiHeader.biCompression = BI_BITFIELDS; + ((DWORD *)bmi->bmiColors)[0] = 0x0000ff; + ((DWORD *)bmi->bmiColors)[1] = 0x00ff00; + ((DWORD *)bmi->bmiColors)[2] = 0xff0000; + bmpSrc = CreateDIBSection(hdcDst, bmi, DIB_RGB_COLORS, &bits, NULL, 0); + ok(bmpSrc != NULL, "Couldn't create source bitmap\n"); + oldSrc = SelectObject(hdcSrc, bmpSrc); + DeleteObject( oldSrc ); + + SetLastError(0xdeadbeef); + ret = pGdiAlphaBlend(hdcDst, 0, 0, 20, 20, hdcSrc, 0, 0, 20, 20, blend); + ok( !ret, "GdiAlphaBlend succeeded\n" ); + ok( GetLastError() == ERROR_INVALID_PARAMETER, "wrong error %u\n", GetLastError() ); + + bmi->bmiHeader.biBitCount = 24; + bmi->bmiHeader.biCompression = BI_RGB; + bmpSrc = CreateDIBSection(hdcDst, bmi, DIB_RGB_COLORS, &bits, NULL, 0); + ok(bmpSrc != NULL, "Couldn't create source bitmap\n"); + oldSrc = SelectObject(hdcSrc, bmpSrc); + DeleteObject( oldSrc ); + + SetLastError(0xdeadbeef); + ret = pGdiAlphaBlend(hdcDst, 0, 0, 20, 20, hdcSrc, 0, 0, 20, 20, blend); + ok( !ret, "GdiAlphaBlend succeeded\n" ); + ok( GetLastError() == ERROR_INVALID_PARAMETER, "wrong error %u\n", GetLastError() ); + + bmi->bmiHeader.biBitCount = 1; + bmpSrc = CreateDIBSection(hdcDst, bmi, DIB_RGB_COLORS, &bits, NULL, 0); + ok(bmpSrc != NULL, "Couldn't create source bitmap\n"); + oldSrc = SelectObject(hdcSrc, bmpSrc); + DeleteObject( oldSrc ); + + SetLastError(0xdeadbeef); + ret = pGdiAlphaBlend(hdcDst, 0, 0, 20, 20, hdcSrc, 0, 0, 20, 20, blend); + ok( !ret, "GdiAlphaBlend succeeded\n" ); + ok( GetLastError() == ERROR_INVALID_PARAMETER, "wrong error %u\n", GetLastError() ); + + bmpSrc = CreateBitmap( 100, 100, 1, 1, NULL ); + ok(bmpSrc != NULL, "Couldn't create source bitmap\n"); + oldSrc = SelectObject(hdcSrc, bmpSrc); + DeleteObject( oldSrc ); + + SetLastError(0xdeadbeef); + ret = pGdiAlphaBlend(hdcDst, 0, 0, 20, 20, hdcSrc, 0, 0, 20, 20, blend); + ok( !ret, "GdiAlphaBlend succeeded\n" ); + ok( GetLastError() == ERROR_INVALID_PARAMETER, "wrong error %u\n", GetLastError() ); SelectObject(hdcDst, oldDst); SelectObject(hdcSrc, oldSrc); @@ -3272,6 +3546,118 @@ static void test_GdiAlphaBlend(void) } +static void test_GdiGradientFill(void) +{ + HDC hdc; + BOOL ret; + HBITMAP bmp; + BITMAPINFO *bmi; + void *bits; + GRADIENT_RECT rect[] = { { 0, 0 }, { 0, 1 }, { 2, 3 } }; + GRADIENT_TRIANGLE tri[] = { { 0, 0, 0 }, { 0, 1, 2 }, { 0, 2, 1 }, { 0, 1, 3 } }; + TRIVERTEX vt[3] = { { 2, 2, 0xff00, 0x0000, 0x0000, 0x8000 }, + { 10, 10, 0x0000, 0xff00, 0x0000, 0x8000 }, + { 20, 10, 0x0000, 0x0000, 0xff00, 0xff00 } }; + + if (!pGdiGradientFill) + { + win_skip( "GdiGradientFill is not implemented\n" ); + return; + } + + hdc = CreateCompatibleDC( NULL ); + bmi = HeapAlloc( GetProcessHeap(), HEAP_ZERO_MEMORY, FIELD_OFFSET( BITMAPINFO, bmiColors[3] )); + bmi->bmiHeader.biSize = sizeof(bmi->bmiHeader); + bmi->bmiHeader.biHeight = 20; + bmi->bmiHeader.biWidth = 20; + bmi->bmiHeader.biBitCount = 32; + bmi->bmiHeader.biPlanes = 1; + bmi->bmiHeader.biCompression = BI_RGB; + bmp = CreateDIBSection(hdc, bmi, DIB_RGB_COLORS, &bits, NULL, 0); + ok( bmp != NULL, "couldn't create bitmap\n" ); + SelectObject( hdc, bmp ); + + SetLastError( 0xdeadbeef ); + ret = pGdiGradientFill( hdc, vt, 3, rect, 1, GRADIENT_FILL_RECT_H ); + ok( ret, "GdiGradientFill failed err %u\n", GetLastError() ); + SetLastError( 0xdeadbeef ); + ret = pGdiGradientFill( hdc, vt, 3, rect, 1, 3 ); + ok( !ret, "GdiGradientFill succeeded\n" ); + ok( GetLastError() == ERROR_INVALID_PARAMETER, "wrong error %u\n", GetLastError() ); + SetLastError( 0xdeadbeef ); + ret = pGdiGradientFill( (HDC)0xdead, vt, 3, rect, 1, GRADIENT_FILL_RECT_H ); + ok( !ret, "GdiGradientFill succeeded\n" ); + ok( GetLastError() == ERROR_INVALID_PARAMETER, "wrong error %u\n", GetLastError() ); + SetLastError( 0xdeadbeef ); + ret = pGdiGradientFill( NULL, NULL, 0, rect, 1, GRADIENT_FILL_RECT_H ); + ok( !ret, "GdiGradientFill succeeded\n" ); + ok( GetLastError() == ERROR_INVALID_PARAMETER, "wrong error %u\n", GetLastError() ); + ret = pGdiGradientFill( hdc, NULL, 0, rect, 1, GRADIENT_FILL_RECT_H ); + ok( !ret, "GdiGradientFill succeeded\n" ); + ok( GetLastError() == ERROR_INVALID_PARAMETER, "wrong error %u\n", GetLastError() ); + SetLastError( 0xdeadbeef ); + ret = pGdiGradientFill( hdc, NULL, 3, rect, 1, GRADIENT_FILL_RECT_H ); + ok( !ret, "GdiGradientFill succeeded\n" ); + ok( GetLastError() == ERROR_INVALID_PARAMETER, "wrong error %u\n", GetLastError() ); + SetLastError( 0xdeadbeef ); + ret = pGdiGradientFill( hdc, vt, 3, NULL, 0, GRADIENT_FILL_RECT_H ); + ok( !ret, "GdiGradientFill succeeded\n" ); + ok( GetLastError() == ERROR_INVALID_PARAMETER, "wrong error %u\n", GetLastError() ); + SetLastError( 0xdeadbeef ); + ret = pGdiGradientFill( hdc, vt, 3, NULL, 1, GRADIENT_FILL_RECT_H ); + ok( !ret, "GdiGradientFill succeeded\n" ); + ok( GetLastError() == ERROR_INVALID_PARAMETER, "wrong error %u\n", GetLastError() ); + SetLastError( 0xdeadbeef ); + ret = pGdiGradientFill( hdc, vt, 3, rect, 0, GRADIENT_FILL_RECT_H ); + ok( !ret, "GdiGradientFill succeeded\n" ); + ok( GetLastError() == ERROR_INVALID_PARAMETER, "wrong error %u\n", GetLastError() ); + SetLastError( 0xdeadbeef ); + ret = pGdiGradientFill( hdc, vt, 3, rect, 3, GRADIENT_FILL_RECT_H ); + ok( !ret, "GdiGradientFill succeeded\n" ); + ok( GetLastError() == 0xdeadbeef, "wrong error %u\n", GetLastError() ); + rect[2].UpperLeft = rect[2].LowerRight = 1; + SetLastError( 0xdeadbeef ); + ret = pGdiGradientFill( hdc, vt, 3, rect, 3, GRADIENT_FILL_RECT_H ); + ok( ret, "GdiGradientFill failed err %u\n", GetLastError() ); + SetLastError( 0xdeadbeef ); + ret = pGdiGradientFill( hdc, vt, 1, rect, 1, GRADIENT_FILL_RECT_H ); + ok( ret, "GdiGradientFill failed err %u\n", GetLastError() ); + SetLastError( 0xdeadbeef ); + ret = pGdiGradientFill( hdc, vt, 1, tri, 0, GRADIENT_FILL_TRIANGLE ); + ok( !ret, "GdiGradientFill succeeded\n" ); + ok( GetLastError() == ERROR_INVALID_PARAMETER, "wrong error %u\n", GetLastError() ); + SetLastError( 0xdeadbeef ); + ret = pGdiGradientFill( hdc, vt, 1, tri, 1, GRADIENT_FILL_TRIANGLE ); + ok( ret, "GdiGradientFill failed err %u\n", GetLastError() ); + SetLastError( 0xdeadbeef ); + ret = pGdiGradientFill( hdc, vt, 3, tri, 2, GRADIENT_FILL_TRIANGLE ); + ok( ret, "GdiGradientFill failed err %u\n", GetLastError() ); + SetLastError( 0xdeadbeef ); + ret = pGdiGradientFill( hdc, vt, 3, tri, 3, GRADIENT_FILL_TRIANGLE ); + ok( ret, "GdiGradientFill failed err %u\n", GetLastError() ); + SetLastError( 0xdeadbeef ); + ret = pGdiGradientFill( hdc, vt, 3, tri, 4, GRADIENT_FILL_TRIANGLE ); + ok( !ret, "GdiGradientFill succeeded\n" ); + ok( GetLastError() == 0xdeadbeef, "wrong error %u\n", GetLastError() ); + tri[3].Vertex3 = 1; + SetLastError( 0xdeadbeef ); + ret = pGdiGradientFill( hdc, vt, 3, tri, 4, GRADIENT_FILL_TRIANGLE ); + ok( !ret, "GdiGradientFill succeeded\n" ); + ok( GetLastError() == 0xdeadbeef, "wrong error %u\n", GetLastError() ); + tri[3].Vertex3 = 0; + SetLastError( 0xdeadbeef ); + ret = pGdiGradientFill( hdc, vt, 3, tri, 4, GRADIENT_FILL_TRIANGLE ); + ok( !ret, "GdiGradientFill succeeded\n" ); + ok( GetLastError() == 0xdeadbeef, "wrong error %u\n", GetLastError() ); + tri[3].Vertex1 = tri[3].Vertex2 = tri[3].Vertex3 = 1; + SetLastError( 0xdeadbeef ); + ret = pGdiGradientFill( hdc, vt, 3, tri, 4, GRADIENT_FILL_TRIANGLE ); + ok( ret, "GdiGradientFill failed err %u\n", GetLastError() ); + + DeleteDC( hdc ); + DeleteObject( bmp ); +} + static void test_clipping(void) { HBITMAP bmpDst; @@ -3315,22 +3701,24 @@ static void test_clipping(void) DeleteDC( hdcSrc ); } -static void test_32bit_bitmap_blt(void) +static void test_32bit_ddb(void) { - BITMAPINFO biDst; + char buffer[sizeof(BITMAPINFOHEADER) + sizeof(DWORD)]; + BITMAPINFO *biDst = (BITMAPINFO *)buffer; HBITMAP bmpSrc, bmpDst; HBITMAP oldSrc, oldDst; HDC hdcSrc, hdcDst, hdcScreen; - UINT32 *dstBuffer; - DWORD colorSrc = 0x11223344; + HBRUSH brush; + DWORD *dstBuffer, *data; + DWORD colorSrc = 0x40201008; - memset(&biDst, 0, sizeof(BITMAPINFO)); - biDst.bmiHeader.biSize = sizeof(BITMAPINFOHEADER); - biDst.bmiHeader.biWidth = 2; - biDst.bmiHeader.biHeight = -2; - biDst.bmiHeader.biPlanes = 1; - biDst.bmiHeader.biBitCount = 32; - biDst.bmiHeader.biCompression = BI_RGB; + memset(biDst, 0, sizeof(BITMAPINFOHEADER)); + biDst->bmiHeader.biSize = sizeof(BITMAPINFOHEADER); + biDst->bmiHeader.biWidth = 1; + biDst->bmiHeader.biHeight = -1; + biDst->bmiHeader.biPlanes = 1; + biDst->bmiHeader.biBitCount = 32; + biDst->bmiHeader.biCompression = BI_RGB; hdcScreen = CreateCompatibleDC(0); if(GetDeviceCaps(hdcScreen, BITSPIXEL) != 32) @@ -3345,12 +3733,54 @@ static void test_32bit_bitmap_blt(void) oldSrc = SelectObject(hdcSrc, bmpSrc); hdcDst = CreateCompatibleDC(hdcScreen); - bmpDst = CreateDIBSection(hdcDst, &biDst, DIB_RGB_COLORS, (void**)&dstBuffer, NULL, 0); + bmpDst = CreateDIBSection(hdcDst, biDst, DIB_RGB_COLORS, (void**)&dstBuffer, NULL, 0); oldDst = SelectObject(hdcDst, bmpDst); StretchBlt(hdcDst, 0, 0, 1, 1, hdcSrc, 0, 0, 1, 1, SRCCOPY); ok(dstBuffer[0] == colorSrc, "Expected color=%x, received color=%x\n", colorSrc, dstBuffer[0]); + if (pGdiAlphaBlend) + { + BLENDFUNCTION blend; + BOOL ret; + + blend.BlendOp = AC_SRC_OVER; + blend.BlendFlags = 0; + blend.SourceConstantAlpha = 128; + blend.AlphaFormat = 0; + dstBuffer[0] = 0x80808080; + ret = pGdiAlphaBlend( hdcDst, 0, 0, 1, 1, hdcSrc, 0, 0, 1, 1, blend ); + ok( ret, "GdiAlphaBlend failed err %u\n", GetLastError() ); + ok(dstBuffer[0] == 0x60504844, "wrong color %x\n", dstBuffer[0]); + blend.AlphaFormat = AC_SRC_ALPHA; + dstBuffer[0] = 0x80808080; + ret = pGdiAlphaBlend( hdcDst, 0, 0, 1, 1, hdcSrc, 0, 0, 1, 1, blend ); + ok( ret, "GdiAlphaBlend failed err %u\n", GetLastError() ); + ok(dstBuffer[0] == 0x90807874, "wrong color %x\n", dstBuffer[0]); + } + + data = (DWORD *)biDst->bmiColors; + data[0] = 0x20304050; + brush = CreateDIBPatternBrushPt( biDst, DIB_RGB_COLORS ); + ok( brush != 0, "brush creation failed\n" ); + SelectObject( hdcSrc, brush ); + PatBlt( hdcSrc, 0, 0, 1, 1, PATCOPY ); + BitBlt( hdcDst, 0, 0, 1, 1, hdcSrc, 0, 0, SRCCOPY ); + ok(dstBuffer[0] == data[0], "Expected color=%x, received color=%x\n", data[0], dstBuffer[0]); + SelectObject( hdcSrc, GetStockObject(BLACK_BRUSH) ); + DeleteObject( brush ); + + biDst->bmiHeader.biBitCount = 24; + brush = CreateDIBPatternBrushPt( biDst, DIB_RGB_COLORS ); + ok( brush != 0, "brush creation failed\n" ); + SelectObject( hdcSrc, brush ); + PatBlt( hdcSrc, 0, 0, 1, 1, PATCOPY ); + BitBlt( hdcDst, 0, 0, 1, 1, hdcSrc, 0, 0, SRCCOPY ); + ok(dstBuffer[0] == (data[0] & ~0xff000000), + "Expected color=%x, received color=%x\n", data[0] & 0xff000000, dstBuffer[0]); + SelectObject( hdcSrc, GetStockObject(BLACK_BRUSH) ); + DeleteObject( brush ); + /* Tidy up */ SelectObject(hdcDst, oldDst); DeleteObject(bmpDst); @@ -3864,6 +4294,10 @@ static void test_GetDIBits_scanlines(void) static void test_SetDIBits(void) { + char palbuf[sizeof(LOGPALETTE) + 256 * sizeof(PALETTEENTRY)]; + LOGPALETTE *pal = (LOGPALETTE *)palbuf; + PALETTEENTRY *palent = pal->palPalEntry; + HPALETTE palette; BITMAPINFO *info; DWORD *dib_bits; HDC hdc = GetDC( NULL ); @@ -4032,8 +4466,62 @@ static void test_SetDIBits(void) for (i = 32; i < 64; i++) ok( dib_bits[i] == 0xaaaaaaaa, "%d: got %08x\n", i, dib_bits[i] ); memset( dib_bits, 0xaa, 64 * 4 ); - DeleteObject( dib ); + /* handling of partial color table */ + + info->bmiHeader.biHeight = -8; + info->bmiHeader.biBitCount = 8; + info->bmiHeader.biClrUsed = 137; + for (i = 0; i < 256; i++) + { + info->bmiColors[i].rgbRed = 255 - i; + info->bmiColors[i].rgbGreen = i * 2; + info->bmiColors[i].rgbBlue = i; + info->bmiColors[i].rgbReserved = 0; + } + for (i = 0; i < 64; i++) ((BYTE *)data)[i] = i * 4 + 1; + ret = SetDIBits( hdc, dib, 0, 8, data, info, DIB_RGB_COLORS ); + ok( ret == 8, "got %d\n", ret ); + for (i = 0; i < 64; i++) + { + int idx = i * 4 + 1; + DWORD expect = idx >= info->bmiHeader.biClrUsed ? 0 : (info->bmiColors[idx].rgbRed << 16 | + info->bmiColors[idx].rgbGreen << 8 | + info->bmiColors[idx].rgbBlue); + ok( dib_bits[i] == expect, "%d: got %08x instead of %08x\n", i, dib_bits[i], expect ); + } + memset( dib_bits, 0xaa, 64 * 4 ); + + /* handling of DIB_PAL_COLORS */ + + pal->palVersion = 0x300; + pal->palNumEntries = 137; + info->bmiHeader.biClrUsed = 221; + for (i = 0; i < 256; i++) + { + palent[i].peRed = i * 2; + palent[i].peGreen = 255 - i; + palent[i].peBlue = i; + } + palette = CreatePalette( pal ); + ok( palette != 0, "palette creation failed\n" ); + SelectPalette( hdc, palette, FALSE ); + for (i = 0; i < 256; i++) ((WORD *)info->bmiColors)[i] = 255 - i; + ret = SetDIBits( hdc, dib, 0, 8, data, info, DIB_PAL_COLORS ); + ok( ret == 8, "got %d\n", ret ); + for (i = 0; i < 64; i++) + { + int idx = i * 4 + 1; + int ent = (255 - idx) % pal->palNumEntries; + DWORD expect = idx >= info->bmiHeader.biClrUsed ? 0 : + (palent[ent].peRed << 16 | palent[ent].peGreen << 8 | palent[ent].peBlue); + ok( dib_bits[i] == expect || broken(dib_bits[i] == 0), /* various Windows versions get some values wrong */ + "%d: got %08x instead of %08x\n", i, dib_bits[i], expect ); + } + memset( dib_bits, 0xaa, 64 * 4 ); + ReleaseDC( NULL, hdc ); + DeleteObject( dib ); + DeleteObject( palette ); HeapFree( GetProcessHeap(), 0, info ); } @@ -4244,6 +4732,10 @@ static void test_SetDIBits_RLE8(void) static void test_SetDIBitsToDevice(void) { + char palbuf[sizeof(LOGPALETTE) + 256 * sizeof(PALETTEENTRY)]; + LOGPALETTE *pal = (LOGPALETTE *)palbuf; + PALETTEENTRY *palent = pal->palPalEntry; + HPALETTE palette; BITMAPINFO *info; DWORD *dib_bits; HDC hdc = CreateCompatibleDC( 0 ); @@ -4602,8 +5094,62 @@ static void test_SetDIBitsToDevice(void) for (i = 0; i < 64; i++) ok( dib_bits[i] == 0xaaaaaaaa, "%d: got %08x\n", i, dib_bits[i] ); memset( dib_bits, 0xaa, 64 * 4 ); + /* handling of partial color table */ + + info->bmiHeader.biHeight = -8; + info->bmiHeader.biBitCount = 8; + info->bmiHeader.biClrUsed = 137; + for (i = 0; i < 256; i++) + { + info->bmiColors[i].rgbRed = 255 - i; + info->bmiColors[i].rgbGreen = i * 2; + info->bmiColors[i].rgbBlue = i; + info->bmiColors[i].rgbReserved = 0; + } + for (i = 0; i < 64; i++) ((BYTE *)data)[i] = i * 4 + 1; + ret = SetDIBitsToDevice( hdc, 0, 0, 8, 8, 0, 0, 0, 8, data, info, DIB_RGB_COLORS ); + ok( ret == 8, "got %d\n", ret ); + for (i = 0; i < 64; i++) + { + int idx = i * 4 + 1; + DWORD expect = idx >= info->bmiHeader.biClrUsed ? 0 : (info->bmiColors[idx].rgbRed << 16 | + info->bmiColors[idx].rgbGreen << 8 | + info->bmiColors[idx].rgbBlue); + ok( dib_bits[i] == expect, "%d: got %08x instead of %08x\n", i, dib_bits[i], expect ); + } + memset( dib_bits, 0xaa, 64 * 4 ); + + /* handling of DIB_PAL_COLORS */ + + pal->palVersion = 0x300; + pal->palNumEntries = 137; + info->bmiHeader.biClrUsed = 221; + for (i = 0; i < 256; i++) + { + palent[i].peRed = i * 2; + palent[i].peGreen = 255 - i; + palent[i].peBlue = i; + } + palette = CreatePalette( pal ); + ok( palette != 0, "palette creation failed\n" ); + SelectPalette( hdc, palette, FALSE ); + for (i = 0; i < 256; i++) ((WORD *)info->bmiColors)[i] = 255 - i; + ret = SetDIBitsToDevice( hdc, 0, 0, 8, 8, 0, 0, 0, 8, data, info, DIB_PAL_COLORS ); + ok( ret == 8, "got %d\n", ret ); + for (i = 0; i < 64; i++) + { + int idx = i * 4 + 1; + int ent = (255 - idx) % pal->palNumEntries; + DWORD expect = idx >= info->bmiHeader.biClrUsed ? 0 : + (palent[ent].peRed << 16 | palent[ent].peGreen << 8 | palent[ent].peBlue); + ok( dib_bits[i] == expect || broken(dib_bits[i] == 0), + "%d: got %08x instead of %08x\n", i, dib_bits[i], expect ); + } + memset( dib_bits, 0xaa, 64 * 4 ); + DeleteDC( hdc ); DeleteObject( dib ); + DeleteObject( palette ); HeapFree( GetProcessHeap(), 0, info ); } @@ -4833,8 +5379,9 @@ START_TEST(bitmap) HMODULE hdll; hdll = GetModuleHandle("gdi32.dll"); - pGdiAlphaBlend = (void*)GetProcAddress(hdll, "GdiAlphaBlend"); - pSetLayout = (void*)GetProcAddress(hdll, "SetLayout"); + pGdiAlphaBlend = (void*)GetProcAddress(hdll, "GdiAlphaBlend"); + pGdiGradientFill = (void*)GetProcAddress(hdll, "GdiGradientFill"); + pSetLayout = (void*)GetProcAddress(hdll, "SetLayout"); test_createdibitmap(); test_dibsections(); @@ -4855,7 +5402,8 @@ START_TEST(bitmap) test_StretchBlt(); test_StretchDIBits(); test_GdiAlphaBlend(); - test_32bit_bitmap_blt(); + test_GdiGradientFill(); + test_32bit_ddb(); test_bitmapinfoheadersize(); test_get16dibits(); test_clipping(); diff --git a/rostests/winetests/gdi32/dib.c b/rostests/winetests/gdi32/dib.c index e8694bbf01b..38d1ee8ef78 100644 --- a/rostests/winetests/gdi32/dib.c +++ b/rostests/winetests/gdi32/dib.c @@ -27,6 +27,7 @@ #include "wingdi.h" #include "winuser.h" #include "wincrypt.h" +#include "mmsystem.h" /* DIBINDEX */ #include "wine/test.h" @@ -35,6 +36,8 @@ #endif static HCRYPTPROV crypt_prov; +static BOOL (WINAPI *pGdiAlphaBlend)(HDC,int,int,int,int,HDC,int,int,int,int,BLENDFUNCTION); +static BOOL (WINAPI *pGdiGradientFill)(HDC,TRIVERTEX*,ULONG,void*,ULONG,ULONG); static DWORD (WINAPI *pSetLayout)(HDC hdc, DWORD layout); static const DWORD rop3[256] = @@ -102,6 +105,7 @@ static const char *sha1_graphics_a8r8g8b8[] = "a78b28472bb7ff480ddedd06b9cf2daa775fa7ae", "5246ef357e7317b9d141a3294d300c195da76cb7", "87f6b6a19f021ca5912d285e14ce2ff9474d79f3", + "3d8244b665ecdb104087bad171b0b0f83545133c", "e2a8eef4aeda3a0f6c950075acba38f1f9e0814d", "8b66f14d51ecdeea12bc993302bb9b7d3ec085a1", "7da9dd3d40d44d92deb9883fb7110443c2d5769a", @@ -116,6 +120,110 @@ static const char *sha1_graphics_a8r8g8b8[] = "94645300d6eb51020a7ef8261dee2941cd51b5df", "c56f5bdc9cac4f0bc81c33295d9aed8eaf4cb1f2", "21cdfde38ac7edbb241ec83d82f31286e90c4629", + "1fd2f4dcb62f8522171872e43fd4a35041d68100", + "68c18db6abfda626cab12d198298d4c39264bfbc", + "6b59ae6c20749020ad43175e05110dc33b6a59b5", + "39c31de73aafcfcadf0bf414da4495be9de54417", + "132949f59bfeb88dc2047e6eaecb8512aea3d9ab", + "f6a6d765bf23726329f96020ba8c5e3c0897aafa", + "a7aa311cdc6137f15b9ef9cb1a92ac54ec02f058", + "e71d6bb9bd38eea5719f8ba57177997910e2d841", + "3d2ccbe51408232a04769546b1bdd74f84558a41", + "a1fe9aa885584a0f713d7c6f76c89830fbf28563", + "d7085333becdec7759a5229e5fe9ba1e11db0c22", + "aaf62842bb98d8a2945c4f643baf50afaeea9307", + "287b2f2f2fb5a1d7ee4a29b43342103d78a7a8ab", + "d7dd4700f49808541bba99244b7eb5840e0a2439", + "af99228aa4cfbd1f61bd824db046144a3c6c2ed7", + "568f87f0194ca19b69a5b2bcdef795d89c5721ce", + "50d19fe68b2ab4fdbb5d590cdca6dc84a95bab68", + "a1fde1094d2c19ddb20871842dae1da73618709e", + "e462052a03dbe4ec3814db7700e166d00d4d686f", + "a27917d4db49ce77989fae246015aeb2a28520ee", + "657514a4ca1f2b6ca7a125ad58dfed82099a37d1", + "5e0549fdcf0fc7c50054dccc51d37fc734ab8134", + "eca1998a4d79fb81b2a4103f79e3b846a864eaaf", + "e4acfcf2d001fbc431d9af59ab3d3ca7c2d965e5", + "2b3198bd5c0a87db5dab13df8bbe14363d02acec", + "f115ef8392ba82d8cd6e7a039320edcd812c1d28", + "aebb1b3baa4fd5213bf80a5ad7a50d54de8fdba4", + "f451a05f699ac3bbe155d059e7871a2636887b5f", + "5dca709c60e0cd50fa85274a2836aec9eb6168e3", + "dccaef62738ff90da4554a85d8cb846d6436799e", + "cc4e1372ddf6e303a7fd159090c9d3a1f8ec2a89", + NULL +}; + +static const char *sha1_graphics_a8r8g8b8_bitfields[] = +{ + "a3cadd34d95d3d5cc23344f69aab1c2e55935fcf", + "2426172d9e8fec27d9228088f382ef3c93717da9", + "9e8f27ca952cdba01dbf25d07c34e86a7820c012", + "664fac17803859a4015c6ae29e5538e314d5c827", + "17b2c177bdce5e94433574a928bda5c94a8cdfa5", + "fe6cc678fb13a3ead67839481bf22348adc69f52", + "d51bd330cec510cdccf5394328bd8e5411901e9e", + "df4aebf98d91f11be560dd232123b3ae327303d7", + "f2af53dd073a09b1031d0032d28da35c82adc566", + "eb5a963a6f7b25533ddfb8915e70865d037bd156", + "c387917268455017aa0b28bed73aa6554044bbb3", + "dcae44fee010dbf7a107797a503923fd8b1abe2e", + "6c530622a025d872a642e8f950867884d7b136cb", + "7c07d91b8f68fb31821701b3dcb96de018bf0c66", + "b2261353decda2712b83538ab434a49ce21f3172", + "35f731c0f6356b8f30651bb3cbe0d922c49deba5", + "9b9874c1c1d92afa554137e191d34ea33acc322f", + "c311dd74325e8cebfc8529a6d24a6fa4ecb7137e", + "d7398de15b2837a58a62a701ca1b3384625afec4", + "a78b28472bb7ff480ddedd06b9cf2daa775fa7ae", + "5246ef357e7317b9d141a3294d300c195da76cb7", + "87f6b6a19f021ca5912d285e14ce2ff9474d79f3", + "3d8244b665ecdb104087bad171b0b0f83545133c", + "e2a8eef4aeda3a0f6c950075acba38f1f9e0814d", + "8b66f14d51ecdeea12bc993302bb9b7d3ec085a1", + "7da9dd3d40d44d92deb9883fb7110443c2d5769a", + "e358efb1c11172e40855de620bdb8a8e545cd790", + "9e0c2596c6ecb4f1bc97b18ec3ca493d37626608", + "58806549380c964e7a53ad54821d2eb86fa5b9ce", + "7fc30d3058c235ce39088de0a598b8c7fe7ca61f", + "52a6c769c227f2bb1949097c4c87fed5ee0cbcb1", + "8a010d4c5af51fcc34d51be3197878782bdf63e7", + "c84c2c33e22eb7e5c4a2faad3b3b99a359d77528", + "41bcc1f57c60bdec3c4d1e749084a12867f91224", + "94645300d6eb51020a7ef8261dee2941cd51b5df", + "c56f5bdc9cac4f0bc81c33295d9aed8eaf4cb1f2", + "21cdfde38ac7edbb241ec83d82f31286e90c4629", + "1fd2f4dcb62f8522171872e43fd4a35041d68100", + "68c18db6abfda626cab12d198298d4c39264bfbc", + "6b59ae6c20749020ad43175e05110dc33b6a59b5", + "39c31de73aafcfcadf0bf414da4495be9de54417", + "132949f59bfeb88dc2047e6eaecb8512aea3d9ab", + "f6a6d765bf23726329f96020ba8c5e3c0897aafa", + "a7aa311cdc6137f15b9ef9cb1a92ac54ec02f058", + "e71d6bb9bd38eea5719f8ba57177997910e2d841", + "3d2ccbe51408232a04769546b1bdd74f84558a41", + "a1fe9aa885584a0f713d7c6f76c89830fbf28563", + "d7085333becdec7759a5229e5fe9ba1e11db0c22", + "aaf62842bb98d8a2945c4f643baf50afaeea9307", + "287b2f2f2fb5a1d7ee4a29b43342103d78a7a8ab", + "d7dd4700f49808541bba99244b7eb5840e0a2439", + "af99228aa4cfbd1f61bd824db046144a3c6c2ed7", + "568f87f0194ca19b69a5b2bcdef795d89c5721ce", + "50d19fe68b2ab4fdbb5d590cdca6dc84a95bab68", + "a1fde1094d2c19ddb20871842dae1da73618709e", + "0cda6b3297003b3ccd6d5baa17e1ca9bb7c56f08", + "b2c8e1ebb9435031fe068442f479d1304096e79f", + "657514a4ca1f2b6ca7a125ad58dfed82099a37d1", + "5e0549fdcf0fc7c50054dccc51d37fc734ab8134", + "eca1998a4d79fb81b2a4103f79e3b846a864eaaf", + "e4acfcf2d001fbc431d9af59ab3d3ca7c2d965e5", + "e4f110504dd3e4e34f960a39ba91a91c67bf26af", + "f115ef8392ba82d8cd6e7a039320edcd812c1d28", + "aebb1b3baa4fd5213bf80a5ad7a50d54de8fdba4", + "f451a05f699ac3bbe155d059e7871a2636887b5f", + "5dca709c60e0cd50fa85274a2836aec9eb6168e3", + "dccaef62738ff90da4554a85d8cb846d6436799e", + "cc4e1372ddf6e303a7fd159090c9d3a1f8ec2a89", NULL }; @@ -143,6 +251,7 @@ static const char *sha1_graphics_a8b8g8r8[] = "473a1fd07df800c87a5d3286b642ace10c61c6af", "10cd25a0ed5cd8f978d7d68236f81d949b938e84", "b8951d2b20518fd129e5113a5f429626893913bf", + "e81fc45962f861d53f420e29cb5d33faf5adbec8", "4851c5b7d5bc18590e787c0c218a592ef504e738", "9aa506e3df33e0d5298755aa4144e10eb4b5adcf", "abdf003699364fe45fab7dc61e67c606d0063b40", @@ -157,6 +266,183 @@ static const char *sha1_graphics_a8b8g8r8[] = "19b32a0daa91201725b5e13820c343d0a84ff698", "abca6a80a99b05722d2d87ce2a8b94ef1ae549e1", "2ba70994d0b4ce87fdf6fbc33ada11252178061e", + "7b4e1d47a03e2cec236d8fb6e2ae89d8ed078f79", + "075c4cb50e2cf96ab5d132c9f7bb1c1deb4735bd", + "8566c1110ab5cb8f754787b47923c8bff38f790c", + "89e90d6159d59886bbbf0c40a7cd01293c3cfda3", + "3a598f1eb35c1412b0c131e9d9e36a4aef9534d2", + "d01071c44259adc94b89978b7d51a058b6dad665", + "e6d33b106bcda374e662d338c57a457dbcaa108a", + "27ef47377e88f5ac5ad33b19eae27d56c456ac65", + "339908a568f384e1f384a3e1b0dd415779203b02", + "88fd743d00bd37d2ed722092146795b044d08a6e", + "c0537ec24147e74939219213d864ee113cad9967", + "118bf4c5bddc206ba737f7aa8b239940cd1aadc2", + "7cb51f6c5f1dae926601986c934533df5f8baa9f", + "86c84cc8306975edecc6d4a89a8aff29f59b55a7", + "af99228aa4cfbd1f61bd824db046144a3c6c2ed7", + "25675c30adfe24d6cae60793b156dfdaa36ac3ba", + "1cb1810b127f509117b38d62a15b67b2347b9145", + "f05b3294f25de5fa6d1114104bca97871052ea5a", + "87f57a31253a38dbf3dc3070473328fa04b68a48", + "db64cc4d830fc35ed170b53943e722b2342954d4", + "9988ceca44dafbee247aece1f027c06c27c01652", + "d80d45a97bc877b50ba2c3f720d5197f2f1c5fc5", + "b76e0724496e471b01ef8b34f8beba69f5bde261", + "34201d3d3583f89ce3267d3d0c4e01c64463de4b", + "693f5c5fbaeaadb5928d34b035499626fecb8394", + "8a9aa84c42dedc3e681191a1229846887ed262ec", + "66041875232f64dbfd2d18353aa28e43e8ccb6b5", + "707bc44fc9fed68ff1f537f0473e0cd825dd660f", + "f19f5d8e2c96328f06f3985d02ff474fa37b1ea8", + "175a7bcb73c74eceecc000657a0100bccf158ff4", + "d26eeb6b2d345b587d4305a1234ec0842a96d4b6", + NULL +}; + +static const char *sha1_graphics_r10g10b10[] = +{ + "a3cadd34d95d3d5cc23344f69aab1c2e55935fcf", + "b340b5d4750dd3dcd95d73c41b2c3a17f799210b", + "b1db68f35022c5fd43519ec8e98047e16bc4fff8", + "6e1902eb24865e74066fa9f2a7a49e6f9154f62f", + "35df9f4b0965fedf7bca36aa4f17b0fa20e2cd03", + "5652e1feb7d4f22c8a2721fd141157e0b9ef965e", + "22d89d5933f8b9bd60e9b22e42e7f5659269b63d", + "0ad27de0c916c073d0d18484fff899bbdb258db7", + "7c05ee5a01dad1e187537701a95382f0a3ec28dc", + "b00f0b4448be722d1a19ffe33aaaac4df848d397", + "7e5ce5c05a54e83890f022ba4e9853e4b254bf0c", + "2986b431a0022153e5f875da77cc792e3825ebd5", + "ca4b25a5459885ce1e0a36844612087893d425b1", + "181bd4616796d89174cedc0332fb320b65aeb0e2", + "6c417b1798ee319eeb404efe4aa136ed7ed37966", + "9a9f83e2035aa591d18101c919d1fd5b3456b46c", + "74ce9f5658cd8aeae4601fe72fcef07d9f75ec26", + "536eaaa901d652805a8977ecb2dc73f651094c5b", + "b8b1ac11bcc7174c5b23c18cc7919d09a04255c2", + "92cddcabf5365eef1e037f488af52b31669d987f", + "2c9c4f27bade080a2cd6f9160422762e267c2f5f", + "c7ce29d189dc06ba57e64f0cc32202f5a25ba48d", + "717778cc9ab30bcfc026a4344ea1bdef870bd247", + "7ac4cb547c8f4ce5079c95afad9d0e2b0cd76a0e", + "d578210815e27fe210eb678a71e6d22ba4b4c196", + "c7a027c7079dfcc831ca8bc134a509958273073c", + "19cf978596195b848df8709aaf637f83f92b8336", + "798a835fe50156eeb478c0a6085b088f53409d52", + "86ddf268d854f37e5b478c48792b551b57635db6", + "8259d388e02542207b6a08d65d553871ce1c4a09", + "faea73ff9436223f8c4ee76ac9861a6609ac4ae4", + "66f8d78d4971934794478afee28b3a50e97f1b82", + "b8f16334bdced439e1c6fc69704bc95f7b46b147", + "63798fb175afef78fa8fe8133d9de97a0cc80651", + "5f629ab51719dd0ca5a67d880eb2631f5b598a7b", + "1ceb85697f649a62b1753438daa14944af7f450c", + "98ce4dbc04eb48fa0f96ef813db5b4dfa1b2dd39", + "3addb9ccd8f56fc0825f61b1b5af67d3297f4ded", + "f00bac7e18827cfb264fae2e8a0da17b9db18d52", + "63c1c6c63e82f3b8bd977a1381b248e05321394d", + "ada202d2f526f6995f83412479891c1764b66e5a", + "68348e8f54883f4fe295354b024e291c85f1038f", + "07f55f85a5bb70de5841ea4f62a9af3d29d3d94b", + "e9167564031ead3459eee6a3ebb2f58f100d931f", + "d39315a1399639f6d4305a342c9ccf02a463b0dd", + "46196f50297260df2863e2fa76d2dfcf72006c23", + "0790585dfaef94f912b1ee81477d4ac448708708", + "589fb8a85d924ad19ed78409ae89475ba479c30a", + "43d67bc61ef54014b022891e5c024fc24b1fe797", + "e8783644428b637adbe80bcd084a33428cb69983", + "fc0c32afb719295f28bcfef22803bef94f798e20", + "36f6db4fbe2a1630a7597d3a446f2902755c96ef", + "d3f08946300e1700865042aed121870e292d1095", + "467ff4af1e105855874f27fbf84d1d2b0417ab5d", + "fb0dcff8a67a88313557ee8b588aaa2004fe7b8b", + "8ea5d7e4bebc40a1d91b04b12e1c11a42c188095", + "317521e576801acaea62c76fe16813cdfe20f4ad", + "ce0fc29bb0281d6c955d64e239254ef9e6dbc06d", + "5ab49e7b61eddd3bab4182f362a38e1ab6a5a3b7", + "555b6f04ba8dec9e2a60693dcaac594227052727", + "c199b96a71c3aab2d49ccb5b6294bf14eb0dd1eb", + "4238fe9d296b5c72b0a8745cc761f308605b2094", + "943dc6033ab335a6a63e666f70a6bb3a0677e157", + "88b6427cf71a6b9a26bfd6026103d50f721651a9", + "88cfa7b7c1487f8eda05fce92b622942c9fb7ca4", + "64cf929548bc5324fb14b053077bf5bc4be3e15c", + "ad91dde8566dceaadc3523cdc8149cd7415a1b70", + "1936661eee8073068506131c9e89265b2f8403e8", + NULL +}; + +static const char *sha1_graphics_r6g6b6[] = +{ + "a3cadd34d95d3d5cc23344f69aab1c2e55935fcf", + "a1adb32e70188a00f82fe58156b4da74f3ef7a0a", + "5b9dab3d8411afb25fbbeba0313db526815ac189", + "6415f551e28e1b38b2d721f0a9e003b7d215f6b2", + "2028d1b0d1acef35dc07027135023f35fb9746b9", + "378713720dcb5aadb730435ad0989a68ab189114", + "084152773feb01a85df6006f2f4f288a1442d37a", + "97b824953f60fc9a91028045baacbe7b7dc82b14", + "f33b1931f392bd09b3494efc23cf7d0ed3071014", + "287d755448e72e29e4812193e2b6f8098a214d82", + "4059d295aa05ace77853d7ee3d74305cdcbec9f5", + "2557ebd4fdacc0e5bcce3dae88a46dd247654ea1", + "e51bcf80211cd06e7d10225534b7a79b5454be27", + "9bf91a547f47b29bf370e9b60eae7cd6ce987617", + "0b94e0a5b739ab0020130646522e53da35a149ad", + "eab6e532845dfd5dc2701ef90669a5f7b63e9539", + "90deb2e2502186b3c62a58ec9b1c9d2b7b4089c1", + "a4e451f76a77bbc3e224a41e9b4fa78cb841a8af", + "084607a5c99a84140d93db57d1b0f3a0f51afdac", + "2128157e601ef0d6b3636b7387d3b28e876de728", + "8bdcdcd463f0052279d070ac763757f4db975483", + "9ea0ad22d7b61598fe36e9c942242e8e07e32edb", + "8b6452ebd1f6d189d10ee6647e7704821559cfcb", + "c39a25a61c4eade48dea62a97c9fb8714c06a8af", + "66b130f83381957cfc4763558c5f5cddf2e3b564", + "d548135ce2320499277ce12b80bc35004f8a9787", + "85a4f3f1b4b0a170198f1bb5d225fcf77887665e", + "1906ddfd829e735af49245171f8eb7673295d399", + "971a0b786d5bccb1bfb9cbb054740e4eb36f9b7a", + "e2896035f178b3d20e4f4d1accb1b3d1b4028865", + "defd95a10d44cad6e736542920b74efd53e9e7eb", + "eaccd012c0fc46e79cae1997ef101979e5654d8d", + "3f11a735e52030aa3d0f024d83803698293d10e5", + "82f45c5a34fbb9e36d947a876834d33a1f69719c", + "3d27002f4fe3c943468b7e3ef6985962c41ac8dc", + "3231c4d87faefb7ec5bd377613969c05b70343fc", + "00394e438e9edde978e88602c9ad2a572e965bf6", + "e760be69cb37c7be35d5968d7a294e1fd49d4f66", + "996fb708ddc4b94eb8d1585bd83a5c8a1e2633ba", + "caa39eb482e8fc2e00f1c6737735c023ac9363ef", + "c1250ff2b67e6d2a8baccc5c93f8f5ad933c5c4f", + "3d6cf3753390a05504b1f50302f767df443f0f40", + "b7cf1bafe002673ae58ff50feea61ee32a1ae10a", + "da9e896a3a98b330980152b2e4a43cb6e686c730", + "0a613357e1e8ec8ff1ad956e46e527a05cab8500", + "bdd8ed3ca3ad107b43731ec253ecaa34750a10de", + "47499ad13b719de18c59c2bc9b38ed578db50b95", + "643e82ac67ab2b0c034a3fcfa498b072a5f2be5c", + "cd01f2c0a63b2229d4467d2f874d58edca32b3d4", + "94b54f1da5212b3f3a1195eda5ea927e160bc89d", + "49341c297a887186bd47d7465d827ab3147f05e3", + "325279e76367200d3fd7194d81c09fd139988ece", + "c3def160a1e847605ff0fc7edd30397fa90635a0", + "a9c2158329c207638cfd2c82cd8a6218efdb28d2", + "7f0c4e6874f0c36cee64ff5dec76258ca8822cb2", + "aecb242c31f31a90f071b6455ea7d808d4ea22e3", + "77ea86e51a94b11a8081b29696cb4115687843e3", + "d67b897cad72d31e75359094007b1346fd8806ea", + "442bcf4d94a649c9406c3b0bf2f00cb7c6a4d1d4", + "3d0853f4f7580d7cd5148c21c34d878ecf39a5f3", + "1e5a4ef7f8634847a251d1fcce298c409fd13d87", + "481337fbedf181d4324bf7f8299b0327197ff468", + "9ab957870fa4e17aec6a79bc1a4fdb42a5ffcc30", + "b4b9f0bf127ef11f510f25684ae21d692609c85e", + "8e32ea3614c3b20899d748db48258761c7158d2b", + "5da35bad12e3e9b26a0444d30820099481281e45", + "94f004e98ae8035af948611770a4a2dd6643f510", + "045ddaf752e7ffc7ded792f36af3c7c0cfeeae42", NULL }; @@ -184,6 +470,7 @@ static const char *sha1_graphics_24[] = "adc20832d8c43f1cf372d8392535492013cd2306", "45649794dcbcabda487f66f7a80fc1bec79047a1", "367c2dc1e91ff9ea0e984d6fb3000cfb4e0ae7e9", + "9c6afd47dd748a33c585e6655fd4ec1c28976a47", "b4df692ac70a5f9f303270df4641ab014c6cbf46", "8bc3128ba47891366fd7b02fde7ca19100e64b9f", "e649e00efe7fea1eb8b17f7867fe089e5270c44b", @@ -198,6 +485,37 @@ static const char *sha1_graphics_24[] = "b0a959745b2db1d9f449e68e4479a4f36301879c", "63f764b9bd2f4876ab1ee0f3c0eb55b5a7de5212", "e171f6ec77bca91d6b8559911bce296c0bac469e", + "9725669042ef68acb408404d196496d10340bb5a", + "26e7e1c300ba0c5aaaef03eeb71d529f6def9289", + "b1f602d2a74095cc0115ae2ae07b642498e6c0fc", + "03d5eb8e3a6662e6dc183f88ee2f285065fc9c51", + "f4c312f9a37ddc54a27f6b1421dab1ce0cec0c27", + "0f79500eda467cd3cbc220abdd37b5dba695d654", + "8d4e3e9d81cc30aaad555ed9e27aed7c615de630", + "84c43a3cbd7d8c1ac9a0e9b6f07620158079b278", + "7d479beeb6758c164566638b5c873c188d6a91e7", + "80086808fca03e757d812e31d1ae576bf90dac9d", + "9560096f1b85ae6d939d736165c44df00a47c424", + "1015e0217ea13eaa62c7666b8b81aafd75f8f610", + "93e1aec608e037af3bfb7bd32dde446abe4eea11", + "b25ba91487ec945410deb2b51bc1156890c032a8", + "d347ca5c6c4b6a61389247c3b6f61564033e8c25", + "ee315634ed92da3a32c2675ecd1b369471c60936", + "6776e0612410e7e200c853721b4ab6ad8b6b81f5", + "620a5a520d81971a2d9c30b8d836ba696e11b8dd", + "354b92008a8409c62d0fa1dff1532c5943aa37a2", + "8dc9cb7deae5c24d1eae004d53893fa6caf4723c", + "cf311a96d41bd98fdbdfb5dfaac4ba1ba9b7d6da", + "bf5ec23456efe00e1e0931c17de9040ab2092858", + "0bbdf0a0489428f96e3c1d3e5305f9a893820852", + "9d86b1b2bbce90efd3c0b9fe20d23ffa3eeecd20", + "8f7a0af421101952e674f37154c1e8c4646ea2d2", + "e96b79bf88988b5694a04dfc3bd0029361b39801", + "d12284f58daabbd173dfae6c7e55fd5d822d89b4", + "09cb4ab070083144bed4271c0a2a34ccb6ed13c0", + "cc5ed4c9e925f0a457a7437fbb8054528cdd9469", + "c95afd0a020e68a76982fe8663b5d64113987233", + "48658ff76c137185c56a53f3ccf0e958d0296742", NULL }; @@ -225,6 +543,7 @@ static const char *sha1_graphics_r5g5b5[] = "6daaf945a955928c5c124c880522ca4634fb2343", "12a288390d16e1efa99d4185301de48a4d433b14", "ea92af2538b76f41a3a03eaa11ac395c9b6197c4", + "1d3af561605fd61433035600d8962cb8d266fdd0", "3a50ce21b3563a604b4fc9f247a30f5a981f1ba6", "d7d97e28ed316f6596c737eb83baa5948d86b673", "ecc2991277d7314f55b00e0f284ae3703aeef81e", @@ -238,6 +557,42 @@ static const char *sha1_graphics_r5g5b5[] = "a8d6a5285a927ba3a3be34b06a06c70a20d4c1b3", "e428d213ad02651287894f093413949dcb369208", "7df915bedcc5951a1b6f828490f7dbb93212e835", + "645dc251d205139282b17eb7bece1055fff3bcd0", + "76215275593631f5900aad3616d725733dc39493", + "81655a550703849a616d4a16504bb9c6f999285f", + "573d65665d20f00d36d9782ae2b89772140524ab", + "619414c1b33ac60cb0c0de61df86245d472259b0", + "c3d4a1425e17de9e05e3f6dfc6a24c26bfd5ee12", + "2a66dae03890ff791eabb982949435adb19af02b", + "24ac219478ba406f30794550690486b14cbac5e8", + "2b28d20690dc92374ebecb5508f8fdc6c7581790", + "db8c34882ddd46716d14bbf569d530f80db65ed4", + "6c652ecce55e71fee16bc1c9b2c5ae4161bdd2ea", + "9b02173f424c098ea0f4cc5db9eb65f69263d127", + "a92942269911a88793b3460b6f2a2cd56e48eec1", + "059db9f0426b371e464ef3d30f1a4f4aa599e101", + "a52d6ceee5c2a04b4e059c0d49337a997cc17e40", + "aa4a0a4b7f2697aaf270c89874631974bd9d7183", + "585061e403d9cac1603a38af420efe87338f381a", + "8f447a3820c83662086dfa836da2205b0130fd5f", + "3772003c7fb420003512d0c437b3659d96d89ce4", + "dab47c9dc149e570045d699598b14a613bf319b3", + "2daca4d26a086ed34894693be0b0374402232809", + "e313ae8f7261b88999757ed0c6f26df85b4f01a5", + "47d0bab8664ae0aaa927495d07bb3537cce35f16", + "295ec16530126046790fb734e99f86f5b3b74ed8", + "d98b0561010606b55a1b9b85fbc93640f681d256", + "1c1499051860b7caa25173b328ca9c862f01dd1a", + "a655512753bc90e6d4eb3848f69e96db1ad348e5", + "2230f36f12d4becb242e2962fa1b3694db2496ca", + "d81e41a765d7a2d68073f5fde3f74f09df84001d", + "0de013c2c6aba9f99cbcf5f8cfd3212ded7ae72a", + "5950f7d00cd8692872377df0e869a7d5ea5e4420", + "fedc67d1b0797be5f40cd45280844f2b61d29b0a", + "7de23c68ca224818fdf127c5e96729dcd0de2b8b", + "a848b1b0293b05b3f9358a3ffcb21a2e5fdecf05", + "1a0fd0df17fa4c455a4a91cad30b5242f77fd233", + "af45bf81d119be5cf6845ad41191ba52637e65e9", NULL }; @@ -265,6 +620,7 @@ static const char *sha1_graphics_r4g4b4[] = "1d283aa4d2b2114f7809fe59357d590c7c779aa7", "29640e2ddd2d3016da14507c3ce9b2ce32f39bb4", "57ebf8becac1524543da120e88e9cc57ecfdec49", + "e68ef3ffd7401244cdea79781eab12d7a5e8ca18", "d591232bbc2592462c819a9486750f64180518fd", "0e183a4c30b3da345129cffe33fe0fc593d8666b", "f14d9a4bd8a365b7c8f068a0dad481b6eb2b178b", @@ -278,6 +634,198 @@ static const char *sha1_graphics_r4g4b4[] = "957a86fbe8a96dd068db65e4e624a52bcc84af46", "13b0f240054dc57ba0e2dfde74048496304a2c7f", "51ef267eb9c15487c9430f505e8a6c929eb2170c", + "1b593d8e031d3b37fecf6f1df5a8f96c8e8bfef8", + "9dd123938b0a02601d8d458ecbd6535ddefea724", + "815a1e4fc7f3a00c2990c150e87eba0b13f66811", + "75ae8c80af4356a1a5eebde6608fbc31e8a95372", + "b89ae8de2d975b8adb263ace66fd953d29165a8b", + "e901ab4b20bc87370609d7ba1f21aa08abd9eced", + "e9105c6ed8355519e0cf2d2217ed7af43cec8ba0", + "3cbf5fffdd73f9639f3eb34ec1ab3055bc8618fb", + "8e2e70ade90711c4ac01352aa0373fce36ff5dc0", + "8c40d6d8e0c696c31f04c896e492a2a38703d870", + "e13c821c236ea0b67cca64c9da7be15e88fc712f", + "9af4907a8144458a73dbb7471784f8c3d9aeffcf", + "e4731b63d41f6b51e30752ea52d85c4a2938731b", + "f0acb3cfcda62e95bee5f7bc8830ffeb3dd7e5a7", + "07b10c3f191d0a93e5e5694aae37dcad407e10f5", + "f7900e60347029876ba55e8f0c4c02e89deb36b6", + "7d80b8289da8a65931f03c74a9ef0aff5f8eb551", + "a7a986097e5b553c71bd93fd0ec6037e6bd0f2d1", + "7587a9c87cab1eca827807f351bb67ca184d1ac5", + "b53ef0b5c674822e784903a9dbdd3b386d9f2350", + "5505d2ed20dc61ffe48832ecf5329162a5ceb734", + "9f72be4467219a345b1164205d1fbfda2d64271e", + "13d1634e03bc49cfe14a32278d9b1f5ddbb9be10", + "a79e4cc419b9e1735e275e2823da52875536943a", + "b0182002cb1f4fba9df3c21a4d046ab41ce7e9be", + "3830cd728c1e72837310940bcdac4e294d6c9843", + "f571c7c4aac92491017963032194690c0fa06b42", + "6fd751b7328c02954bce98bed94b3ce3c73db118", + "91d50b5a604d6c38aa0d08b9af995490f8ec246b", + "8585783d0373e9696b508776b6e6b18a80b09888", + "b53cde47b0e28063770d3b1328c3cc2f774a6300", + NULL +}; + +static const char *sha1_graphics_8_color[] = +{ + "41728d7ff2bb425b5fc06521adeabf6cc73136f3", + "e313bb57f699587b0bae2f17f5da5d977e6f2a61", + "49024d6cbdf1614327dfda9eda17675e76805f7e", + "63ba8ab7e7996857d52d4c2b995cfcd304daf25f", + "92295ae66712df050cfd6cc9fd2fd4101784c5fc", + "84d85009d35ae10abbc435f3913422544105cea2", + "eae349c2a481d6e8bfdf9a7f4f49384a14716a5f", + "6c51068ca1db36d948eaa34aed4a44d2cd1e8b32", + "f3aa8d89430748178952de56643069d80b40aad6", + "bd5fed74e2f1b097ef4c20bd30edfc6ee11eeccd", + "0546b87bf5fbe1b8168eed5d4a20649be92734a1", + "52b1363e821bf604d9df260bfa97e26d428c33fd", + "108732d9909ee5f3542a9b90b3ad96ec82446ab9", + "06c76c53dcf3ba5e213d483e27d841404c9aa90a", + "ae8fcdbdd44ba58e9bd46a4c56eb54f37483913c", + "89711289be6d5c55734878410e4923d5cca9aca9", + "8355caf57d51ad4e14275943088392e37dc75d33", + "5992b2e331a0e0f752598cc8d083cbecb5f4dde6", + "6f0570da9dea7f043f678088f8362ee458cd79fa", + "940db409d4c3e5640275724f9e5f7c1a0d2e21b2", + "242ce86967ea62fa69c1e6f597ccbcf2f0b1602c", + "5092b22af85a08f10a2899888bb9d552f25f828e", + "f5dafef807237fe72c74c0bbd47c382ace45bfde", + "e91973be2651eeef568700463652838d8cbba976", + "1df851515ecf46df5c2d3279535c1763f72353dd", + "b68922915ebc2797d58deecf983f7d0cf9a5efbd", + "359bd76088a965bb0cee7c44800bc46b2638807e", + "e14e5734b33057b890368f3e9d482d9e5a0358c5", + "64205ccaa277e64eeea0c20e99900ac79858ca2c", + "2cdee35d43d62da09b4ddfddbd0948ddbb9fc48e", + "91f988f575338505ba8a40727865a8d3f2298624", + "d2b4557492ebb2e0f640a0a2f6fc3bdc8d8f36f9", + "421e8b608378e4f17774dd32ea6446fa0fa16f91", + "3b7488731da48635d86be551ab7c8c0f91c78219", + "4fd49cb49853ef950fd0b7e2e35718a71c8374c7", + "e15a355fc09bfd22267917898e2266168ff410e3", + "b9688566bddf18586787c00e68724e51e97dfb72", + "5e38e03310f1c66f2052af2a745d8c60515707c5", + "f994fb5019bf4c1a96eccf89af599eae0aa6b412", + "3a71ad6fef147067641e49a5f69b2454e3a5010d", + "ea10eac72830dcae19bcb16a076c2b21d844b5b6", + "6376234f542467e5887adfece62f753e998dc19d", + "add949d009217ef2b847e34772ba363e4be7b1b8", + "28fcf9f7d098c05de632ae38b2fe33b9635ad445", + "0b58666deb3615e912896a764e5c6475989e95e4", + "bf460cc44c0edee851d72587c8425c3f06a62c55", + "ea74c00c45569007383b632d7f1d2adc82645717", + "5ac22e1a33b0204fdc7a68d54ee94648e96079a0", + "284abed096637c80bb50844e393da9dd4b3f19ac", + "9dc776c5ab8256b1301c7d1da60544a9410e6715", + "a433c41c05b6db008a4cb2c52a321d027c6be1fe", + "46f772c2832b3aad584674db666bd63e48b4f338", + "a9f9ca0049235db51ab7359a5fc3d21be42d2aac", + "f3dc739da41fb299637c8660e8c46917ddcf87a8", + "eae47bf865d932f22a6e59b6fe8d041f220e1fbc", + "9ae38bb94c7b4c0c6dfebbee23d1de4db9b77488", + "678979a45126a76eb629992cd64734862f53a555", + "2f7ba8803604c032cb1a1228bc021f0f1c03e245", + "9b1cc7b24f8ce15db2af7f4aa8cde8687784dfa2", + "cc4a4cea622d825700bccef7d90a5a447d9ca39d", + "e58d9c0acf0219d0839e1dbd162e08a765ed7f0f", + "34ca0f9660e1889f9f2c0deb80535d3c4f349fa4", + "2c07272462c68cf5944b03e2aa049475b99143c5", + "07ca369fb875d37b9cf855045f528af1827edec4", + "5e9e3e71b06c5efe20f93b3838e745b40b878471", + "153ae5c9fc2a31b38c4878b25d9026b9f51f132d", + "488341e88810d737de0b26de4e4d4fa0e78eb482", + "bd1e7f40e3971e2ff6c5561286901193a1557527", + "5a42b7eeff8198e7b005e4afa4282e6ffb939906", + "d7ffa3893c6fa937569791cf49986518a4a4d96e", + "26bc25a011e2b60961ee9d6c6141d928ae24389b", + "8771d5ff7b93b9dd9d077e672b342235dfb28472", + "6a1f6e1d494bf6b0ece7af5fa164ebaadb3a19bd", + NULL +}; + +static const char *sha1_graphics_8_grayscale[] = +{ + "41728d7ff2bb425b5fc06521adeabf6cc73136f3", + "df35491dd5038187c05bac06921402ba6d7773a8", + "c8cd6d34e011d5f9ca4b1190eec3b416e5e68e53", + "66a686ac22cd0ec326f2c97ef473781cabe9690b", + "9bddef7b97b8b03569f07011e66ddd67fe82d787", + "2a4cea20974bcfb92cf40b05746fc7eb465c4b0f", + "0a87689ca33f888f05dbfa21ddec11c069990d8b", + "8d0a92e6333e1b99591962e2def9bc9121111cf5", + "409c9f29f6fa2e312c8e0b4b3c59acb4d84d8717", + "1fbc234c28a8140965ad0fe30b4b799f6681e864", + "1fc709d5d3e55d5f96c451c209cd73c59dbfe733", + "96b6a32e057d5faeae57086cbb62a8e7b3e6e86f", + "aa66ea7c9b7214339858b9fc9bd4720d05e8c843", + "114bb377b4e78a1978e1ac09388c48861b5223a3", + "8d0a92e6333e1b99591962e2def9bc9121111cf5", + "9dc511d6947fe816185cdff93bf0cfe0349b72b4", + "eb4c14ee66b012187f5fe6a2ec28b6be956567c8", + "216388ddf6b563dd2058a9df65b40b6f72df1715", + "ad11e4b6979cf055e3bf1868112a7bef207385a4", + "47f72be971bd2d3399dabd018201f4f5075e96fe", + "de09d41c9ae4338fbfcfe9f8ed71d343537a6f3d", + "f39ab890a2b99d0c31e6e047f2315244972f5ffd", + "6e7baf7d328bc2c55366e32967a0db4d2f43ab82", + "15b991814d84d6aa252696dd0c6150ef88a8db3f", + "1cb52f2a4d17b9b0d8375d016aa8cf0677fcd29a", + "9a6cfd68523e40ea1d52847d7747da912cfe2ca9", + "b6785a410048bb85e7ea3f0492459972103c935e", + "82e641ebe47d9f8cc229b82b8315e69e52f812b1", + "15db343049e3a9b31addc5d2ffebc3fe91b39c51", + "a895daf1f20371d4d1c3f93c070124cc13e341c3", + "3ddc872384ed8f9eaef472aa14a1d79a2c3f3b04", + "0000000000000000000000000000000000000000", + "bd7d8c1cb4b2adc31cf8c7d39a4fa1e3ac7f2545", + "33fc8618ce62f5cdd9e06ad61e296f718a99899e", + "dcaa7fe030ae4d3029e38ca584047eeb2d17fe10", + "6d41e6168662e75baacf74d911d7419d54c8d73c", + "2404952157ba1519094a2da6bfbf2b0f1356432d", + "24caede65b40815a60b83c4edfa06bdc542388cd", + "650a51bedd1af92469d2950eb95220db35f95c6e", + "3f43aa11e6fccb747cc13224583fb2f951fee08c", + "04cea9753b575ecce8e55357eddfcec10ddfbbea", + "6b6f4b97f05e015eb37a5f6aff637235feacd030", + "1bd06e4e11929e5e91c3c9f20def639b20e731e8", + "d63a6086547e90d2ba84aaebfeae24f3ba0c04f1", + "85425940daf119125deb52421b2057acebe6d1cf", + "a3db92382cf0a4c7cafe52c27b1f41520aaa677d", + "9869b6f088822fb423996f9968e5a931301fc2c3", + "cdf63ab4ab32c2e8e27527a9588d0fb525f1c945", + "a7f81cf3326fa3608acc13cfce2f573912e9d745", + "f2ea92f523f8918b1d514a2d9555dcb4750273b4", + "e9c16e43a8f589ae85289c5c3ffea6b22fba1806", + "84a4bc0c2c5d36d016da4df95a5d8d6c8ce3ba6f", + "f543efc84e638afbaa456e629100f0274de1a35b", + "1bd2587399006eed0d46beff397d32081f6bc58e", + "f8a571de89ed82ffb9cbc041ce1eacb064be2853", + "640a49455acabca6954a7fbb6af4e872af342d11", + "589e7911e09332ee090371deae17b0120ff990b5", + "a1a941fa270cda48c648553ed4b427e16e96f8e0", + "f30a8d9f73ca043c5bfc18d9595e299fc0a39eec", + "fb63bbb2f944fb63ed2d7399f07b168740c1034b", + "3685c9ae95118a83db3569832c29753276fa1264", + "09640bad951c33e7d70a1fced83b1869f65b3fc5", + "cb9ea8137eca1450e049879772f5c11a0e11ff0a", + "a4b04ed35484de0de61832a8a28bbc7def645622", + "515897610714251dd3b54f54fe76a9ed3fd12c53", + "0ca8775d9a61ccc251d1e6f2e3cfd26a24ae24a2", + "17ae603c199a5d6695d198a7f36e6d7263990951", + "1918a33f59d3500204ffc573318a39e9ff754221", + "5449d1aef0d2d6af9ac3fd7adb32c23ddc9be1e2", + "55d302ece31a9b7fc4be4a07a53767ba210273e7", + "a6a29836291f9dbca85e25cee60f62ef5faca6d7", + "3494a23633405e46af96cb57715617fef1ac252e", + "5a3ae1da30d83cc157e6a4a5617c85598309f4ac", + "edc1ad2704452354aa6f79fac244a55b6f509c2e", + "87eab8f81fb2a036080e099760f628037f9306e7", + "a3eac75d30f681b3898ee469d368960529634d7d", + "cd5caeabdb71241766d24f038cfc5f1e91e11256", + "e2b393dc3f5833f7868668ea31369e90348768cd", NULL }; @@ -305,6 +853,7 @@ static const char *sha1_graphics_8[] = "7262364067e03c7fa498af1d59d228d6c63b460e", "5241241a355a667ef0834049adf4218e8b3f16b8", "db22d666690948eb966f75b796c72c7150a5c4b9", + "af21fb2645b568b049549de375584c4aa3055143", "1f13ea0034db4b0ffa4ddcff9664fd892058f9cd", "3caf512cfddfd463d0750cfe3cadb58548eb2ae8", "4e5e7d5fd64818b2b3d3e793c88f603b699d2f0f", @@ -318,6 +867,41 @@ static const char *sha1_graphics_8[] = "ea39ac62ca2f815a1d029340c6465994b6f03cb0", "9a603513cd81acf70cf8b27b0d544e7f672e9d40", "f4a334e69535de74ee5ed54be93a75120a66e54a", + "559fd1d15447745527c61fe43a94c6708bff3e39", + "995f77f2f53398399f09d1365cb4dfd105764e5c", + "61907a6685bba93077da40cfb28cf2ab74552fd2", + "122015e5e17c1c317c6e51c0e207826b606a4077", + "c21851589a5f8a45ea5f9bb3e72f4f88d0a6697d", + "8c609921d4a3ed89a994a75482b27496bf103cf5", + "eb2ce16a6ae251f4965135ee776776b5fc02c42c", + "66493ee117719e172f327a426af601996025f28c", + "acead2745fec0b6c817fa601353bdf2d197b64f7", + "a6b858b2d125c159529d3f3ec45b31925a79acff", + "1f1379089d7c6e8d733aaa4eaffbe02db6255b61", + "d83adc669c0dea0dc4812b93f998514b6f02d805", + "9e8ceb7c3cd68e043b6d875c8c84a1e394962412", + "9e996fc74eeef53f0a6c31aabb2edce6e103f189", + "6b8abd1785304d6531c1e4cc65c1ffcdcb2196a5", + "7d1bfff706b0713e53209407889f83a0da26a81d", + "31e667c2dbb81dcf81d01cb88f794e88ddb90ff2", + "31e667c2dbb81dcf81d01cb88f794e88ddb90ff2", + "465d9cd0a77ab4fcf035aa67544b2a26269e0b09", + "600d6b2713d5e4c0d90c02660245ed26c7ae3033", + "d4f3a5ea033adc405c44e1ca137dc908c606dad6", + "7103d428ec9a959778120fd6f0dc62dd608ddd63", + "bd28d77cd85b20a2384d6b25082cfd884bba683e", + "7e591ec8ae9bb61c3a443c93f071cab2b8978394", + "f81c70b6ee2d4690f9f7c797c66582b176f8dcef", + "d3f359cac7318ce09e0531d51c8c2b316cf3a23b", + "293c41a7ed923a4617560481ae8815cebf83701a", + "ec06b56f3abe277be42650ebd49dabeaae9e756d", + "750c923785ba2afb9ce597516c072f90f014bf95", + "80089132f8a11d86e8038f2f8e12dfba46624ee5", + "bde5a62a065c027561226fbec5155e938ba7f6b3", + "a6311d74fc058079a327abb536e69353be719925", + "fbaa8848a1d3896469c37fd43ab44233f5b875a3", + "0000000000000000000000000000000000000000", + "c2ac98ef716fd8a5ac8f08ce66293d9a96344337", NULL }; @@ -345,6 +929,7 @@ static const char *sha1_graphics_4[] = "eb38683e812fd13dca971ba8f4cfd2b6820d3524", "73bbc83f88f1aaa6df0158b63e70bb3165163163", "0dc2690a5c58a2907a8ab06693ebfab6698172eb", + "df5f0d6574bdf1781754b5b9f98232a77e439e33", "39c16648cf6c261be71a33cec41867f28e119b94", "26ad5116562e7b58c76a26eaf521e2e40899e944", "1bcc54eaf8e3c2b7c59ecccb23c240181d7ba8b8", @@ -358,6 +943,109 @@ static const char *sha1_graphics_4[] = "b672afbeeafb44194a821f0def81a8892872937e", "db0124045882b598feea192186cf7eb7a0387866", "602d91471378fe24a2d0248bd8a92b624f099fea", + "e772873b87a0f55ea51a3da323f64bf8814c6703", + "21aa1ff238a2d78efed1aa658ac8fe21b1e64daa", + "1a579cd280422131c35e907a023ee0e80749b5a4", + "bbf027f506cbb80d359bf4892fcb75f816f2e446", + "ed44bded6b17df7fe92b191fd810d1aafbd55f52", + "a49bcb1ace42d548254d9e96d22088b1fe2e75b4", + "e2a21a965dfd0bd09f9270917f681610efc18ce7", + "3e411b004a5be84451860c6da6a4a1a482b77862", + "3b3d2f18fdc75e938ca43cc2d0b41fa67c1c5d36", + "7811c536a6527112b438a6413f3927f2c79086a7", + "525ef3615040225752a2fe646ab99ee64e360630", + "46760975993f9881b7bbe94123173e6a683d3f25", + "df5feb905a31c288008cf5e82d73ac818a160d82", + "df5feb905a31c288008cf5e82d73ac818a160d82", + "d8af3868c66c7d6dac35ec8ee0317b38a6910bb1", + "ec8e2aebfb4a1c28ebcd0e053b9e4d8638b50951", + "1a23839d71d2379ed4e709a5ae6c14639fbe3ab8", + "09f8416a780d80be61cbda3d8a05aee418d0ea00", + "28a6b9f7927e99e53cf46f0333d29168cb10e920", + "029552113292cc110fd6b7888e766628950aaeef", + "297f6ad15200bffbf15198324ee8f27a61a6f2d4", + "70cfa427a1a0d6f2232b1fd544905d48af69cb98", + "287ea7db721e641439888cb9f4bac3a5f16124eb", + "dd9eaa5325cdf250e89162ac84207978ebb6458e", + "42466aab11852741d937c1ff6f3bb711e58415a6", + "0663cf6330591fcf744aba96664e05d90243d07a", + "3024fa38333f83a639b0f0e6ac6d4b9868231157", + "6fe7d0d17b892032cfd171c3d7c365f030b5be38", + "7ae780dcc7cf04dda50648bfc07cc6a7a2f2189e", + "0000000000000000000000000000000000000000", + "9ab46e0c42f82dc73df8a55cbf881abd72397cec", + NULL +}; + +static const char *sha1_graphics_4_grayscale[] = +{ + "fa867e2976a549ecd3b1fa67df54963232fcef8c", + "6611ea6cb24bcf34c5f3688d57e2874aecb39c24", + "5ab1d3f8f5938c5d20a2fa3237e319077b21e716", + "1c201d149c0bd886ff8a427ad513f15a70991174", + "44646e67842a4d055bea1fad0434e6e4a0eb5465", + "315189097a02024d2eae61d524c4de07a396aee7", + "73ac786015dea36ac466a6524dba757d5d238ece", + "6e328cc4d53627f034b23706d8bf26afe18512ae", + "3c5b90cfeafdc1c99c8c62317d07276fdf66803e", + "95e6f509bb1cf9981efc47a0878ab0bd983eb349", + "2e1bc3b00e4ecc62b03785533dc0faeeda38d53f", + "6448226859cab61a61c95d3ed5ed5f216b1bb120", + "7f1cb06597b14edbea03b860aec3cebc4ebc3d62", + "ec3879342b5a44f6de6efe946243ae5ade00980d", + "6e328cc4d53627f034b23706d8bf26afe18512ae", + "51b50968a3a0570d5ed690fe44ba1a78a4d62ce2", + "d5bab61f78ac3355aa2e0776b2d5d9d71d61e77b", + "fa47c5195405f6a0eefba3e3a60ad463c7ee94c7", + "b2bda683edef912957845a33edc055902a801fed", + "b067f0421cb2c83b218b8ab6edbede2ff5723b57", + "c8de76f9c0900e5f86c7584fe94d5749376b7b49", + "43ee3e187dda14b86aef12371041ae70313b5a65", + "7fab79b7f1a5cb2ec31ed8eeaf213b3d8dcde4d8", + "d4930552a7845111ffd9db57260be1ab97967c06", + "afdf41fca7951c6dd6193320de1295f2c68fe52a", + "f2f1f331fe6b1b31d7c9ddd37793b375fc01d3d4", + "f0af0f1edcb837bdf1535c1f5e9988c21ae9bfd1", + "0000000000000000000000000000000000000000", + "71c4577baaf35f12f6707b1e2f78a1e8c0d41d0b", + "9b7d6b12385bb9e1cd881758aff342bd5427432b", + "6fdd5aa022da2a8af6f1d02b6072ebc068b4b600", + "643fab30f1a59dc37f1e0f1a6006076fbf90a5fe", + "6edbc0b95e9ae3348ce7d12c44f9c8082b5f2aa9", + "9c0da52c4ceaa8fdfcff7351328dd520bb57e985", + "f8224430462f6a93f85ef33b8aa7299525990708", + "1cf93cecc942b41ab8fae21ea18418a6d64873e5", + "d58b8760ef01c12e691651c932d683c66fde3654", + "94438c82b8812fe81a69d5d1429c5967cdbfed7a", + "764ea26f10fe11f7bdb538a26fc33d44b3a95d6d", + "94ad53c578f6034dfc5c666e363203cdfb00f2cc", + "8cd7b0ba8426db344b4cb8820890603020ed65e9", + "ad96132f25ca14e1aeb17c86f8d187febf6401c9", + "027b05bc82ce4f897c4bf812610a641547368939", + "3f131e855ba1611d8fb0f16a6979f8f56aacc7f3", + "ae64d1dc52dcfa8c644f953c4601fa2fbefec37b", + "2f3fb1bd8f416198d70e06f6d519571cd5eb4ef4", + "cc96ccaf6b99f60a49b03017515f83cba22b4c40", + "5eeb56afea8040a8fb18c11f29931b836474126d", + "a3405c085fc2f2184bcd0d1edcdcc66927e33659", + "f8681c09f1abfc38d31e47622cb8798cd896a00e", + "b5ee51cfc73acb59a2f6124509ea236f8fc7f9f7", + "d374d4d92c940ae42a9b42c14d744341b68a8c14", + "43560b856907f552df3b9dd1f91e1aa8ab9ff17e", + "8cefa6dcb658487d0715598d5d120677dbfdab42", + "ada3b7c34946e584dcdf4203e07cfa3dad02bc63", + "c2f61571b067a44b30f56b4658c9606f0edfc0f3", + "58f400c9bb78e49a879276fb049edfc9c981740a", + "cb3794f676d6e9502f27172ac7d79a12ca2ba32c", + "aa89612798fbc4e11a73b6233c0ac4832e6af2f9", + "c96a998be5c1d588ef1243cfd2610d056d16947e", + "68bee638d59a373f33f308751471b3ef41849582", + "be0501175cc3cbb61217fca76356f761117fb40f", + "8fa37e26cdae406c2d1c81b1175dcf0311cf60c9", + "3efe128a5bf250f2c460664e8f543f5ec54d5dc2", + "2d5123e757cf00e423a89160d7dc4997c3688829", + "0000000000000000000000000000000000000000", + "36dfdad9f3f5cfde6add3cef23368c343d30469a", NULL }; @@ -398,6 +1086,10 @@ static const char *sha1_graphics_1[] = "4d95c3d1e170f004c80aa8c52feafb8e0e90760e", "c14832e69ec3585c15987b3d69d5007236fa9814", "e44ea620b0c47125a34193537ab9d219a52ad028", + "ef2db9fb75a672f69bab88e5d08fe64f50ec2bc4", + "df81db2a9b3942a82e0dc5e57247b642f9b42702", + "8819bf7a43295161fe045a42936000b3a51fe200", + "e08dbc26469c229f75ccbf1a38a133401f270b84", "d1e6091caa4482d3142df3b958606c41ebf4698e", "07c1116d8286fb665a1005de220eadc3d5999aaf", "4afb0649488f6e6f7d3a2b8bf438d82f2c88f4d1", @@ -413,9 +1105,115 @@ static const char *sha1_graphics_1[] = "be36cda370650e6d5fb0570aeb8ced491d0c2b1c", "4c34cb8e47f9ff4b4348aa2d40cce7cb54d65cb0", "18f4497e43903e8df5b27da4ceebf62b15550a87", + "3fa3570a2ebd38042b90f24bd3496233bca5a23d", + "2fcd25c2d19a01fa631fd19135d9f28b26b86259", + "655cfadeb157233c804d42b58195569c8846e3c1", + "65c8811c609203fd424f5ed5f92ca2268a1dca54", + "a45b297d709e297584eb0f2985294ec0ab53d8ad", + "0d180c37bc26d83a1a11f66168757f3de2493243", + "b362ba4790def178c236c0ae7b0093dbba47cf24", + "d1d2ecf71a37d9eda58fa09454aa871971428ace", + "6672da4e016b6e9de0ca218f8307cce7d48d62c4", + "ee22f43ea867228c6ff937d39e1826e285a107e8", + "832c3c3afd056e5d1cdfb2f466f27225c4adcc6c", + "a2a928de9007d765da496abec8c21b23601f8c45", + "28ded40e72d4327b9413571476b167fb28a1f420", + "23366004515f3bc46796ea505d748f8d0f97fbe1", + "88763f8e8fcf4f78fa864325791a9dd35a0bd279", + "013cee26bac8f815eadad4bfc012d9b5d01c3b7f", + "44a28536466dc895feb824b23dfd4a47c6948af8", + "f0316a5765a0404760e94cd05b7dc956cae07d26", + "781d8c5cbc28591fd48fce06f984c502fdc6b363", + "df510792a7790cc699532b1420d43c6d4da2ae2f", + "55c26d22f11d80b73383fa57d0fac552d705b092", + "14443b33a9879bf829ed3b06e1aef0d7dcf662cc", + "53ab1fcccd09fa5cbff77497f36a70a3b3cb8b81", + "4842a30dd7fdf38ddc3ddec85c08efe13a0e2e0b", + "cc76db6da5ba1776f20240a5ad97a26a9cdf96b0", + "014f477664a7f4ce4a948d6359a2707119afc8e2", + "1ee4e951743efc8764249fbc7adecefbfec0428e", + "9ab50a663b74577b656e9849484a909d7ac52eeb", + "128eefd2ee043d59dc37918065f687e378e5ca95", + "c642abc651f525332d9d635049646d309e877839", + "8d34215487088b5d4ef63062270ce25c2862643d", + "3dc3075b0c87fdcaabbbae8928303fb2358c15c2", + "bbae6f0659e095a42b420082079663f937065813", + "ca711c69165e1fa5be72993b9a7870ef6d485249", NULL }; +static const RECT graphics_bounds[] = +{ + { 0, 0, 0, 0 }, + { 10, 3, 219, 101 }, + { 100, 100, 301, 301 }, + { 0, 0, 201, 201 }, + { 10, 10, 110, 320 }, + { 10, 99, 300, 200 }, + { 99, 12, 201, 200 }, + { 90, 110, 300, 200 }, + { 90, 90, 210, 200 }, + { 10, 99, 300, 200 }, + { 10, 99, 300, 200 }, + { 99, 12, 201, 200 }, + { 99, 11, 201, 200 }, + { 90, 110, 300, 200 }, + { 90, 110, 300, 200 }, + { 10, 10, 365, 405 }, + { 10, 10, 365, 405 }, + { 10, 10, 365, 405 }, + { 10, 10, 365, 405 }, + { 10, 10, 365, 405 }, + { 10, 10, 365, 405 }, + { 10, 10, 365, 405 }, + { 10, 10, 365, 405 }, + { 10, 10, 350, 251 }, + { 10, 10, 300, 200 }, + { 300, 10, 9, 260 }, + { 10, 10, 435, 405 }, + { 10, 10, 120, 120 }, + { 10, 10, 110, 110 }, + { 10, 10, 120, 110 }, + { 10, 10, 110, 120 }, + { 10, 10, 120, 120 }, + { 10, 10, 110, 110 }, + { 10, 10, 120, 110 }, + { 10, 10, 110, 120 }, + { 100, 100, 356, 356 }, + { 100, 100, 356, 356 }, + { 50, 50, 306, 306 }, + { 100, 100, 356, 356 }, + { 100, 100, 356, 356 }, + { 100, 100, 356, 356 }, + { 100, 100, 356, 356 }, + { 100, 100, 356, 356 }, + { 100, 100, 356, 356 }, + { 100, 100, 356, 356 }, + { 100, 100, 356, 356 }, + { 100, 100, 356, 356 }, + { 100, 100, 356, 356 }, + { 100, 100, 356, 356 }, + { 10, 10, 416, 26 }, + { 10, 8, 60, 104 }, + { 0, 10, 511, 306 }, + { 0, 10, 512, 306 }, + { 1, 1, 300, 512 }, + { 0, 0, 500, 512 }, + { 5, 5, 206, 206 }, + { 45, 45, 256, 256 }, + { 86, 86, 215, 215 }, + { 45, 45, 256, 256 }, + { 8, 0, 392, 231 }, + { 8, 0, 392, 231 }, + { 0, 0, 60, 20 }, + { 0, 0, 512, 512 }, + { -1, -1, -1, -1 } /* the end */ +}; + +static const char **current_sha1; +static const RECT *current_bounds; +static const char *dst_format; + static inline DWORD get_stride(BITMAPINFO *bmi) { return ((bmi->bmiHeader.biBitCount * bmi->bmiHeader.biWidth + 31) >> 3) & ~3; @@ -460,12 +1258,49 @@ static char *hash_dib(BITMAPINFO *bmi, void *bits) return buf; } -static void compare_hash_broken_todo(BITMAPINFO *bmi, BYTE *bits, const char ***sha1, const char *info, int num_broken, BOOL todo) +static void reset_bounds( HDC hdc ) +{ + current_bounds = graphics_bounds; + SetBoundsRect( hdc, NULL, DCB_RESET | DCB_ENABLE ); +} + +static void compare_bounds( HDC hdc, const char *info ) +{ + RECT rect; + + GetBoundsRect( hdc, &rect, DCB_RESET ); + + if (current_bounds->left == -1 && + current_bounds->top == -1 && + current_bounds->right == -1 && + current_bounds->bottom == -1) + { + ok( 0, "missing bounds, got { %d, %d, %d, %d },\n", rect.left, rect.top, rect.right, rect.bottom ); + return; + } + + ok( !memcmp( current_bounds, &rect, sizeof(RECT) ), + "%s: %s: expected bounds %d,%d,%d,%d got %d,%d,%d,%d\n", dst_format, info, + current_bounds->left, current_bounds->top, current_bounds->right, current_bounds->bottom, + rect.left, rect.top, rect.right, rect.bottom ); + current_bounds++; +} + +static void skip_compare( int count ) +{ + current_sha1 += count; + current_bounds++; +} + +static void compare_hash_broken_todo(HDC hdc, BITMAPINFO *bmi, BYTE *bits, const char *info, int num_broken, BOOL todo) { char *hash = hash_dib(bmi, bits); BOOL ok_cond; int i; + /* reset the bits for the next test */ + memset( bits, 0xcc, get_dib_size(bmi) ); + if(!hash) { skip("SHA1 hashing unavailable on this platform\n"); @@ -474,33 +1309,35 @@ static void compare_hash_broken_todo(BITMAPINFO *bmi, BYTE *bits, const char *** for(i = 0; i <= num_broken; i++) { - if((*sha1)[i] == NULL) + if(current_sha1[i] == NULL) { - ok((*sha1)[i] != NULL, "missing hash, got \"%s\",\n", hash); + ok(current_sha1[i] != NULL, "missing hash, got \"%s\",\n", hash); return; } } - ok_cond = !strcmp(hash, **sha1); + ok_cond = !strcmp(hash, *current_sha1); for(i = 1; i <= num_broken; i++) - ok_cond = ok_cond || broken( !strcmp(hash, (*sha1)[i]) ); + ok_cond = ok_cond || broken( !strcmp(hash, current_sha1[i]) ); if(todo) - todo_wine ok( ok_cond, "%d: %s: expected hash %s got %s\n", - bmi->bmiHeader.biBitCount, info, **sha1, hash ); + todo_wine ok( ok_cond, "%s: %s: expected hash %s got %s\n", + dst_format, info, *current_sha1, hash ); else - ok( ok_cond, "%d: %s: expected hash %s got %s\n", - bmi->bmiHeader.biBitCount, info, **sha1, hash ); + ok( ok_cond, "%s: %s: expected hash %s got %s\n", + dst_format, info, *current_sha1, hash ); - *sha1 += num_broken + 1; + current_sha1 += num_broken + 1; HeapFree(GetProcessHeap(), 0, hash); + + compare_bounds( hdc, info ); } -static void compare_hash(BITMAPINFO *bmi, BYTE *bits, const char ***sha1, const char *info) +static void compare_hash(HDC hdc, BITMAPINFO *bmi, BYTE *bits, const char *info) { - compare_hash_broken_todo(bmi, bits, sha1, info, 0, FALSE); + compare_hash_broken_todo(hdc, bmi, bits, info, 0, FALSE); } static const RECT bias_check[] = @@ -564,6 +1401,33 @@ static const RECT line_clips[] = {199, 142, 210, 143} /* start pt just inside r edge */ }; +static const RECT wide_lines[] = +{ + {100, 10, 200, 10}, + {100, 21, 200, 21}, + {200, 40, 100, 40}, + {200, 61, 100, 61}, + { 10, 100, 10, 200}, + { 21, 100, 21, 200}, + { 40, 200, 40, 100}, + { 61, 200, 61, 100}, +}; + +static const POINT poly_lines[] = +{ + {100, 100}, {200, 100}, {200, 200}, {100, 200} +}; + +static const POINT polypoly_lines[] = +{ + {100, 100}, {200, 100}, {200, 100}, {200, 200} +}; + +static const DWORD polypoly_counts[] = +{ + sizeof(polypoly_lines)/sizeof(polypoly_lines[0]) +}; + static const RECT patblt_clips[] = { {120, 120, 140, 126}, /* unclipped */ @@ -610,21 +1474,60 @@ static const BITMAPINFOHEADER dib_brush_header_8 = {sizeof(BITMAPINFOHEADER), static const BITMAPINFOHEADER dib_brush_header_4 = {sizeof(BITMAPINFOHEADER), 16, -16, 1, 4, BI_RGB, 0, 0, 0, 0, 0}; static const BITMAPINFOHEADER dib_brush_header_1 = {sizeof(BITMAPINFOHEADER), 16, -16, 1, 1, BI_RGB, 0, 0, 0, 0, 0}; -static void draw_graphics(HDC hdc, BITMAPINFO *bmi, BYTE *bits, const char ***sha1) +static const BYTE rle8_data[20] = { 0x03, 0x02, 0x04, 0xf0, 0x00, 0x00, /* 2, 2, 2, f0, f0, f0, f0, */ + 0x00, 0x03, 0x04, 0x05, 0x06, 0x00, /* 4, 5, 6, */ + 0x00, 0x02, 0x01, 0x02, 0x05, 0x80, /* dx=1, dy=2, 80, 80, 80, 80, (80) */ + 0x00, 0x01 }; /* */ + +static const DWORD four_by_four_data[16] = { 0x000000, 0xff0000, 0x00ff00, 0x0000ff, + 0xffffff, 0x00ffff, 0xff00ff, 0xffff00, + 0x000000, 0xff0000, 0x00ff00, 0x0000ff, + 0xffffff, 0x00ffff, 0xff00ff, 0xffff00 }; + +static const DWORD ddb_brush_bits[8] = { 0x11112222, 0x33334444, 0x55556666, 0x77778888, + 0xaaaaaaaa, 0x00000000, 0x98765432, 0xabcdef00 }; + +static inline void solid_patblt( HDC hdc, int x, int y, int width, int height, COLORREF color ) { - DWORD dib_size = get_dib_size(bmi); - HPEN solid_pen, dashed_pen, orig_pen; + HBRUSH brush = CreateSolidBrush( color ); + brush = SelectObject( hdc, brush ); + PatBlt( hdc, x, y, width, height, PATCOPY ); + DeleteObject( SelectObject( hdc, brush ) ); +} + +static void draw_graphics(HDC hdc, BITMAPINFO *bmi, BYTE *bits) +{ + char pal_buffer[sizeof(LOGPALETTE) + 255 * sizeof(PALETTEENTRY)]; + LOGPALETTE *pal = (LOGPALETTE *)pal_buffer; + PALETTEENTRY *entries = pal->palPalEntry; + HPEN solid_pen, dashed_pen, wide_pen, orig_pen; + LOGBRUSH log_brush; HBRUSH solid_brush, dib_brush, hatch_brush, orig_brush; - INT i, y, hatch_style; + HBITMAP bmp; + INT i, j, x, y, hatch_style; + HDC src_dc; HRGN hrgn, hrgn2; + BYTE dib_src_buf[sizeof(BITMAPINFO) + 256 * sizeof(RGBQUAD)]; BYTE dib_brush_buf[sizeof(BITMAPINFO) + 256 * sizeof(RGBQUAD) + 16 * 16 * sizeof(DWORD)]; /* Enough for 16 x 16 at 32 bpp */ + BITMAPINFO *src_bi = (BITMAPINFO*)dib_src_buf; BITMAPINFO *brush_bi = (BITMAPINFO*)dib_brush_buf; - BYTE *brush_bits; - BOOL dib_is_1bpp = (bmi->bmiHeader.biBitCount == 1); + RGBQUAD *brush_colors = brush_bi->bmiColors; + BYTE *brush_bits, *src_bits; + BOOL ret, dib_is_1bpp = (bmi->bmiHeader.biBitCount == 1); + BOOL dib_is_8bpp_gray = (bmi->bmiHeader.biBitCount == 8 && bmi->bmiColors[1].rgbRed == 1); + BLENDFUNCTION blend; + COLORREF old_text, old_bkgnd; + HPALETTE hpal; - memset(bits, 0xcc, dib_size); - compare_hash(bmi, bits, sha1, "empty"); + blend.BlendOp = AC_SRC_OVER; + blend.BlendFlags = 0; + reset_bounds( hdc ); + + memset(bits, 0xcc, get_dib_size(bmi)); + compare_hash(hdc, bmi, bits, "empty"); + + src_dc = CreateCompatibleDC( 0 ); solid_pen = CreatePen(PS_SOLID, 1, RGB(0, 0, 0xff)); orig_pen = SelectObject(hdc, solid_pen); SetBrushOrgEx(hdc, 0, 0, NULL); @@ -642,8 +1545,7 @@ static void draw_graphics(HDC hdc, BITMAPINFO *bmi, BYTE *bits, const char ***sh MoveToEx(hdc, 170 + i * 3, 100, NULL); LineTo(hdc, 170 + i * 3, 10); /* b -> t */ } - compare_hash(bmi, bits, sha1, "h and v solid lines"); - memset(bits, 0xcc, dib_size); + compare_hash(hdc, bmi, bits, "h and v solid lines"); /* diagonal lines */ SetROP2(hdc, R2_COPYPEN); @@ -655,16 +1557,14 @@ static void draw_graphics(HDC hdc, BITMAPINFO *bmi, BYTE *bits, const char ***sh MoveToEx(hdc, 200.5 + 10 * c, 200.5 + 10 * s, NULL); LineTo(hdc, 200.5 + 100 * c, 200.5 + 100 * s); } - compare_hash(bmi, bits, sha1, "diagonal solid lines"); - memset(bits, 0xcc, dib_size); + compare_hash(hdc, bmi, bits, "diagonal solid lines"); for(i = 0; i < sizeof(bias_check) / sizeof(bias_check[0]); i++) { MoveToEx(hdc, bias_check[i].left, bias_check[i].top, NULL); LineTo(hdc, bias_check[i].right, bias_check[i].bottom); } - compare_hash(bmi, bits, sha1, "more diagonal solid lines"); - memset(bits, 0xcc, dib_size); + compare_hash(hdc, bmi, bits, "more diagonal solid lines"); /* solid brush PatBlt */ solid_brush = CreateSolidBrush(RGB(0x33, 0xaa, 0xff)); @@ -672,8 +1572,6 @@ static void draw_graphics(HDC hdc, BITMAPINFO *bmi, BYTE *bits, const char ***sh for(i = 0, y = 10; i < 256; i++) { - BOOL ret; - ret = PatBlt(hdc, 10, y, 100, 10, rop3[i]); if(rop_uses_src(rop3[i])) @@ -685,8 +1583,7 @@ static void draw_graphics(HDC hdc, BITMAPINFO *bmi, BYTE *bits, const char ***sh } } - compare_hash(bmi, bits, sha1, "solid patblt"); - memset(bits, 0xcc, dib_size); + compare_hash(hdc, bmi, bits, "solid patblt"); /* clipped lines */ hrgn = CreateRectRgn(10, 10, 200, 20); @@ -702,24 +1599,21 @@ static void draw_graphics(HDC hdc, BITMAPINFO *bmi, BYTE *bits, const char ***sh MoveToEx(hdc, hline_clips[i].left, hline_clips[i].top, NULL); LineTo(hdc, hline_clips[i].right, hline_clips[i].bottom); } - compare_hash(bmi, bits, sha1, "clipped solid hlines"); - memset(bits, 0xcc, dib_size); + compare_hash(hdc, bmi, bits, "clipped solid hlines"); for(i = 0; i < sizeof(vline_clips)/sizeof(vline_clips[0]); i++) { MoveToEx(hdc, vline_clips[i].left, vline_clips[i].top, NULL); LineTo(hdc, vline_clips[i].right, vline_clips[i].bottom); } - compare_hash(bmi, bits, sha1, "clipped solid vlines"); - memset(bits, 0xcc, dib_size); + compare_hash(hdc, bmi, bits, "clipped solid vlines"); for(i = 0; i < sizeof(line_clips)/sizeof(line_clips[0]); i++) { MoveToEx(hdc, line_clips[i].left, line_clips[i].top, NULL); LineTo(hdc, line_clips[i].right, line_clips[i].bottom); } - compare_hash(bmi, bits, sha1, "clipped solid diagonal lines"); - memset(bits, 0xcc, dib_size); + compare_hash(hdc, bmi, bits, "clipped solid diagonal lines"); /* clipped PatBlt */ for(i = 0; i < sizeof(patblt_clips) / sizeof(patblt_clips[0]); i++) @@ -728,8 +1622,7 @@ static void draw_graphics(HDC hdc, BITMAPINFO *bmi, BYTE *bits, const char ***sh patblt_clips[i].right - patblt_clips[i].left, patblt_clips[i].bottom - patblt_clips[i].top, PATCOPY); } - compare_hash(bmi, bits, sha1, "clipped patblt"); - memset(bits, 0xcc, dib_size); + compare_hash(hdc, bmi, bits, "clipped patblt"); /* clipped dashed lines */ dashed_pen = CreatePen(PS_DASH, 1, RGB(0xff, 0, 0)); @@ -742,40 +1635,35 @@ static void draw_graphics(HDC hdc, BITMAPINFO *bmi, BYTE *bits, const char ***sh MoveToEx(hdc, hline_clips[i].left, hline_clips[i].top, NULL); LineTo(hdc, hline_clips[i].right, hline_clips[i].bottom); } - compare_hash(bmi, bits, sha1, "clipped dashed hlines"); - memset(bits, 0xcc, dib_size); + compare_hash(hdc, bmi, bits, "clipped dashed hlines"); for(i = 0; i < sizeof(hline_clips)/sizeof(hline_clips[0]); i++) { MoveToEx(hdc, hline_clips[i].right - 1, hline_clips[i].bottom, NULL); LineTo(hdc, hline_clips[i].left - 1, hline_clips[i].top); } - compare_hash(bmi, bits, sha1, "clipped dashed hlines r -> l"); - memset(bits, 0xcc, dib_size); + compare_hash(hdc, bmi, bits, "clipped dashed hlines r -> l"); for(i = 0; i < sizeof(vline_clips)/sizeof(vline_clips[0]); i++) { MoveToEx(hdc, vline_clips[i].left, vline_clips[i].top, NULL); LineTo(hdc, vline_clips[i].right, vline_clips[i].bottom); } - compare_hash(bmi, bits, sha1, "clipped dashed vlines"); - memset(bits, 0xcc, dib_size); + compare_hash(hdc, bmi, bits, "clipped dashed vlines"); for(i = 0; i < sizeof(vline_clips)/sizeof(vline_clips[0]); i++) { MoveToEx(hdc, vline_clips[i].right, vline_clips[i].bottom - 1, NULL); LineTo(hdc, vline_clips[i].left, vline_clips[i].top - 1); } - compare_hash(bmi, bits, sha1, "clipped dashed vlines b -> t"); - memset(bits, 0xcc, dib_size); + compare_hash(hdc, bmi, bits, "clipped dashed vlines b -> t"); for(i = 0; i < sizeof(line_clips)/sizeof(line_clips[0]); i++) { MoveToEx(hdc, line_clips[i].left, line_clips[i].top, NULL); LineTo(hdc, line_clips[i].right, line_clips[i].bottom); } - compare_hash(bmi, bits, sha1, "clipped dashed diagonal lines"); - memset(bits, 0xcc, dib_size); + compare_hash(hdc, bmi, bits, "clipped dashed diagonal lines"); SetBkMode(hdc, OPAQUE); @@ -784,8 +1672,7 @@ static void draw_graphics(HDC hdc, BITMAPINFO *bmi, BYTE *bits, const char ***sh MoveToEx(hdc, line_clips[i].left, line_clips[i].top, NULL); LineTo(hdc, line_clips[i].right, line_clips[i].bottom); } - compare_hash(bmi, bits, sha1, "clipped opaque dashed diagonal lines"); - memset(bits, 0xcc, dib_size); + compare_hash(hdc, bmi, bits, "clipped opaque dashed diagonal lines"); ExtSelectClipRgn(hdc, NULL, RGN_COPY); @@ -808,8 +1695,6 @@ static void draw_graphics(HDC hdc, BITMAPINFO *bmi, BYTE *bits, const char ***sh for(i = 0, y = 10; i < 256; i++) { - BOOL ret; - if(!rop_uses_src(rop3[i])) { ret = PatBlt(hdc, 10 + i, y, 100, 20, rop3[i]); @@ -817,8 +1702,10 @@ static void draw_graphics(HDC hdc, BITMAPINFO *bmi, BYTE *bits, const char ***sh y += 25; } } - compare_hash_broken_todo(bmi, bits, sha1, "top-down 8888 dib brush patblt", dib_is_1bpp ? 2 : 0, dib_is_1bpp); - memset(bits, 0xcc, dib_size); + if (bmi->bmiHeader.biBitCount == 8 && bmi->bmiHeader.biClrUsed == 256) /* 8-bpp grayscale broken on NT4 */ + compare_hash_broken_todo(hdc, bmi, bits, "top-down 8888 dib brush patblt", 1, FALSE); + else + compare_hash_broken_todo(hdc, bmi, bits, "top-down 8888 dib brush patblt", dib_is_1bpp ? 2 : 0, dib_is_1bpp); SelectObject(hdc, orig_brush); DeleteObject(dib_brush); @@ -838,8 +1725,6 @@ static void draw_graphics(HDC hdc, BITMAPINFO *bmi, BYTE *bits, const char ***sh for(i = 0, y = 10; i < 256; i++) { - BOOL ret; - if(!rop_uses_src(rop3[i])) { ret = PatBlt(hdc, 10 + i, y, 100, 20, rop3[i]); @@ -847,8 +1732,10 @@ static void draw_graphics(HDC hdc, BITMAPINFO *bmi, BYTE *bits, const char ***sh y += 25; } } - compare_hash_broken_todo(bmi, bits, sha1, "bottom-up 8888 dib brush patblt", dib_is_1bpp ? 2 : 0, dib_is_1bpp); - memset(bits, 0xcc, dib_size); + if (bmi->bmiHeader.biBitCount == 8 && bmi->bmiHeader.biClrUsed == 256) /* 8-bpp grayscale broken on NT4 */ + compare_hash_broken_todo(hdc, bmi, bits, "bottom-up 8888 dib brush patblt", 1, FALSE); + else + compare_hash_broken_todo(hdc, bmi, bits, "bottom-up 8888 dib brush patblt", dib_is_1bpp ? 2 : 0, dib_is_1bpp); SelectObject(hdc, orig_brush); DeleteObject(dib_brush); @@ -868,8 +1755,6 @@ static void draw_graphics(HDC hdc, BITMAPINFO *bmi, BYTE *bits, const char ***sh for(i = 0, y = 10; i < 256; i++) { - BOOL ret; - if(!rop_uses_src(rop3[i])) { ret = PatBlt(hdc, 10 + i, y, 100, 20, rop3[i]); @@ -877,8 +1762,10 @@ static void draw_graphics(HDC hdc, BITMAPINFO *bmi, BYTE *bits, const char ***sh y += 25; } } - compare_hash_broken_todo(bmi, bits, sha1, "top-down 24 bpp brush patblt", dib_is_1bpp ? 2 : 0, dib_is_1bpp); - memset(bits, 0xcc, dib_size); + if (bmi->bmiHeader.biBitCount == 8 && bmi->bmiHeader.biClrUsed == 256) /* 8-bpp grayscale broken on NT4 */ + compare_hash_broken_todo(hdc, bmi, bits, "top-down 24 bpp brush patblt", 1, FALSE); + else + compare_hash_broken_todo(hdc, bmi, bits, "top-down 24 bpp brush patblt", dib_is_1bpp ? 2 : 0, dib_is_1bpp); SelectObject(hdc, orig_brush); DeleteObject(dib_brush); @@ -898,8 +1785,6 @@ static void draw_graphics(HDC hdc, BITMAPINFO *bmi, BYTE *bits, const char ***sh for(i = 0, y = 10; i < 256; i++) { - BOOL ret; - if(!rop_uses_src(rop3[i])) { ret = PatBlt(hdc, 10 + i, y, 100, 20, rop3[i]); @@ -907,8 +1792,10 @@ static void draw_graphics(HDC hdc, BITMAPINFO *bmi, BYTE *bits, const char ***sh y += 25; } } - compare_hash_broken_todo(bmi, bits, sha1, "top-down 555 dib brush patblt", dib_is_1bpp ? 1 : 0, dib_is_1bpp); - memset(bits, 0xcc, dib_size); + if (bmi->bmiHeader.biBitCount == 8 && bmi->bmiHeader.biClrUsed == 256) /* 8-bpp grayscale broken on NT4 */ + compare_hash_broken_todo(hdc, bmi, bits, "top-down 555 dib brush patblt", 1, FALSE); + else + compare_hash_broken_todo(hdc, bmi, bits, "top-down 555 dib brush patblt", dib_is_1bpp ? 1 : 0, dib_is_1bpp); SelectObject(hdc, orig_brush); DeleteObject(dib_brush); @@ -919,11 +1806,11 @@ static void draw_graphics(HDC hdc, BITMAPINFO *bmi, BYTE *bits, const char ***sh brush_bi->bmiHeader = dib_brush_header_8; brush_bi->bmiHeader.biClrUsed = 3; - memset(brush_bi->bmiColors, 0, brush_bi->bmiHeader.biClrUsed * sizeof(RGBQUAD)); - brush_bi->bmiColors[0].rgbRed = 0xff; - brush_bi->bmiColors[1].rgbRed = 0xff; - brush_bi->bmiColors[1].rgbGreen = 0xff; - brush_bi->bmiColors[1].rgbBlue = 0xff; + memset(brush_colors, 0, brush_bi->bmiHeader.biClrUsed * sizeof(RGBQUAD)); + brush_colors[0].rgbRed = 0xff; + brush_colors[1].rgbRed = 0xff; + brush_colors[1].rgbGreen = 0xff; + brush_colors[1].rgbBlue = 0xff; brush_bits = (BYTE*)brush_bi + sizeof(BITMAPINFOHEADER) + brush_bi->bmiHeader.biClrUsed * sizeof(RGBQUAD); memset(brush_bits, 0, 16 * 16 * sizeof(BYTE)); @@ -938,8 +1825,6 @@ static void draw_graphics(HDC hdc, BITMAPINFO *bmi, BYTE *bits, const char ***sh for(i = 0, y = 10; i < 256; i++) { - BOOL ret; - if(!rop_uses_src(rop3[i])) { ret = PatBlt(hdc, 10 + i, y, 100, 20, rop3[i]); @@ -947,8 +1832,7 @@ static void draw_graphics(HDC hdc, BITMAPINFO *bmi, BYTE *bits, const char ***sh y += 25; } } - compare_hash_broken_todo(bmi, bits, sha1, "top-down 8 bpp dib brush patblt", dib_is_1bpp ? 2 : 0, dib_is_1bpp); - memset(bits, 0xcc, dib_size); + compare_hash_broken_todo(hdc, bmi, bits, "top-down 8 bpp dib brush patblt", dib_is_1bpp ? 2 : 0, dib_is_1bpp); SelectObject(hdc, orig_brush); DeleteObject(dib_brush); @@ -963,8 +1847,6 @@ static void draw_graphics(HDC hdc, BITMAPINFO *bmi, BYTE *bits, const char ***sh for(i = 0, y = 10; i < 256; i++) { - BOOL ret; - if(!rop_uses_src(rop3[i])) { ret = PatBlt(hdc, 10 + i, y, 100, 20, rop3[i]); @@ -972,8 +1854,7 @@ static void draw_graphics(HDC hdc, BITMAPINFO *bmi, BYTE *bits, const char ***sh y += 25; } } - compare_hash_broken_todo(bmi, bits, sha1, "top-down 4 bpp dib brush patblt", dib_is_1bpp ? 2 : 0, dib_is_1bpp); - memset(bits, 0xcc, dib_size); + compare_hash_broken_todo(hdc, bmi, bits, "top-down 4 bpp dib brush patblt", dib_is_1bpp ? 2 : 0, dib_is_1bpp); SelectObject(hdc, orig_brush); DeleteObject(dib_brush); @@ -991,8 +1872,6 @@ static void draw_graphics(HDC hdc, BITMAPINFO *bmi, BYTE *bits, const char ***sh SelectObject(hdc, dib_brush); for(i = 0, y = 10; i < 256; i++) { - BOOL ret; - if(!rop_uses_src(rop3[i])) { ret = PatBlt(hdc, 10 + i, y, 100, 20, rop3[i]); @@ -1001,11 +1880,37 @@ static void draw_graphics(HDC hdc, BITMAPINFO *bmi, BYTE *bits, const char ***sh } } - compare_hash_broken_todo(bmi, bits, sha1, "top-down 1 bpp dib brush patblt", dib_is_1bpp ? 2 : 0, dib_is_1bpp); - memset(bits, 0xcc, dib_size); + compare_hash_broken_todo(hdc, bmi, bits, "top-down 1 bpp dib brush patblt", dib_is_1bpp ? 2 : 0, dib_is_1bpp); + SelectObject(hdc, orig_brush); + DeleteObject(dib_brush); + + /* 1 bpp ddb pattern brush */ + + old_text = GetTextColor( hdc ); + old_bkgnd = GetBkColor( hdc ); + bmp = CreateBitmap( 16, 16, 1, 1, ddb_brush_bits ); + dib_brush = CreatePatternBrush( bmp ); + SelectObject(hdc, dib_brush); + for(i = 0, y = 10; i < 256; i++) + { + SetTextColor(hdc, RGB( i, 2*i, 255 - i ) ); + SetBkColor(hdc, RGB( 255 - i, i / 3, i ) ); + if(!rop_uses_src(rop3[i])) + { + ret = PatBlt(hdc, 10 + i, y, 100, 20, rop3[i]); + ok(ret, "got FALSE for %x\n", rop3[i]); + y += 25; + } + } + + compare_hash_broken_todo(hdc, bmi, bits, "1 bpp ddb brush patblt", dib_is_1bpp ? 3 : 0, dib_is_1bpp); + + DeleteObject(bmp); SelectObject(hdc, orig_brush); SetBrushOrgEx(hdc, 0, 0, NULL); + SetTextColor(hdc, old_text); + SetBkColor(hdc, old_bkgnd); /* Rectangle */ @@ -1023,22 +1928,20 @@ static void draw_graphics(HDC hdc, BITMAPINFO *bmi, BYTE *bits, const char ***sh Rectangle(hdc, rectangles[i].left, rectangles[i].top + 150, rectangles[i].right, rectangles[i].bottom + 150); } - compare_hash(bmi, bits, sha1, "rectangles"); - memset(bits, 0xcc, dib_size); + compare_hash(hdc, bmi, bits, "rectangles"); SelectObject(hdc, solid_pen); /* PaintRgn */ PaintRgn(hdc, hrgn); - compare_hash(bmi, bits, sha1, "PaintRgn"); - memset(bits, 0xcc, dib_size); + compare_hash(hdc, bmi, bits, "PaintRgn"); /* RTL rectangles */ if( !pSetLayout ) { win_skip("Don't have SetLayout\n"); - (*sha1)++; + skip_compare(1); } else { @@ -1046,16 +1949,14 @@ static void draw_graphics(HDC hdc, BITMAPINFO *bmi, BYTE *bits, const char ***sh PaintRgn(hdc, hrgn); PatBlt(hdc, 10, 250, 10, 10, PATCOPY); Rectangle(hdc, 100, 250, 110, 260); - compare_hash(bmi, bits, sha1, "rtl"); - memset(bits, 0xcc, dib_size); + compare_hash(hdc, bmi, bits, "rtl"); pSetLayout(hdc, LAYOUT_LTR); } + DeleteObject( hrgn ); for(i = 0, y = 10; i < 256; i++) { - BOOL ret; - if(!rop_uses_src(rop3[i])) { for(hatch_style = HS_HORIZONTAL; hatch_style <= HS_DIAGCROSS; hatch_style++) @@ -1071,8 +1972,7 @@ static void draw_graphics(HDC hdc, BITMAPINFO *bmi, BYTE *bits, const char ***sh } } - compare_hash_broken_todo(bmi, bits, sha1, "hatch brushes", 1, FALSE); /* nt4 is different */ - memset(bits, 0xcc, dib_size); + compare_hash_broken_todo(hdc, bmi, bits, "hatch brushes", 1, FALSE); /* nt4 is different */ /* overlapping blits */ @@ -1083,8 +1983,7 @@ static void draw_graphics(HDC hdc, BITMAPINFO *bmi, BYTE *bits, const char ***sh Rectangle(hdc, 15, 15, 20, 20); Rectangle(hdc, 15, 20, 50, 45); BitBlt( hdc, 20, 20, 100, 100, hdc, 10, 10, SRCCOPY ); - compare_hash(bmi, bits, sha1, "overlapping BitBlt SRCCOPY +x, +y"); - memset(bits, 0xcc, dib_size); + compare_hash(hdc, bmi, bits, "overlapping BitBlt SRCCOPY +x, +y"); Rectangle(hdc, 10, 10, 100, 100); Rectangle(hdc, 20, 15, 30, 40); @@ -1092,18 +1991,16 @@ static void draw_graphics(HDC hdc, BITMAPINFO *bmi, BYTE *bits, const char ***sh Rectangle(hdc, 15, 20, 50, 45); BitBlt( hdc, 10, 10, 100, 100, hdc, 20, 20, SRCCOPY ); if (bmi->bmiHeader.biBitCount == 1) /* Windows gets this one wrong */ - compare_hash_broken_todo(bmi, bits, sha1, "overlapping BitBlt SRCCOPY -x, -y",1, FALSE); + compare_hash_broken_todo(hdc, bmi, bits, "overlapping BitBlt SRCCOPY -x, -y",1, FALSE); else - compare_hash(bmi, bits, sha1, "overlapping BitBlt SRCCOPY -x, -y"); - memset(bits, 0xcc, dib_size); + compare_hash(hdc, bmi, bits, "overlapping BitBlt SRCCOPY -x, -y"); Rectangle(hdc, 10, 10, 100, 100); Rectangle(hdc, 20, 15, 30, 40); Rectangle(hdc, 15, 15, 20, 20); Rectangle(hdc, 15, 20, 50, 45); BitBlt( hdc, 20, 10, 100, 100, hdc, 10, 20, SRCCOPY ); - compare_hash(bmi, bits, sha1, "overlapping BitBlt SRCCOPY +x, -y"); - memset(bits, 0xcc, dib_size); + compare_hash(hdc, bmi, bits, "overlapping BitBlt SRCCOPY +x, -y"); Rectangle(hdc, 10, 10, 100, 100); Rectangle(hdc, 20, 15, 30, 40); @@ -1111,26 +2008,23 @@ static void draw_graphics(HDC hdc, BITMAPINFO *bmi, BYTE *bits, const char ***sh Rectangle(hdc, 15, 20, 50, 45); BitBlt( hdc, 10, 20, 100, 100, hdc, 20, 10, SRCCOPY ); if (bmi->bmiHeader.biBitCount == 1) /* Windows gets this one wrong */ - compare_hash_broken_todo(bmi, bits, sha1, "overlapping BitBlt SRCCOPY -x, +y", 1, FALSE ); + compare_hash_broken_todo(hdc, bmi, bits, "overlapping BitBlt SRCCOPY -x, +y", 1, FALSE ); else - compare_hash(bmi, bits, sha1, "overlapping BitBlt SRCCOPY -x, +y" ); - memset(bits, 0xcc, dib_size); + compare_hash(hdc, bmi, bits, "overlapping BitBlt SRCCOPY -x, +y" ); Rectangle(hdc, 10, 10, 100, 100); Rectangle(hdc, 20, 15, 30, 40); Rectangle(hdc, 15, 15, 20, 20); Rectangle(hdc, 15, 20, 50, 45); BitBlt( hdc, 20, 20, 100, 100, hdc, 10, 10, PATPAINT ); - compare_hash(bmi, bits, sha1, "overlapping BitBlt PATPAINT +x, +y"); - memset(bits, 0xcc, dib_size); + compare_hash(hdc, bmi, bits, "overlapping BitBlt PATPAINT +x, +y"); Rectangle(hdc, 10, 10, 100, 100); Rectangle(hdc, 20, 15, 30, 40); Rectangle(hdc, 15, 15, 20, 20); Rectangle(hdc, 15, 20, 50, 45); BitBlt( hdc, 10, 10, 100, 100, hdc, 20, 20, PATPAINT ); - compare_hash(bmi, bits, sha1, "overlapping BitBlt PATPAINT -x, -y"); - memset(bits, 0xcc, dib_size); + compare_hash(hdc, bmi, bits, "overlapping BitBlt PATPAINT -x, -y"); Rectangle(hdc, 10, 10, 100, 100); Rectangle(hdc, 20, 15, 30, 40); @@ -1138,38 +2032,833 @@ static void draw_graphics(HDC hdc, BITMAPINFO *bmi, BYTE *bits, const char ***sh Rectangle(hdc, 15, 20, 50, 45); BitBlt( hdc, 20, 10, 100, 100, hdc, 10, 20, PATPAINT ); if (bmi->bmiHeader.biBitCount >= 24) /* Windows gets this one wrong */ - compare_hash_broken_todo(bmi, bits, sha1, "overlapping BitBlt PATPAINT +x, -y", 1, FALSE); + compare_hash_broken_todo(hdc, bmi, bits, "overlapping BitBlt PATPAINT +x, -y", 1, FALSE); else - compare_hash(bmi, bits, sha1, "overlapping BitBlt PATPAINT +x, -y"); - memset(bits, 0xcc, dib_size); + compare_hash(hdc, bmi, bits, "overlapping BitBlt PATPAINT +x, -y"); Rectangle(hdc, 10, 10, 100, 100); Rectangle(hdc, 20, 15, 30, 40); Rectangle(hdc, 15, 15, 20, 20); Rectangle(hdc, 15, 20, 50, 45); BitBlt( hdc, 10, 20, 100, 100, hdc, 20, 10, PATPAINT ); - compare_hash(bmi, bits, sha1, "overlapping BitBlt PATPAINT -x, +y" ); - memset(bits, 0xcc, dib_size); + compare_hash(hdc, bmi, bits, "overlapping BitBlt PATPAINT -x, +y" ); + + /* blitting with 32-bpp BI_RGB source */ + + memset( dib_src_buf, 0, sizeof(dib_src_buf) ); + src_bi->bmiHeader.biSize = sizeof(bmi->bmiHeader); + src_bi->bmiHeader.biHeight = 256; + src_bi->bmiHeader.biWidth = 256; + src_bi->bmiHeader.biBitCount = 32; + src_bi->bmiHeader.biPlanes = 1; + src_bi->bmiHeader.biCompression = BI_RGB; + bmp = CreateDIBSection(0, src_bi, DIB_RGB_COLORS, (void**)&src_bits, NULL, 0); + SelectObject( src_dc, bmp ); + for (y = 0; y < 256; y++) + for (x = 0; x < 256; x++) + { + BYTE a = (x + y) * 2; + BYTE r = (BYTE)(y + 2 * x) * a / 255; + BYTE g = (BYTE)(x + y / 3) * a / 255; + BYTE b = (BYTE)(x / 3 + 2 * y) * a / 255; + ((DWORD *)src_bits)[y * 256 + x] = (a << 24) | RGB( r, g, b ); + } + + BitBlt( hdc, 100, 100, 256, 256, src_dc, 0, 0, SRCCOPY ); + if (bmi->bmiHeader.biBitCount == 8) /* broken on NT4 */ + compare_hash_broken_todo(hdc, bmi, bits, "BitBlt src 32-bpp SRCCOPY", 1, FALSE ); + else + compare_hash(hdc, bmi, bits, "BitBlt src 32-bpp SRCCOPY" ); + + blend.SourceConstantAlpha = 0xd0; + blend.AlphaFormat = 0; + if (pGdiAlphaBlend) pGdiAlphaBlend( hdc, 100, 100, 256, 256, src_dc, 0, 0, 256, 256, blend ); + if (bmi->bmiHeader.biBitCount == 16 && bmi->bmiHeader.biCompression == BI_RGB) /* 555 broken on w2k */ + { + if (!pGdiAlphaBlend) skip_compare(2); + else compare_hash_broken_todo(hdc, bmi, bits, "AlphaBlend src 32-bpp no alpha", 1, FALSE ); + } + else + { + if (!pGdiAlphaBlend) skip_compare(1); + else compare_hash_broken_todo(hdc, bmi, bits, "AlphaBlend src 32-bpp no alpha", 0, dib_is_1bpp ); + } + + blend.SourceConstantAlpha = 0xb0; + blend.AlphaFormat = AC_SRC_ALPHA; + if (pGdiAlphaBlend) pGdiAlphaBlend( hdc, 50, 50, 256, 256, src_dc, 0, 0, 256, 256, blend ); + if (bmi->bmiHeader.biBitCount == 16 && bmi->bmiHeader.biCompression == BI_RGB) /* 555 broken on w2k */ + { + if (!pGdiAlphaBlend) skip_compare(2); + else compare_hash_broken_todo(hdc, bmi, bits, "AlphaBlend src 32-bpp alpha", 1, FALSE ); + } + else + { + if (!pGdiAlphaBlend) skip_compare(1); + else compare_hash_broken_todo(hdc, bmi, bits, "AlphaBlend src 32-bpp alpha", 0, dib_is_1bpp ); + } + + /* blitting with 32-bpp r10g10b10 source */ + + src_bi->bmiHeader.biBitCount = 32; + src_bi->bmiHeader.biCompression = BI_BITFIELDS; + ((DWORD *)src_bi->bmiColors)[0] = 0x3ff00000; + ((DWORD *)src_bi->bmiColors)[1] = 0x000ffc00; + ((DWORD *)src_bi->bmiColors)[2] = 0x000003ff; + bmp = CreateDIBSection(0, src_bi, DIB_RGB_COLORS, (void**)&src_bits, NULL, 0); + SelectObject( src_dc, bmp ); + for (y = 0; y < 256; y++) + for (x = 0; x < 256; x++) + { + WORD r = (7 * x + 3 * y) % 1024; + WORD g = (11 * x + y / 3) % 1024; + WORD b = (x / 3 + 9 * y) % 1024; + ((DWORD *)src_bits)[y * 256 + x] = r << 20 | g << 10 | b; + } + + BitBlt( hdc, 100, 100, 256, 256, src_dc, 0, 0, SRCCOPY ); + if (bmi->bmiHeader.biBitCount == 8) /* broken on NT4 */ + compare_hash_broken_todo(hdc, bmi, bits, "BitBlt src 32-bpp r10g10b10 SRCCOPY", 1, FALSE ); + else + compare_hash(hdc, bmi, bits, "BitBlt src 32-bpp r10g10b10 SRCCOPY" ); + + /* blitting with 32-bpp b6g6r6 source */ + + src_bi->bmiHeader.biBitCount = 32; + src_bi->bmiHeader.biCompression = BI_BITFIELDS; + ((DWORD *)src_bi->bmiColors)[0] = 0x00003f; + ((DWORD *)src_bi->bmiColors)[1] = 0x000fc0; + ((DWORD *)src_bi->bmiColors)[2] = 0x03f000; + bmp = CreateDIBSection(0, src_bi, DIB_RGB_COLORS, (void**)&src_bits, NULL, 0); + SelectObject( src_dc, bmp ); + for (y = 0; y < 256; y++) + for (x = 0; x < 256; x++) + { + BYTE r = (y + 2 * x) % 64; + BYTE g = (x + y / 3) % 64; + BYTE b = (x / 3 + 2 * y) % 64; + ((DWORD *)src_bits)[y * 256 + x] = r | g << 6 | b << 12; + } + + BitBlt( hdc, 100, 100, 256, 256, src_dc, 0, 0, SRCCOPY ); + if (bmi->bmiHeader.biBitCount == 8) /* broken on NT4 */ + compare_hash_broken_todo(hdc, bmi, bits, "BitBlt src 32-bpp b6g6r6 SRCCOPY", 1, FALSE ); + else + compare_hash(hdc, bmi, bits, "BitBlt src 32-bpp b6g6r6 SRCCOPY" ); + + /* blitting with 24-bpp source */ + + src_bi->bmiHeader.biBitCount = 24; + src_bi->bmiHeader.biCompression = BI_RGB; + bmp = CreateDIBSection(0, src_bi, DIB_RGB_COLORS, (void**)&src_bits, NULL, 0); + DeleteObject( SelectObject( src_dc, bmp ) ); + for (y = 0; y < 256; y++) + for (x = 0; x < 256; x++) + { + src_bits[(y * 256 + x) * 3 + 0] = x + 3 * y; + src_bits[(y * 256 + x) * 3 + 1] = 2 * x + 7 * y; + src_bits[(y * 256 + x) * 3 + 2] = 5 * x + 12 * y; + } + + BitBlt( hdc, 100, 100, 256, 256, src_dc, 0, 0, SRCCOPY ); + if (bmi->bmiHeader.biBitCount == 8) /* broken on NT4 */ + compare_hash_broken_todo(hdc, bmi, bits, "BitBlt src 24-bpp SRCCOPY", 1, FALSE ); + else + compare_hash(hdc, bmi, bits, "BitBlt src 24-bpp SRCCOPY" ); + + blend.SourceConstantAlpha = 0xe0; + blend.AlphaFormat = 0; + if (pGdiAlphaBlend) pGdiAlphaBlend( hdc, 100, 100, 256, 256, src_dc, 0, 0, 256, 256, blend ); + if (bmi->bmiHeader.biBitCount == 16 && bmi->bmiHeader.biCompression == BI_RGB) /* 555 broken on w2k */ + { + if (!pGdiAlphaBlend) skip_compare(2); + else compare_hash_broken_todo(hdc, bmi, bits, "AlphaBlend src 24-bpp", 1, FALSE ); + } + else + { + if (!pGdiAlphaBlend) skip_compare(1); + else compare_hash_broken_todo(hdc, bmi, bits, "AlphaBlend src 24-bpp", 0, dib_is_1bpp ); + } + + /* blitting with 16-bpp BI_RGB source */ + + src_bi->bmiHeader.biBitCount = 16; + src_bi->bmiHeader.biCompression = BI_RGB; + bmp = CreateDIBSection(0, src_bi, DIB_RGB_COLORS, (void**)&src_bits, NULL, 0); + DeleteObject( SelectObject( src_dc, bmp ) ); + for (y = 0; y < 256; y++) + for (x = 0; x < 256; x++) + ((WORD *)src_bits)[y * 256 + x] = x | x << 4 | x << 8 | y << 3 | y << 7; + + BitBlt( hdc, 100, 100, 256, 256, src_dc, 0, 0, SRCCOPY ); + if (bmi->bmiHeader.biBitCount == 8 && bmi->bmiHeader.biClrUsed > 5) /* broken on NT4 */ + compare_hash_broken_todo(hdc, bmi, bits, "BitBlt src 16-bpp SRCCOPY", 1, FALSE ); + else + compare_hash(hdc, bmi, bits, "BitBlt src 16-bpp SRCCOPY" ); + + /* blitting with 16-bpp b4g4r4 source */ + + src_bi->bmiHeader.biBitCount = 16; + src_bi->bmiHeader.biCompression = BI_BITFIELDS; + ((DWORD *)src_bi->bmiColors)[0] = 0x00000f; + ((DWORD *)src_bi->bmiColors)[1] = 0x0000f0; + ((DWORD *)src_bi->bmiColors)[2] = 0x000f00; + bmp = CreateDIBSection(0, src_bi, DIB_RGB_COLORS, (void**)&src_bits, NULL, 0); + DeleteObject( SelectObject( src_dc, bmp ) ); + for (y = 0; y < 256; y++) + for (x = 0; x < 256; x++) + ((WORD *)src_bits)[y * 256 + x] = x | x << 4 | x << 8 | y << 3 | y << 7; + + BitBlt( hdc, 100, 100, 256, 256, src_dc, 0, 0, SRCCOPY ); + if (bmi->bmiHeader.biBitCount == 8 && bmi->bmiHeader.biClrUsed > 5) /* broken on NT4 */ + compare_hash_broken_todo(hdc, bmi, bits, "BitBlt src 16-bpp b4g4r4 SRCCOPY", 1, FALSE ); + else + compare_hash(hdc, bmi, bits, "BitBlt src 16-bpp b4g4r4 SRCCOPY" ); + + /* blitting with 8-bpp source */ + + src_bi->bmiHeader.biBitCount = 8; + src_bi->bmiHeader.biCompression = BI_RGB; + src_bi->bmiHeader.biClrUsed = 160; + for (i = 0; i < 256; i++) ((DWORD *)src_bi->bmiColors)[i] = i | (i * 3) << 8 | (i / 2) << 16; + bmp = CreateDIBSection(0, src_bi, DIB_RGB_COLORS, (void**)&src_bits, NULL, 0); + DeleteObject( SelectObject( src_dc, bmp ) ); + for (y = 0; y < 256; y++) + for (x = 0; x < 256; x++) + src_bits[y * 256 + x] = 3 * x + 5 * y; + + BitBlt( hdc, 100, 100, 256, 256, src_dc, 0, 0, SRCCOPY ); + compare_hash(hdc, bmi, bits, "BitBlt src 8-bpp SRCCOPY" ); + + blend.SourceConstantAlpha = 0xd0; + blend.AlphaFormat = 0; + if (pGdiAlphaBlend) pGdiAlphaBlend( hdc, 100, 100, 256, 256, src_dc, 0, 0, 256, 256, blend ); + if (bmi->bmiHeader.biBitCount == 16 && bmi->bmiHeader.biCompression == BI_RGB) /* 555 broken on w2k */ + { + if (!pGdiAlphaBlend) skip_compare(2); + else compare_hash_broken_todo(hdc, bmi, bits, "AlphaBlend src 8-bpp", 1, FALSE ); + } + else + { + if (!pGdiAlphaBlend) skip_compare(1); + else compare_hash_broken_todo(hdc, bmi, bits, "AlphaBlend src 8-bpp", 0, dib_is_1bpp ); + } + + /* blitting with 4-bpp source */ + + src_bi->bmiHeader.biBitCount = 4; + src_bi->bmiHeader.biClrUsed = 12; + for (i = 0; i < 16; i++) ((DWORD *)src_bi->bmiColors)[i] = i | (i * 5) << 8 | (i * 19) << 16; + bmp = CreateDIBSection(0, src_bi, DIB_RGB_COLORS, (void**)&src_bits, NULL, 0); + DeleteObject( SelectObject( src_dc, bmp ) ); + for (y = 0; y < 256; y++) + for (x = 0; x < 256; x += 2) + src_bits[(y * 256 + x) / 2] = 7 * x + 3 * y; + + BitBlt( hdc, 100, 100, 256, 256, src_dc, 0, 0, SRCCOPY ); + compare_hash(hdc, bmi, bits, "BitBlt src 4-bpp SRCCOPY" ); + + /* blitting with 1-bpp source */ + + src_bi->bmiHeader.biBitCount = 1; + src_bi->bmiHeader.biClrUsed = 0; + for (i = 0; i < 2; i++) ((DWORD *)src_bi->bmiColors)[i] = (i + 37) | (i * 91) << 8 | (i * 53) << 16; + bmp = CreateDIBSection(0, src_bi, DIB_RGB_COLORS, (void**)&src_bits, NULL, 0); + DeleteObject( SelectObject( src_dc, bmp ) ); + for (y = 0; y < 256; y++) + for (x = 0; x < 256; x += 8) + src_bits[(y * 256 + x) / 8] = 7 * x + 3 * y; + + BitBlt( hdc, 100, 100, 256, 256, src_dc, 0, 0, SRCCOPY ); + compare_hash(hdc, bmi, bits, "BitBlt src 1-bpp SRCCOPY" ); + + blend.SourceConstantAlpha = 0x90; + blend.AlphaFormat = 0; + if (pGdiAlphaBlend) pGdiAlphaBlend( hdc, 100, 100, 256, 256, src_dc, 0, 0, 256, 256, blend ); + if (bmi->bmiHeader.biBitCount == 16 && bmi->bmiHeader.biCompression == BI_RGB) /* 555 broken on w2k */ + { + if (!pGdiAlphaBlend) skip_compare(2); + else compare_hash_broken_todo(hdc, bmi, bits, "AlphaBlend src 1-bpp", 1, FALSE ); + } + else + { + if (!pGdiAlphaBlend) skip_compare(1); + else compare_hash(hdc, bmi, bits, "AlphaBlend src 1-bpp" ); + } + + DeleteDC( src_dc ); + DeleteObject( bmp ); + + /* RLE StretchDIBits */ + src_bi->bmiHeader.biSize = sizeof(src_bi->bmiHeader); + src_bi->bmiHeader.biWidth = 8; + src_bi->bmiHeader.biHeight = 8; + src_bi->bmiHeader.biPlanes = 1; + src_bi->bmiHeader.biBitCount = 8; + src_bi->bmiHeader.biCompression = BI_RLE8; + src_bi->bmiHeader.biClrUsed = 0; + src_bi->bmiHeader.biSizeImage = sizeof(rle8_data); + + for (i = 0; i < 256; i++) + { + src_bi->bmiColors[i].rgbRed = i; + src_bi->bmiColors[i].rgbGreen = i; + src_bi->bmiColors[i].rgbBlue = i; + src_bi->bmiColors[i].rgbReserved = 0; + } + + StretchDIBits( hdc, 10, 10, 7, 7, 0, 0, 7, 7, rle8_data, src_bi, DIB_RGB_COLORS, SRCCOPY ); + StretchDIBits( hdc, 100, 10, 7, 7, 0, 0, 7, 7, rle8_data, src_bi, DIB_RGB_COLORS, SRCAND ); + StretchDIBits( hdc, 200, 10, 7, 7, 0, 1, 7, 7, rle8_data, src_bi, DIB_RGB_COLORS, SRCCOPY ); + StretchDIBits( hdc, 300, 10, 7, 7, 1, 0, 7, 7, rle8_data, src_bi, DIB_RGB_COLORS, SRCCOPY ); + StretchDIBits( hdc, 400, 10, 16, 16, 0, 0, 8, 8, rle8_data, src_bi, DIB_RGB_COLORS, SRCCOPY ); + compare_hash_broken_todo(hdc, bmi, bits, "rle stretchdibits", 0, dib_is_1bpp ); + + /* 32 bpp StretchDIBits */ + + src_bi->bmiHeader.biWidth = 4; + src_bi->bmiHeader.biHeight = 4; + src_bi->bmiHeader.biPlanes = 1; + src_bi->bmiHeader.biBitCount = 32; + src_bi->bmiHeader.biCompression = BI_RGB; + src_bi->bmiHeader.biClrUsed = 0; + src_bi->bmiHeader.biSizeImage = 0; + + ret = StretchDIBits( hdc, 10, 10, 4, 4, 0, 0, 4, 4, four_by_four_data, src_bi, DIB_RGB_COLORS, SRCCOPY ); + ok(ret == 4, "got %d\n", ret); + ret = StretchDIBits( hdc, 20, 10, 4, 4, 0, 0, 4, 4, four_by_four_data, src_bi, DIB_RGB_COLORS, SRCAND ); + ok(ret == 4, "got %d\n", ret); + ret = StretchDIBits( hdc, 30, 10, 3, 3, 1, 1, 3, 3, four_by_four_data, src_bi, DIB_RGB_COLORS, SRCCOPY ); + ok(ret == 4, "got %d\n", ret); + ret = StretchDIBits( hdc, 40, 10, 3, 3, 1, 1, 3, 3, four_by_four_data, src_bi, DIB_RGB_COLORS, SRCAND ); + ok(ret == 4, "got %d\n", ret); + ret = StretchDIBits( hdc, 50, 10, -2, -2, 2, 3, -2, -2, four_by_four_data, src_bi, DIB_RGB_COLORS, SRCCOPY ); + ok(ret == 4, "got %d\n", ret); + ret = StretchDIBits( hdc, 60, 10, -2, -2, 2, 3, -2, -2, four_by_four_data, src_bi, DIB_RGB_COLORS, SRCAND ); + ok(ret == 4, "got %d\n", ret); + + src_bi->bmiHeader.biHeight = -4; + + ret = StretchDIBits( hdc, 10, 100, 4, 4, 0, 0, 4, 4, four_by_four_data, src_bi, DIB_RGB_COLORS, SRCCOPY ); + ok(ret == 4, "got %d\n", ret); + ret = StretchDIBits( hdc, 20, 100, 4, 4, 0, 0, 4, 4, four_by_four_data, src_bi, DIB_RGB_COLORS, SRCAND ); + ok(ret == -4, "got %d\n", ret); + ret = StretchDIBits( hdc, 30, 100, 3, 3, 1, 1, 3, 3, four_by_four_data, src_bi, DIB_RGB_COLORS, SRCCOPY ); + ok(ret == 4, "got %d\n", ret); + ret = StretchDIBits( hdc, 40, 100, 3, 3, 1, 1, 3, 3, four_by_four_data, src_bi, DIB_RGB_COLORS, SRCAND ); + ok(ret == -4, "got %d\n", ret); + ret = StretchDIBits( hdc, 50, 100, -2, -2, 2, 3, -2, -2, four_by_four_data, src_bi, DIB_RGB_COLORS, SRCCOPY ); + ok(ret == 4, "got %d\n", ret); + ret = StretchDIBits( hdc, 60, 100, -2, -2, 2, 3, -2, -2, four_by_four_data, src_bi, DIB_RGB_COLORS, SRCAND ); + ok(ret == -4, "got %d\n", ret); + + compare_hash_broken_todo(hdc, bmi, bits, "stretchdibits", dib_is_8bpp_gray ? 1 : 0, dib_is_8bpp_gray ); + + /* Solid colors */ + for (i = 0; i < 256; i++) + { + solid_patblt( hdc, i * 2, 10, 1, 1, DIBINDEX(i) ); + solid_patblt( hdc, i * 2, 20, 1, 1, PALETTEINDEX(i) ); + solid_patblt( hdc, i * 2, 30, 1, 1, RGB( (i & 0x07) << 5, (i & 0x38) << 2, i & 0xc0 ) ); + solid_patblt( hdc, i * 2, 40, 1, 1, PALETTERGB( (i & 0x07) << 5, (i & 0x38) << 2, i & 0xc0 ) ); + for (j = 0; j < 256; j++) solid_patblt( hdc, i * 2, 50 + j, 1, 1, (j << 24) | i ); + } + + /* A few extra colors that are interesting in the 1bpp case */ + + /* bk color */ + solid_patblt( hdc, 0, 50, 1, 1, RGB( 0, 0xff, 0 ) ); + solid_patblt( hdc, 2, 50, 1, 1, PALETTERGB( 0, 0xff, 0 ) ); + + /* color 0 */ + solid_patblt( hdc, 4, 50, 1, 1, RGB( 0, 0x1, 0xff ) ); + solid_patblt( hdc, 6, 50, 1, 1, PALETTERGB( 0, 0x1, 0xff ) ); + + /* color 1 */ + solid_patblt( hdc, 8, 50, 1, 1, RGB( 0xff, 0, 0 ) ); + solid_patblt( hdc, 10, 50, 1, 1, PALETTERGB( 0xff, 0, 0 ) ); + + compare_hash(hdc, bmi, bits, "Colors"); + + for (i = 0; i < 256; i++) + { + COLORREF s, g; + s = SetPixel( hdc, i * 2, 10, DIBINDEX(i) ); + g = GetPixel( hdc, i * 2, 10 ); + ok( s == g, "got %08x and %08x\n", s, g ); + + s = SetPixel( hdc, i * 2, 20, PALETTEINDEX(i) ); + g = GetPixel( hdc, i * 2, 20 ); + ok( s == g, "got %08x and %08x\n", s, g ); + + s = SetPixel( hdc, i * 2, 30, RGB( (i & 0x07) << 5, (i & 0x38) << 2, i & 0xc0 ) ); + g = GetPixel( hdc, i * 2, 30 ); + ok( s == g, "got %08x and %08x\n", s, g ); + + s = SetPixel( hdc, i * 2, 40, PALETTERGB( (i & 0x07) << 5, (i & 0x38) << 2, i & 0xc0 ) ); + g = GetPixel( hdc, i * 2, 40 ); + ok( s == g, "got %08x and %08x\n", s, g ); + + for (j = 0; j < 256; j++) + { + s = SetPixel( hdc, i * 2, 50+j, (j << 24) | RGB( (i & 0x07) << 5, (i & 0x38) << 2, i & 0xc0 )); + g = GetPixel( hdc, i * 2, 50+j ); + ok( s == g, "got %08x and %08x\n", s, g ); + + s = SetPixel( hdc, i * 2 + 1, 50+j, (j << 24) | i ); + g = GetPixel( hdc, i * 2 + 1, 50+j ); + ok( s == g, "got %08x and %08x\n", s, g ); + } + } + + compare_hash(hdc, bmi, bits, "SetPixel"); + + /* gradients */ + + if (pGdiGradientFill) + { + TRIVERTEX vrect[] = + { + { 1, 1, 0xff00, 0x8000, 0x0000, 0x8000 }, + { 200, 200, 0x0000, 0x0000, 0xff00, 0xff00 }, + { 180, 180, 0x1234, 0x5678, 0x9abc, 0xdef0 }, + { 300, 300, 0xff00, 0xff00, 0xff00, 0x0000 } + }; + GRADIENT_RECT rect[] = { { 0, 1 }, { 2, 3 }, { 2, 1 } }; + + TRIVERTEX vtri[] = + { + { 250, 0, 0xff00, 0x0000, 0xff00, 0xff00 }, + { 500, 500, 0x0000, 0xff00, 0x0000, 0xff00 }, + { 0, 500, 0x0000, 0x0000, 0xff00, 0xff00 }, + + { 10, 0, 0x8000, 0x0000, 0x8000, 0x8000 }, + { 0, 20, 0xff00, 0xff00, 0xff00, 0x0000 }, + { 5, 30, 0x4000, 0xc000, 0x7000, 0x9000 }, + + { 30, 0, 0x9000, 0x8800, 0xcc00, 0xff00 }, + { 5, 12, 0x9900, 0xaa00, 0xbb00, 0xcc00 }, + { 0, 30, 0x5000, 0xd000, 0x9000, 0xbb00 }, + + { 35, 3, 0xaa00, 0x6500, 0x4300, 0x2100 }, + { 50, 6, 0x9800, 0x9800, 0x9800, 0x2000 }, + { 60, 10, 0x0100, 0x0200, 0x0300, 0x3000 }, + + { 60, 2, 0x0700, 0x0800, 0x0900, 0xff00 }, + { 73, 10, 0x9900, 0x8800, 0x7700, 0xff00 }, + { 66, 23, 0x1100, 0x2200, 0x3300, 0xff00 }, + + { 80, 1, 0xa000, 0x6000, 0x4000, 0x2000 }, + { 76, 9, 0x7000, 0x5000, 0x3000, 0x1000 }, + { 85, 23, 0x3300, 0x3300, 0x3300, 0x3300 }, + + { 90, 4, 0x4400, 0x5500, 0x6600, 0x9900 }, + { 95, 12, 0x4500, 0x5600, 0x6700, 0x9900 }, + { 85, 14, 0x4600, 0x5700, 0x6800, 0x9900 }, + }; + GRADIENT_TRIANGLE tri[] = + { + { 0, 1, 2 }, { 3, 4, 5 }, { 6, 7, 8 }, { 9, 10, 11 }, { 12, 13, 14 }, { 15, 16, 17 }, { 18, 19, 20 }, + { 2, 1, 0 }, { 3, 5, 4 }, { 7, 6, 8 }, { 10, 11, 9 }, { 14, 13, 12 }, { 17, 15, 16 }, { 19, 20, 18 } + }; + + pGdiGradientFill( hdc, vrect, 4, rect, 2, GRADIENT_FILL_RECT_H ); + for (i = 0; i < 4; i++) vrect[i].y += 250; + pGdiGradientFill( hdc, vrect, 4, rect, 2, GRADIENT_FILL_RECT_V ); + + if (bmi->bmiHeader.biBitCount <= 8) /* Wine's 8-bit dithering isn't identical to Windows */ + compare_hash_broken_todo(hdc, bmi, bits, "GdiGradientFill", 0, 1 ); + else + compare_hash(hdc, bmi, bits, "GdiGradientFill" ); + + pGdiGradientFill( hdc, vtri, 7*3, tri, 7, GRADIENT_FILL_TRIANGLE ); + for (i = 0; i < 7*3; i++) vtri[i].y += 100; + pGdiGradientFill( hdc, vtri, 7*3, tri + 7, 7, GRADIENT_FILL_TRIANGLE ); + if (bmi->bmiHeader.biBitCount <= 8) /* Wine's 8-bit dithering isn't identical to Windows */ + compare_hash_broken_todo(hdc, bmi, bits, "GdiGradientFill", 0, 1 ); + else + compare_hash(hdc, bmi, bits, "GdiGradientFill" ); + } + else + { + win_skip( "GdiGradientFill not supported\n" ); + skip_compare(1); + skip_compare(1); + } + + /* wide pen */ + + wide_pen = CreatePen( PS_SOLID, 7, RGB( 0xff, 0, 0 ) ); + SelectObject( hdc, wide_pen ); + + for (i = 0; i < sizeof( wide_lines ) / sizeof( wide_lines[0] ); i++) + { + MoveToEx( hdc, wide_lines[i].left, wide_lines[i].top, NULL ); + LineTo( hdc, wide_lines[i].right, wide_lines[i].bottom ); + } + + compare_hash(hdc, bmi, bits, "wide pen" ); + + SelectObject( hdc, orig_pen ); + DeleteObject( wide_pen ); + + log_brush.lbStyle = BS_SOLID; + log_brush.lbColor = RGB(0xff, 0, 0); + log_brush.lbHatch = 0; + + wide_pen = ExtCreatePen( PS_GEOMETRIC | PS_ENDCAP_FLAT | PS_JOIN_MITER | PS_SOLID, + 9, &log_brush, 0, NULL ); + SelectObject( hdc, wide_pen ); + + Polyline( hdc, poly_lines, sizeof(poly_lines) / sizeof(poly_lines[0]) ); + compare_hash(hdc, bmi, bits, "wide pen - flat caps, mitred" ); + + SelectObject( hdc, orig_pen ); + DeleteObject( wide_pen ); + + wide_pen = ExtCreatePen( PS_GEOMETRIC | PS_ENDCAP_SQUARE | PS_JOIN_BEVEL | PS_SOLID, + 16, &log_brush, 0, NULL ); + SelectObject( hdc, wide_pen ); + + Polyline( hdc, poly_lines, sizeof(poly_lines) / sizeof(poly_lines[0]) ); + compare_hash(hdc, bmi, bits, "wide pen - square caps, bevelled" ); + + SelectObject( hdc, orig_pen ); + DeleteObject( wide_pen ); + + wide_pen = ExtCreatePen( PS_GEOMETRIC | PS_ENDCAP_FLAT | PS_JOIN_MITER | PS_SOLID, + 9, &log_brush, 0, NULL ); + SelectObject( hdc, wide_pen ); + + PolyPolyline( hdc, polypoly_lines, polypoly_counts, sizeof(polypoly_counts)/sizeof(polypoly_counts[0]) ); + compare_hash(hdc, bmi, bits, "wide pen - empty segments" ); + + SelectObject( hdc, orig_pen ); + DeleteObject( wide_pen ); + + /* brushed wide pen */ + + old_text = GetTextColor( hdc ); + old_bkgnd = GetBkColor( hdc ); + bmp = CreateBitmap( 16, 16, 1, 1, ddb_brush_bits ); + log_brush.lbStyle = BS_PATTERN; + log_brush.lbColor = 0; + log_brush.lbHatch = (ULONG_PTR)bmp; + wide_pen = ExtCreatePen( PS_GEOMETRIC | PS_ENDCAP_FLAT | PS_JOIN_BEVEL | PS_SOLID, + 12, &log_brush, 0, NULL ); + ok( wide_pen != 0, "failed to create pen\n" ); + SelectObject( hdc, wide_pen ); + Polyline( hdc, poly_lines, sizeof(poly_lines) / sizeof(poly_lines[0]) ); + + for (i = 1; i < 20; i++) + { + wide_pen = ExtCreatePen( PS_GEOMETRIC | PS_ENDCAP_FLAT | PS_JOIN_BEVEL | PS_SOLID, + i, &log_brush, 0, NULL ); + ok( wide_pen != 0, "failed to create pen\n" ); + DeleteObject( SelectObject( hdc, wide_pen )); + SetTextColor(hdc, RGB( 2*i, i, 255 - i ) ); + SetBkColor(hdc, RGB( 255 - i, i, i / 3 ) ); + MoveToEx( hdc, 10 * i, 10, NULL ); + LineTo( hdc, 10 * i, 200 + i ); + LineTo( hdc, 20 * i, 200 + i ); + } + /* NT4 broken for all cases, W2K for 1 bpp only */ + compare_hash_broken_todo(hdc, bmi, bits, "wide brushed pen", 1 + dib_is_1bpp, dib_is_1bpp ); + + for (i = 1; i < 20; i++) + { + wide_pen = ExtCreatePen( PS_GEOMETRIC | PS_ENDCAP_FLAT | PS_JOIN_BEVEL | (i % 5), + i, &log_brush, 0, NULL ); + DeleteObject( SelectObject( hdc, wide_pen )); + SetTextColor(hdc, RGB( 2*i, i, 255 - i ) ); + SetBkColor(hdc, RGB( i, 255 - i, i / 3 ) ); + MoveToEx( hdc, 10 * i, 10, NULL ); + LineTo( hdc, 10 * i, 200 + i ); + LineTo( hdc, 20 * i, 200 + i ); + } + /* NT4 broken for all cases, W2K for 1 bpp only */ + compare_hash_broken_todo(hdc, bmi, bits, "dashed wide brushed pen", 1 + dib_is_1bpp, dib_is_1bpp ); + + DeleteObject(bmp); + SetTextColor(hdc, old_text); + SetBkColor(hdc, old_bkgnd); + SelectObject( hdc, orig_pen ); + + /* PALETTEINDEX */ + + solid_brush = CreateSolidBrush( PALETTEINDEX(3) ); + solid_pen = CreatePen( PS_DASH, 1, PALETTEINDEX(5) ); + SetTextColor( hdc, PALETTEINDEX(38) ); + SetBkColor( hdc, PALETTEINDEX(9) ); + SelectObject( hdc, solid_brush ); + SelectObject( hdc, solid_pen ); + + pal->palVersion = 0x300; + pal->palNumEntries = 40; + for (i = 0; i < 80; i++) + { + entries[i].peRed = i * 3; + entries[i].peGreen = i * 7; + entries[i].peBlue = 128 - i; + entries[i].peFlags = 0; + } + hpal = CreatePalette( pal ); + SelectPalette( hdc, hpal, FALSE ); + + solid_patblt( hdc, 20, 10, 10, 10, PALETTEINDEX(15) ); + Rectangle( hdc, 0, 0, 10, 10 ); + SetPaletteEntries( hpal, 0, 40, entries + 40 ); + Rectangle( hdc, 10, 0, 10, 10 ); + SelectObject( hdc, orig_brush ); + DeleteObject( solid_brush ); + + solid_brush = CreateHatchBrush( HS_CROSS, PALETTEINDEX(7) ); + DeleteObject( SelectObject( hdc, solid_brush )); + PatBlt( hdc, 20, 0, 10, 10, PATCOPY ); + SetPaletteEntries( hpal, 0, 40, entries ); + PatBlt( hdc, 30, 0, 10, 10, PATCOPY ); + SelectObject( hdc, orig_brush ); + DeleteObject( solid_brush ); + + bmp = CreateBitmap( 16, 16, 1, 1, ddb_brush_bits ); + dib_brush = CreatePatternBrush( bmp ); + SelectObject( hdc, dib_brush ); + PatBlt( hdc, 40, 0, 10, 10, PATCOPY ); + SetPaletteEntries( hpal, 0, 40, entries + 40 ); + PatBlt( hdc, 50, 0, 10, 10, PATCOPY ); + DeleteObject( bmp ); + SelectObject( hdc, orig_brush ); + DeleteObject( dib_brush ); + + SelectPalette( hdc, GetStockObject(DEFAULT_PALETTE), FALSE ); + DeleteObject( hpal ); + + /* NT4 broken for all cases, W2K for 1 bpp only */ + compare_hash_broken_todo(hdc, bmi, bits, "PALETTEINDEX", 1 + dib_is_1bpp, dib_is_1bpp ); + + /* ExtFloodFill */ + + solid_patblt( hdc, 0, 0, 512, 512, RGB( 0, 0, 0xff ) ); + solid_patblt( hdc, 10, 10, 200, 200, RGB( 0, 0xff, 0 ) ); + solid_patblt( hdc, 10, 50, 50, 50, RGB( 0, 0, 0xff ) ); + solid_patblt( hdc, 100, 160, 50, 50, RGB( 0, 0, 0xff ) ); + solid_patblt( hdc, 90, 160, 70, 10, RGB( 0, 0, 0xff ) ); + + /* add a vertical 'bar' to show that the clip rgn stops the flooding */ + hrgn = CreateRectRgn( 180, 10, 190, 210 ); + ExtSelectClipRgn( hdc, hrgn, RGN_DIFF ); + DeleteObject( hrgn ); + + solid_brush = CreateSolidBrush( RGB( 0xff, 0, 0 ) ); + SelectObject( hdc, solid_brush ); + + ret = ExtFloodFill( hdc, 100, 100, RGB( 0, 0xff, 0 ), FLOODFILLSURFACE ); + ok (!ret == !!dib_is_1bpp, "got ret %d\n", ret); + compare_hash(hdc, bmi, bits, "flood fill" ); + + ExtSelectClipRgn( hdc, NULL, RGN_COPY ); SelectObject(hdc, orig_brush); SelectObject(hdc, orig_pen); - DeleteObject(hrgn); DeleteObject(dib_brush); - DeleteObject(dashed_pen); DeleteObject(solid_brush); + DeleteObject(wide_pen); + DeleteObject(dashed_pen); DeleteObject(solid_pen); } +static const BYTE ramp[17] = +{ + 0, 0x4d, 0x68, 0x7c, + 0x8c, 0x9a, 0xa7, 0xb2, + 0xbd, 0xc7, 0xd0, 0xd9, + 0xe1, 0xe9, 0xf0, 0xf8, + 0xff +}; + +static inline void get_range(BYTE alpha, DWORD text_comp, BYTE *min_comp, BYTE *max_comp) +{ + *min_comp = (ramp[alpha] * text_comp) / 0xff; + *max_comp = ramp[16 - alpha] + ((0xff - ramp[16 - alpha]) * text_comp) / 0xff; +} + +static inline BYTE aa_comp(BYTE dst, BYTE text, BYTE alpha) +{ + BYTE min_comp, max_comp; + + if (alpha == 16) return text; + if (alpha <= 1) return dst; + if (text == dst) return dst; + + get_range( alpha, text, &min_comp, &max_comp ); + + if (dst > text) + { + DWORD diff = dst - text; + DWORD range = max_comp - text; + dst = text + (diff * range ) / (0xff - text); + return dst; + } + else + { + DWORD diff = text - dst; + DWORD range = text - min_comp ; + dst = text - (diff * range) / text; + return dst; + } +} + +static inline COLORREF aa_colorref( COLORREF dst, COLORREF text, BYTE glyph ) +{ + COLORREF ret; + + ret = RGB( aa_comp( GetRValue(dst), GetRValue(text), glyph ), + aa_comp( GetGValue(dst), GetGValue(text), glyph ), + aa_comp( GetBValue(dst), GetBValue(text), glyph ) ); + return ret; +} + +static const BYTE masks[8] = {0x80, 0x40, 0x20, 0x10, 0x08, 0x04, 0x02, 0x01}; + +static void draw_text_2( HDC hdc, BITMAPINFO *bmi, BYTE *bits, BOOL aa ) +{ + DWORD dib_size = get_dib_size(bmi), ret; + LOGFONT lf; + HFONT font; + GLYPHMETRICS gm; + BYTE g_buf[10000]; + int i, stride, x, y; + static const MAT2 identity = { {0,1}, {0,0}, {0,0}, {0,1} }; + char *eto_hash = NULL, *diy_hash = NULL; + static const char *str = "Hello Wine"; + POINT origin, g_org; + static const BYTE vals[4] = { 0x00, 0x00, 0x00, 0x00 }; + TEXTMETRIC tm; + COLORREF text_color; + + for(i = 0; i < dib_size; i++) + bits[i] = vals[i % 4]; + + memset( &lf, 0, sizeof(lf) ); + strcpy( lf.lfFaceName, "Tahoma" ); + lf.lfHeight = 24; + lf.lfQuality = aa ? ANTIALIASED_QUALITY : NONANTIALIASED_QUALITY; + + font = CreateFontIndirect( &lf ); + font = SelectObject( hdc, font ); + + GetTextMetrics( hdc, &tm ); + if (!(tm.tmPitchAndFamily & TMPF_VECTOR)) + { + skip( "skipping as a bitmap font has been selected for Tahoma.\n" ); + DeleteObject( SelectObject( hdc, font ) ); + return; + } + + SetTextColor( hdc, RGB(0xff, 0x00, 0x00) ); + SetTextAlign( hdc, TA_BASELINE ); + SetBkMode( hdc, TRANSPARENT ); + origin.x = 10; + origin.y = 100; + + ExtTextOut( hdc, origin.x, origin.y, 0, NULL, str, strlen(str), NULL ); + eto_hash = hash_dib( bmi, bits ); + + for(i = 0; i < dib_size; i++) + bits[i] = vals[i % 4]; + + if (bmi->bmiHeader.biBitCount <= 8) aa = FALSE; + + text_color = GetTextColor( hdc ); + for (i = 0; i < strlen(str); i++) + { + DWORD ggo_flags = aa ? GGO_GRAY4_BITMAP : GGO_BITMAP; + + ret = GetGlyphOutline( hdc, str[i], ggo_flags, &gm, 0, NULL, &identity ); + + if (ret == GDI_ERROR) continue; + + if (ret) GetGlyphOutline( hdc, str[i], ggo_flags, &gm, sizeof(g_buf), g_buf, &identity ); + + g_org.x = origin.x + gm.gmptGlyphOrigin.x; + g_org.y = origin.y - gm.gmptGlyphOrigin.y; + + origin.x += gm.gmCellIncX; + origin.y += gm.gmCellIncY; + + if (!ret) continue; + + if (aa) + { + stride = (gm.gmBlackBoxX + 3) & ~3; + + for (y = 0; y < gm.gmBlackBoxY; y++) + { + BYTE *g_ptr = g_buf + y * stride; + COLORREF val; + + for (x = 0; x < gm.gmBlackBoxX; x++) + { + if (g_ptr[x] <= 1) continue; + if (g_ptr[x] >= 16) val = text_color; + else + { + val = GetPixel( hdc, g_org.x + x, g_org.y + y ); + val = aa_colorref( val, text_color, g_ptr[x] ); + } + SetPixel( hdc, g_org.x + x, g_org.y + y, val ); + } + } + } + else + { + stride = ((gm.gmBlackBoxX + 31) >> 3) & ~3; + + for (y = 0; y < gm.gmBlackBoxY; y++) + { + BYTE *g_ptr = g_buf + y * stride; + for (x = 0; x < gm.gmBlackBoxX; x++) + { + if (g_ptr[x / 8] & masks[x % 8]) + SetPixel( hdc, g_org.x + x, g_org.y + y, text_color ); + } + } + } + } + + diy_hash = hash_dib( bmi, bits ); + ok( !strcmp( eto_hash, diy_hash ), "hash mismatch - aa %d\n", aa ); + + HeapFree( GetProcessHeap(), 0, diy_hash ); + HeapFree( GetProcessHeap(), 0, eto_hash ); + + font = SelectObject( hdc, font ); + DeleteObject( font ); +} + +static void draw_text( HDC hdc, BITMAPINFO *bmi, BYTE *bits ) +{ + draw_text_2( hdc, bmi, bits, FALSE ); + + /* Rounding errors make these cases hard to test */ + if ((bmi->bmiHeader.biCompression == BI_BITFIELDS && ((DWORD*)bmi->bmiColors)[0] == 0x3f000) || + (bmi->bmiHeader.biBitCount == 16)) + return; + + draw_text_2( hdc, bmi, bits, TRUE ); +} + static void test_simple_graphics(void) { char bmibuf[sizeof(BITMAPINFO) + 256 * sizeof(RGBQUAD)]; BITMAPINFO *bmi = (BITMAPINFO *)bmibuf; + RGBQUAD *colors = bmi->bmiColors; DWORD *bit_fields = (DWORD*)(bmibuf + sizeof(BITMAPINFOHEADER)); HDC mem_dc; BYTE *bits; HBITMAP dib, orig_bm; - const char **sha1; DIBSECTION ds; + int i; mem_dc = CreateCompatibleDC(NULL); @@ -1195,8 +2884,10 @@ static void test_simple_graphics(void) orig_bm = SelectObject(mem_dc, dib); - sha1 = sha1_graphics_a8r8g8b8; - draw_graphics(mem_dc, bmi, bits, &sha1); + dst_format = "8888"; + current_sha1 = sha1_graphics_a8r8g8b8; + draw_graphics(mem_dc, bmi, bits); + draw_text(mem_dc, bmi, bits); SelectObject(mem_dc, orig_bm); DeleteObject(dib); @@ -1219,14 +2910,16 @@ static void test_simple_graphics(void) orig_bm = SelectObject(mem_dc, dib); - sha1 = sha1_graphics_a8r8g8b8; - draw_graphics(mem_dc, bmi, bits, &sha1); + dst_format = "8888 - bitfields"; + current_sha1 = sha1_graphics_a8r8g8b8_bitfields; + draw_graphics(mem_dc, bmi, bits); + draw_text(mem_dc, bmi, bits); SelectObject(mem_dc, orig_bm); DeleteObject(dib); - /* a8b8g8r8 - bitfields. */ - trace("a8b8g8r8 - bitfields\n"); + /* a8b8g8r8. */ + trace("a8b8g8r8\n"); bmi->bmiHeader.biBitCount = 32; bmi->bmiHeader.biCompression = BI_BITFIELDS; bit_fields[0] = 0x0000ff; @@ -1243,8 +2936,62 @@ static void test_simple_graphics(void) orig_bm = SelectObject(mem_dc, dib); - sha1 = sha1_graphics_a8b8g8r8; - draw_graphics(mem_dc, bmi, bits, &sha1); + dst_format = "a8b8g8r8"; + current_sha1 = sha1_graphics_a8b8g8r8; + draw_graphics(mem_dc, bmi, bits); + draw_text(mem_dc, bmi, bits); + + SelectObject(mem_dc, orig_bm); + DeleteObject(dib); + + /* r10g10b10. */ + trace("r10g10b10\n"); + bmi->bmiHeader.biBitCount = 32; + bmi->bmiHeader.biCompression = BI_BITFIELDS; + bit_fields[0] = 0x3ff00000; + bit_fields[1] = 0x000ffc00; + bit_fields[2] = 0x000003ff; + + 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] == 0x3ff00000, "got %08x\n", ds.dsBitfields[0]); + ok(ds.dsBitfields[1] == 0x000ffc00, "got %08x\n", ds.dsBitfields[1]); + ok(ds.dsBitfields[2] == 0x000003ff, "got %08x\n", ds.dsBitfields[2]); + ok(ds.dsBmih.biCompression == BI_BITFIELDS, "got %x\n", ds.dsBmih.biCompression); + + orig_bm = SelectObject(mem_dc, dib); + + dst_format = "r10g10b10"; + current_sha1 = sha1_graphics_r10g10b10; + draw_graphics(mem_dc, bmi, bits); + draw_text(mem_dc, bmi, bits); + + SelectObject(mem_dc, orig_bm); + DeleteObject(dib); + + /* r6g6b6. */ + trace("r6g6b6\n"); + bmi->bmiHeader.biBitCount = 32; + bmi->bmiHeader.biCompression = BI_BITFIELDS; + bit_fields[0] = 0x0003f000; + bit_fields[1] = 0x00000fc0; + bit_fields[2] = 0x0000003f; + + 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] == 0x0003f000, "got %08x\n", ds.dsBitfields[0]); + ok(ds.dsBitfields[1] == 0x00000fc0, "got %08x\n", ds.dsBitfields[1]); + ok(ds.dsBitfields[2] == 0x0000003f, "got %08x\n", ds.dsBitfields[2]); + ok(ds.dsBmih.biCompression == BI_BITFIELDS, "got %x\n", ds.dsBmih.biCompression); + + orig_bm = SelectObject(mem_dc, dib); + + dst_format = "r6g6b6"; + current_sha1 = sha1_graphics_r6g6b6; + draw_graphics(mem_dc, bmi, bits); + draw_text(mem_dc, bmi, bits); SelectObject(mem_dc, orig_bm); DeleteObject(dib); @@ -1258,8 +3005,10 @@ static void test_simple_graphics(void) ok(dib != NULL, "ret NULL\n"); orig_bm = SelectObject(mem_dc, dib); - sha1 = sha1_graphics_24; - draw_graphics(mem_dc, bmi, bits, &sha1); + dst_format = "24"; + current_sha1 = sha1_graphics_24; + draw_graphics(mem_dc, bmi, bits); + draw_text(mem_dc, bmi, bits); SelectObject(mem_dc, orig_bm); DeleteObject(dib); @@ -1279,8 +3028,10 @@ static void test_simple_graphics(void) orig_bm = SelectObject(mem_dc, dib); - sha1 = sha1_graphics_r5g5b5; - draw_graphics(mem_dc, bmi, bits, &sha1); + dst_format = "r5g5b5"; + current_sha1 = sha1_graphics_r5g5b5; + draw_graphics(mem_dc, bmi, bits); + draw_text(mem_dc, bmi, bits); SelectObject(mem_dc, orig_bm); DeleteObject(dib); @@ -1302,8 +3053,54 @@ static void test_simple_graphics(void) orig_bm = SelectObject(mem_dc, dib); - sha1 = sha1_graphics_r4g4b4; - draw_graphics(mem_dc, bmi, bits, &sha1); + dst_format = "r4g4b4"; + current_sha1 = sha1_graphics_r4g4b4; + draw_graphics(mem_dc, bmi, bits); + draw_text(mem_dc, bmi, bits); + + SelectObject(mem_dc, orig_bm); + DeleteObject(dib); + + /* 8 color */ + trace("8 color\n"); + bmi->bmiHeader.biBitCount = 8; + bmi->bmiHeader.biCompression = BI_RGB; + bmi->bmiHeader.biClrUsed = 236; + for (i = 0; i < 236; i++) + { + colors[i].rgbRed = (i & 0x07) << 5; + colors[i].rgbGreen = (i & 0x38) << 2; + colors[i].rgbBlue = i & 0xc0; + } + dib = CreateDIBSection(0, bmi, DIB_RGB_COLORS, (void**)&bits, NULL, 0); + ok(dib != NULL, "ret NULL\n"); + + orig_bm = SelectObject(mem_dc, dib); + + dst_format = "8 color"; + current_sha1 = sha1_graphics_8_color; + draw_graphics(mem_dc, bmi, bits); + draw_text(mem_dc, bmi, bits); + + SelectObject(mem_dc, orig_bm); + DeleteObject(dib); + + /* 8 grayscale */ + trace("8 grayscale\n"); + bmi->bmiHeader.biBitCount = 8; + bmi->bmiHeader.biCompression = BI_RGB; + bmi->bmiHeader.biClrUsed = 256; + for (i = 0; i < 256; i++) colors[i].rgbRed = colors[i].rgbGreen = colors[i].rgbBlue = i; + + dib = CreateDIBSection(0, bmi, DIB_RGB_COLORS, (void**)&bits, NULL, 0); + ok(dib != NULL, "ret NULL\n"); + + orig_bm = SelectObject(mem_dc, dib); + + dst_format = "8 grayscale"; + current_sha1 = sha1_graphics_8_grayscale; + draw_graphics(mem_dc, bmi, bits); + draw_text(mem_dc, bmi, bits); SelectObject(mem_dc, orig_bm); DeleteObject(dib); @@ -1313,29 +3110,31 @@ static void test_simple_graphics(void) bmi->bmiHeader.biBitCount = 8; bmi->bmiHeader.biCompression = BI_RGB; bmi->bmiHeader.biClrUsed = 5; - bmi->bmiColors[0].rgbRed = 0xff; - bmi->bmiColors[0].rgbGreen = 0xff; - bmi->bmiColors[0].rgbBlue = 0xff; - bmi->bmiColors[1].rgbRed = 0; - bmi->bmiColors[1].rgbGreen = 0; - bmi->bmiColors[1].rgbBlue = 0; - bmi->bmiColors[2].rgbRed = 0xff; - bmi->bmiColors[2].rgbGreen = 0; - bmi->bmiColors[2].rgbBlue = 0; - bmi->bmiColors[3].rgbRed = 0; - bmi->bmiColors[3].rgbGreen = 0xff; - bmi->bmiColors[3].rgbBlue = 0; - bmi->bmiColors[4].rgbRed = 0; - bmi->bmiColors[4].rgbGreen = 0; - bmi->bmiColors[4].rgbBlue = 0xff; + colors[0].rgbRed = 0xff; + colors[0].rgbGreen = 0xff; + colors[0].rgbBlue = 0xff; + colors[1].rgbRed = 0; + colors[1].rgbGreen = 0; + colors[1].rgbBlue = 0; + colors[2].rgbRed = 0xff; + colors[2].rgbGreen = 0; + colors[2].rgbBlue = 0; + colors[3].rgbRed = 0; + colors[3].rgbGreen = 0xff; + colors[3].rgbBlue = 0; + colors[4].rgbRed = 0; + colors[4].rgbGreen = 0; + colors[4].rgbBlue = 0xff; dib = CreateDIBSection(0, bmi, DIB_RGB_COLORS, (void**)&bits, NULL, 0); ok(dib != NULL, "ret NULL\n"); orig_bm = SelectObject(mem_dc, dib); - sha1 = sha1_graphics_8; - draw_graphics(mem_dc, bmi, bits, &sha1); + dst_format = "8"; + current_sha1 = sha1_graphics_8; + draw_graphics(mem_dc, bmi, bits); + draw_text(mem_dc, bmi, bits); SelectObject(mem_dc, orig_bm); DeleteObject(dib); @@ -1349,8 +3148,28 @@ static void test_simple_graphics(void) orig_bm = SelectObject(mem_dc, dib); - sha1 = sha1_graphics_4; - draw_graphics(mem_dc, bmi, bits, &sha1); + dst_format = "4"; + current_sha1 = sha1_graphics_4; + draw_graphics(mem_dc, bmi, bits); + draw_text(mem_dc, bmi, bits); + + SelectObject(mem_dc, orig_bm); + DeleteObject(dib); + + /* 4 grayscale */ + trace("4 grayscale\n"); + bmi->bmiHeader.biClrUsed = 16; + for (i = 0; i < 16; i++) colors[i].rgbRed = colors[i].rgbGreen = colors[i].rgbBlue = i * 17; + + dib = CreateDIBSection(0, bmi, DIB_RGB_COLORS, (void**)&bits, NULL, 0); + ok(dib != NULL, "ret NULL\n"); + + orig_bm = SelectObject(mem_dc, dib); + + dst_format = "4 grayscale"; + current_sha1 = sha1_graphics_4_grayscale; + draw_graphics(mem_dc, bmi, bits); + draw_text(mem_dc, bmi, bits); SelectObject(mem_dc, orig_bm); DeleteObject(dib); @@ -1360,20 +3179,22 @@ static void test_simple_graphics(void) bmi->bmiHeader.biBitCount = 1; bmi->bmiHeader.biClrUsed = 2; - bmi->bmiColors[0].rgbRed = 0x00; - bmi->bmiColors[0].rgbGreen = 0x01; - bmi->bmiColors[0].rgbBlue = 0xff; - bmi->bmiColors[1].rgbRed = 0xff; - bmi->bmiColors[1].rgbGreen = 0x00; - bmi->bmiColors[1].rgbBlue = 0x00; + colors[0].rgbRed = 0x00; + colors[0].rgbGreen = 0x01; + colors[0].rgbBlue = 0xff; + colors[1].rgbRed = 0xff; + colors[1].rgbGreen = 0x00; + colors[1].rgbBlue = 0x00; dib = CreateDIBSection(0, bmi, DIB_RGB_COLORS, (void**)&bits, NULL, 0); ok(dib != NULL, "ret NULL\n"); orig_bm = SelectObject(mem_dc, dib); - sha1 = sha1_graphics_1; - draw_graphics(mem_dc, bmi, bits, &sha1); + dst_format = "1"; + current_sha1 = sha1_graphics_1; + draw_graphics(mem_dc, bmi, bits); + draw_text(mem_dc, bmi, bits); SelectObject(mem_dc, orig_bm); DeleteObject(dib); @@ -1385,6 +3206,8 @@ START_TEST(dib) { HMODULE mod = GetModuleHandleA("gdi32.dll"); pSetLayout = (void *)GetProcAddress( mod, "SetLayout" ); + pGdiAlphaBlend = (void *)GetProcAddress( mod, "GdiAlphaBlend" ); + pGdiGradientFill = (void *)GetProcAddress( mod, "GdiGradientFill" ); CryptAcquireContextW(&crypt_prov, NULL, NULL, PROV_RSA_FULL, CRYPT_VERIFYCONTEXT);