From f04935d8f23cd940551e673911c892c5083ebbaf Mon Sep 17 00:00:00 2001 From: Amine Khaldi Date: Tue, 29 Jan 2019 13:09:42 +0100 Subject: [PATCH] [MSVFW32_WINETEST] Sync with Wine Staging 4.0. CORE-15682 --- modules/rostests/winetests/msvfw32/drawdib.c | 2 +- modules/rostests/winetests/msvfw32/msvfw.c | 537 +++++++++---------- 2 files changed, 253 insertions(+), 286 deletions(-) diff --git a/modules/rostests/winetests/msvfw32/drawdib.c b/modules/rostests/winetests/msvfw32/drawdib.c index 0a59d826213..92e60df264f 100644 --- a/modules/rostests/winetests/msvfw32/drawdib.c +++ b/modules/rostests/winetests/msvfw32/drawdib.c @@ -138,7 +138,7 @@ static void test_DrawDib_sizeimage(void) hdd = DrawDibOpen(); ok(hdd != NULL, "DrawDibOpen failed\n"); - for (i = 0; i < sizeof(test_data)/sizeof(test_data[0]); i++) { + for (i = 0; i < ARRAY_SIZE(test_data); i++) { char *hash; memset(dst_bits, 0xff, dst_dib_size); init_bmi(&src_info, test_data[i].width, test_data[i].height, test_data[i].size); diff --git a/modules/rostests/winetests/msvfw32/msvfw.c b/modules/rostests/winetests/msvfw32/msvfw.c index c63039a092e..fbc0afd4564 100644 --- a/modules/rostests/winetests/msvfw32/msvfw.c +++ b/modules/rostests/winetests/msvfw32/msvfw.c @@ -374,290 +374,6 @@ static void test_ICSeqCompress(void) ok(err == ICERR_BADHANDLE, "Expected -8, got %d\n", err); } -struct msg_result -{ - int msg_index; - UINT msg; - BOOL output_format; - int width; - int height; - int bits; - int compression; - LRESULT result; - BOOL todo; -}; - -static struct msg_result expected_msgs[] = -{ - /* Wine bug - shouldn't be called */ - { 0, DRV_LOAD, FALSE, 0, 0, 0, 0, TRUE, TRUE}, - { 0, DRV_ENABLE, FALSE, 0, 0, 0, 0, 0, TRUE}, - - { 0, DRV_OPEN, FALSE, 0, 0, 0, 0, 0xdeadbeef, FALSE}, - - /* test 1 */ - { 1, ICM_DECOMPRESS_QUERY, FALSE, 0, 0, 0, 0, ICERR_OK, FALSE}, - { 2, ICM_DECOMPRESS_GET_FORMAT, TRUE, 320, 240, 16, BI_RGB, ICERR_BADFORMAT, FALSE}, - { 3, ICM_DECOMPRESS_QUERY, TRUE, 640, 480, 8, BI_RGB, ICERR_BADFORMAT, FALSE}, - { 4, ICM_DECOMPRESS_QUERY, TRUE, 640, 480, 16, BI_RGB, ICERR_BADFORMAT, FALSE}, - { 5, ICM_DECOMPRESS_QUERY, TRUE, 640, 480, 16, BI_BITFIELDS, ICERR_BADFORMAT, FALSE}, - { 6, ICM_DECOMPRESS_QUERY, TRUE, 640, 480, 24, BI_RGB, ICERR_BADFORMAT, FALSE}, - { 7, ICM_DECOMPRESS_QUERY, TRUE, 640, 480, 32, BI_RGB, ICERR_BADFORMAT, FALSE}, - { 8, ICM_DECOMPRESS_GET_FORMAT, TRUE, 640, 480, 32, BI_RGB, ICERR_OK, FALSE}, - - /* test 2 */ - { 9, ICM_DECOMPRESS_QUERY, FALSE, 0, 0, 0, 0, ICERR_OK, FALSE}, - {10, ICM_DECOMPRESS_GET_FORMAT, TRUE, 320, 240, 16, BI_RGB, ICERR_BADFORMAT, FALSE}, - {11, ICM_DECOMPRESS_QUERY, TRUE, 640, 480, 8, BI_RGB, ICERR_BADFORMAT, FALSE}, - {12, ICM_DECOMPRESS_QUERY, TRUE, 640, 480, 16, BI_RGB, ICERR_OK, FALSE}, - - /* test 3 */ - {13, ICM_DECOMPRESS_QUERY, FALSE, 0, 0, 0, 0, ICERR_OK, FALSE}, - {14, ICM_DECOMPRESS_GET_FORMAT, TRUE, 320, 240, 16, BI_RGB, ICERR_OK, FALSE}, - {15, ICM_DECOMPRESS_QUERY, TRUE, 640, 480, 8, BI_RGB, ICERR_BADFORMAT, FALSE}, - {16, ICM_DECOMPRESS_QUERY, TRUE, 640, 480, 16, BI_RGB, ICERR_OK, FALSE}, - - /* test 4 */ - {17, ICM_DECOMPRESS_QUERY, FALSE, 0, 0, 0, 0, ICERR_OK, FALSE}, - {18, ICM_DECOMPRESS_GET_FORMAT, TRUE, 320, 240, 16, BI_RGB, ICERR_BADFORMAT, FALSE}, - {19, ICM_DECOMPRESS_QUERY, TRUE, 640, 480, 24, BI_RGB, ICERR_BADFORMAT, FALSE}, - {20, ICM_DECOMPRESS_QUERY, TRUE, 640, 480, 32, BI_RGB, ICERR_BADFORMAT, FALSE}, - {21, ICM_DECOMPRESS_GET_FORMAT, TRUE, 640, 480, 32, BI_RGB, ICERR_OK, FALSE}, - - /* test 5 */ - {22, ICM_DECOMPRESS_QUERY, FALSE, 0, 0, 0, 0, ICERR_OK, FALSE}, - {23, ICM_DECOMPRESS_GET_FORMAT, TRUE, 320, 240, 16, BI_RGB, ICERR_OK, FALSE}, - {24, ICM_DECOMPRESS_QUERY, TRUE, 640, 480, 32, BI_RGB, ICERR_OK, FALSE}, - - /* test 6 */ - {25, ICM_DECOMPRESS_QUERY, FALSE, 0, 0, 0, 0, ICERR_OK, FALSE}, - {26, ICM_DECOMPRESS_GET_FORMAT, TRUE, 320, 240, 16, BI_RGB, ICERR_OK, FALSE}, - {27, ICM_DECOMPRESS_QUERY, TRUE, 640, 480, 32, BI_RGB, ICERR_OK, FALSE}, - - /* test 7 */ - {28, ICM_DECOMPRESS_QUERY, FALSE, 0, 0, 0, 0, ICERR_OK, FALSE}, - {29, ICM_DECOMPRESS_GET_FORMAT, TRUE, 320, 240, 16, BI_RGB, ICERR_OK, FALSE}, - {30, ICM_DECOMPRESS_QUERY, TRUE, 640, 480, 9, BI_RGB, ICERR_BADFORMAT, FALSE}, - {31, ICM_DECOMPRESS_QUERY, TRUE, 640, 480, 32, BI_RGB, ICERR_BADFORMAT, FALSE}, - {32, ICM_DECOMPRESS_GET_FORMAT, TRUE, 640, 480, 32, BI_RGB, ICERR_OK, FALSE}, - - /* test 8 */ - {33, ICM_DECOMPRESS_QUERY, FALSE, 0, 0, 0, 0, ICERR_OK, FALSE}, - {34, ICM_DECOMPRESS_GET_FORMAT, TRUE, 320, 240, 16, BI_RGB, ICERR_OK, FALSE}, - {35, ICM_DECOMPRESS_QUERY, TRUE, 800, 600, 32, BI_RGB, ICERR_OK, FALSE}, - - /* test 9 */ - {36, ICM_DECOMPRESS_QUERY, FALSE, 0, 0, 0, 0, ICERR_OK, FALSE}, - {37, ICM_DECOMPRESS_GET_FORMAT, TRUE, 320, 240, 16, BI_RGB, ICERR_OK, FALSE}, - {38, ICM_DECOMPRESS_QUERY, TRUE, 640, 480, 32, BI_RGB, ICERR_OK, FALSE}, - - /* test 10 */ - {39, ICM_DECOMPRESS_QUERY, FALSE, 0, 0, 0, 0, ICERR_OK, FALSE}, - {40, ICM_DECOMPRESS_GET_FORMAT, TRUE, 320, 240, 16, BI_RGB, ICERR_OK, FALSE}, - {41, ICM_DECOMPRESS_QUERY, TRUE, 640, 480, 32, BI_RGB, ICERR_OK, FALSE}, - - /* test 11 */ - {42, ICM_DECOMPRESS_QUERY, FALSE, 0, 0, 0, 0, ICERR_OK, FALSE}, - {43, ICM_DECOMPRESS_GET_FORMAT, TRUE, 320, 240, 16, BI_RGB, ICERR_OK, FALSE}, - {44, ICM_DECOMPRESS_QUERY, TRUE, 270, 270, 8, BI_RGB, ICERR_OK, FALSE}, - {45, ICM_DECOMPRESS_GET_PALETTE, FALSE, 0, 0, 0, 0, ICERR_UNSUPPORTED, FALSE}, - - /* test 12 */ - {46, ICM_DECOMPRESS_QUERY, FALSE, 0, 0, 0, 0, ICERR_OK, FALSE}, - {47, ICM_DECOMPRESS_GET_FORMAT, TRUE, 320, 240, 16, BI_RGB, ICERR_OK, FALSE}, - {48, ICM_DECOMPRESS_QUERY, TRUE, 270, 270, 16, BI_RGB, ICERR_OK, FALSE}, - - /* test 13 */ - {49, ICM_DECOMPRESS_QUERY, FALSE, 0, 0, 0, 0, ICERR_OK, FALSE}, - {50, ICM_DECOMPRESS_GET_FORMAT, TRUE, 320, 240, 16, BI_RGB, ICERR_OK, FALSE}, - {51, ICM_DECOMPRESS_QUERY, TRUE, 270, 270, 24, BI_RGB, ICERR_OK, FALSE}, - - /* test 14 */ - {52, ICM_DECOMPRESS_QUERY, FALSE, 0, 0, 0, 0, ICERR_OK, FALSE}, - {53, ICM_DECOMPRESS_GET_FORMAT, TRUE, 320, 240, 16, BI_RGB, ICERR_OK, FALSE}, - {54, ICM_DECOMPRESS_QUERY, TRUE, 640, 480, 4, BI_RGB, ICERR_OK, FALSE}, - - /* Wine bug - shouldn't be called */ - {55, DRV_DISABLE, FALSE, 0, 0, 0, 0, ICERR_OK, TRUE}, - {55, DRV_FREE, FALSE, 0, 0, 0, 0, ICERR_OK, TRUE}, -}; - -static int msg_index = 0; - -static struct msg_result *get_expected_msg(UINT msg) -{ - int i = 0; - for(; i < sizeof(expected_msgs) / sizeof(expected_msgs[0]); i++) - { - if (expected_msgs[i].msg_index == msg_index && expected_msgs[i].msg == msg) - return &expected_msgs[i]; - } - return NULL; -} - -LRESULT WINAPI driver_proc_test(DWORD_PTR dwDriverId, HDRVR hdrvr, UINT msg, - LPARAM lParam1, LPARAM lParam2) -{ - struct msg_result *expected = get_expected_msg(msg); - LRESULT res = expected ? expected->result : ICERR_UNSUPPORTED; - - if (msg == DRV_CLOSE) - return ICERR_OK; - - if (!expected) - { - ok(0, "unexpected message: %04x %ld %ld at msg index %d\n", - msg, lParam1, lParam2, msg_index); - return ICERR_UNSUPPORTED; - } - else if (expected->todo) - { - todo_wine ok(0, "unexpected message: %04x %ld %ld at msg index %d\n", - msg, lParam1, lParam2, msg_index); - return res; - } - - switch (msg) - { - case ICM_DECOMPRESS_QUERY: - { - BITMAPINFOHEADER *out = (BITMAPINFOHEADER *)lParam2; - - if (!lParam2) - { - trace("query -> without format\n"); - ok(!expected->output_format, "Expected no output format pointer\n"); - break; - } - - ok(expected->output_format, "Expected output format pointer\n"); - ok(out->biWidth == expected->width, - "Expected width %d, got %d\n", expected->width, out->biWidth); - ok(out->biHeight == expected->height, - "Expected height %d, got %d\n", expected->height, out->biHeight); - ok(out->biBitCount == expected->bits, - "Expected biBitCount %d, got %d\n", expected->bits, out->biBitCount); - ok(out->biCompression == expected->compression, - "Expected compression %d, got %d\n", expected->compression, out->biCompression); - ok(out->biSizeImage == get_stride(out->biWidth, out->biBitCount) * out->biHeight, - "Expected biSizeImage %d, got %d\n", get_stride(out->biWidth, out->biBitCount) * out->biHeight, - out->biSizeImage); - - trace("query -> width: %d, height: %d, bit: %d, compression: %d, size: %d\n", - out->biWidth, out->biHeight, out->biBitCount, out->biCompression, out->biSizeImage); - break; - } - - case ICM_DECOMPRESS_GET_FORMAT: - { - BITMAPINFOHEADER *out = (BITMAPINFOHEADER *)lParam2; - - if (!lParam2) - { - trace("format -> without format\n"); - ok(!expected->output_format, "Expected no output format pointer\n"); - break; - } - - ok(expected->output_format, "Expected output format pointer\n"); - ok(out->biWidth == expected->width, - "Expected width %d, got %d\n", expected->width, out->biWidth); - ok(out->biHeight == expected->height, - "Expected height %d, got %d\n", expected->height, out->biHeight); - ok(out->biBitCount == expected->bits, - "Expected biBitCount %d, got %d\n", expected->bits, out->biBitCount); - ok(out->biCompression == expected->compression, - "Expected compression %d, got %d\n", expected->compression, out->biCompression); - - trace("format -> width: %d, height: %d, bit: %d, compression: %d, size: %d\n", - out->biWidth, out->biHeight, out->biBitCount, out->biCompression, out->biSizeImage); - - out->biBitCount = 64; - break; - } - } - - msg_index++; - return res; -} - - -void test_ICGetDisplayFormat(void) -{ - static const struct - { - int bits_wanted; - int bits_expected; - int dx; - int width_expected; - int dy; - int height_expected; - int msg_index; - } - tests[] = - { - { 8, 64, 0, 640, 0, 480, 9}, - { 8, 16, 0, 640, 0, 480, 13}, - { 8, 16, 0, 640, 0, 480, 17}, - {24, 64, 0, 640, 0, 480, 22}, - {32, 32, 0, 640, 0, 480, 25}, - { 0, 32, 0, 640, 0, 480, 28}, - { 9, 64, 0, 640, 0, 480, 33}, - {32, 32, 800, 800, 600, 600, 36}, - {32, 32, -1, 640, -1, 480, 39}, - {32, 32, -90, 640, -60, 480, 42}, - { 8, 8, 270, 270, 270, 270, 46}, - {16, 16, 270, 270, 270, 270, 49}, - {24, 24, 270, 270, 270, 270, 52}, - { 4, 4, 0, 640, 0, 480, 55}, - }; - - HIC ic, ic2; - BITMAPINFOHEADER in; - BITMAPINFOHEADER out; - int real_depth; - int i; - - ic = ICOpenFunction(ICTYPE_VIDEO, 0xdeadbeef, ICMODE_DECOMPRESS, driver_proc_test); - ok(!!ic, "Opening driver failed\n"); - - for (i = 0; i < sizeof(tests) / sizeof(tests[0]); i++) - { - memset(&in, 0, sizeof(in)); - memset(&out, 0, sizeof(out)); - - in.biSize = sizeof(in); - in.biWidth = 640; - in.biHeight = 480; - in.biPlanes = 1; - in.biBitCount = 32; - in.biCompression = BI_PNG; - in.biSizeImage = 1024; - - out.biBitCount = 16; - out.biWidth = 320; - out.biHeight = 240; - - ic2 = ICGetDisplayFormat(ic, &in, &out, tests[i].bits_wanted, tests[i].dx, tests[i].dy); - ok(!!ic2, "Expected ICGetDisplayFormat to succeeded\n"); - - ok(out.biBitCount == tests[i].bits_expected, - "Expected biBitCount %d, got %d\n", tests[i].bits_expected, out.biBitCount); - ok(out.biWidth == tests[i].width_expected, - "Expected biWidth %d, got %d\n", tests[i].width_expected, out.biWidth); - ok(out.biHeight == tests[i].height_expected, - "Expected biHeight %d, got %d\n", tests[i].height_expected, out.biHeight); - real_depth = (out.biBitCount > 32) ? 32 : out.biBitCount; - ok(out.biSizeImage == get_stride(out.biWidth, real_depth) * out.biHeight, - "Expected biSizeImage %d, got %d\n", get_stride(out.biWidth, real_depth) * out.biHeight, - out.biSizeImage); - ok(msg_index == tests[i].msg_index, - "Expected msg_index %d, got %d\n", tests[i].msg_index, msg_index); - } - - ICClose(ic); -} - static void test_ICInfo(void) { ICINFO info, info2; @@ -689,11 +405,262 @@ static void test_ICInfo(void) ok(info.fccHandler == mmioFOURCC('f','a','k','e'), "got 0x%08x\n", info.fccHandler); } +static int get_display_format_test; + +static DWORD get_size_image(LONG width, LONG height, WORD depth) +{ + DWORD ret = width * depth; + ret = (ret + 7) / 8; /* divide by byte size, rounding up */ + ret = (ret + 3) & ~3; /* align to 4 bytes */ + ret *= abs(height); + return ret; +} + +static const RGBQUAD color_yellow = {0x00, 0xff, 0xff, 0x00}; + +static BITMAPINFOHEADER gdf_in, *gdf_out; + +static LRESULT CALLBACK gdf_driver_proc(DWORD_PTR id, HDRVR driver, UINT msg, + LPARAM lparam1, LPARAM lparam2) +{ + LRESULT ret = 0; + + if (winetest_debug > 1) + trace("(%#lx, %p, %#x, %#lx, %#lx)\n", id, driver, msg, lparam1, lparam2); + + switch(msg) + { + case DRV_LOAD: + case DRV_OPEN: + case DRV_CLOSE: + case DRV_FREE: + return 1; + case ICM_DECOMPRESS_QUERY: + { + BITMAPINFOHEADER *out = (BITMAPINFOHEADER *)lparam2; + DWORD expected_size; + + ok(lparam1 == (LPARAM)&gdf_in, "got input %#lx\n", lparam1); + + if (!out) + return ICERR_OK; + + ok(out == gdf_out, "got output %p\n", out); + + ok(out->biSize == sizeof(*out), "got size %d\n", out->biSize); + expected_size = get_size_image(out->biWidth, out->biHeight, out->biBitCount); + ok(out->biSizeImage == expected_size, "expected image size %d, got %d\n", + expected_size, out->biSizeImage); + + ok(out->biPlanes == 0xcccc, "got planes %d\n", out->biPlanes); + ok(out->biXPelsPerMeter == 0xcccccccc && out->biYPelsPerMeter == 0xcccccccc, + "got resolution %dx%d\n", out->biXPelsPerMeter, out->biYPelsPerMeter); + ok(out->biClrUsed == 0xcccccccc, "got biClrUsed %u\n", out->biClrUsed); + ok(out->biClrImportant == 0xcccccccc, "got biClrImportant %u\n", out->biClrImportant); + + switch (get_display_format_test) + { + case 0: + return ICERR_OK; + case 1: + if (out->biWidth == 30 && out->biHeight == 40 && out->biCompression == BI_RGB && out->biBitCount == 16) + return ICERR_OK; + break; + case 2: + if (out->biWidth == 30 && out->biHeight == 40 && out->biCompression == BI_BITFIELDS && out->biBitCount == 16) + return ICERR_OK; + break; + case 3: + if (out->biWidth == 30 && out->biHeight == 40 && out->biCompression == BI_RGB && out->biBitCount == 24) + return ICERR_OK; + break; + case 4: + if (out->biWidth == 30 && out->biHeight == 40 && out->biCompression == BI_RGB && out->biBitCount == 32) + return ICERR_OK; + break; + case 5: + if (out->biWidth == 10 && out->biHeight == 20 && out->biCompression == BI_RGB && out->biBitCount == 32) + return ICERR_OK; + break; + case 6: + break; + } + + return ICERR_BADFORMAT; + } + case ICM_DECOMPRESS_GET_FORMAT: + { + BITMAPINFOHEADER *out = (BITMAPINFOHEADER *)lparam2; + + ok(lparam1 == (LPARAM)&gdf_in, "got input %#lx\n", lparam1); + if (out) + { + ok(out == gdf_out, "got output %p\n", out); + + memset(out, 0x55, sizeof(*out)); + out->biWidth = 50; + out->biHeight = 60; + out->biBitCount = 0xdead; + out->biCompression = 0xbeef; + out->biSizeImage = 0; + + return ICERR_OK; + } + } + case ICM_DECOMPRESS_GET_PALETTE: + { + BITMAPINFO *out = (BITMAPINFO *)lparam2; + + ok(lparam1 == (LPARAM)&gdf_in, "got input %#lx\n", lparam1); + if (out) + { + ok(out == (BITMAPINFO *)gdf_out, "got output %p\n", out); + + out->bmiHeader.biClrUsed = 1; + out->bmiColors[0] = color_yellow; + + return 0xdeadbeef; + } + } + } + + return ret; +} + +static void check_bitmap_header_(int line, BITMAPINFOHEADER *header, LONG width, LONG height, WORD depth, DWORD compression) +{ + ok_(__FILE__, line)(header->biWidth == width, "expected %d, got %d\n", width, header->biWidth); + ok_(__FILE__, line)(header->biHeight == height, "expected %d, got %d\n", height, header->biHeight); + ok_(__FILE__, line)(header->biBitCount == depth, "expected %d, got %d\n", depth, header->biBitCount); + ok_(__FILE__, line)(header->biCompression == compression, "expected %#x, got %#x\n", compression, header->biCompression); +} +#define check_bitmap_header(a,b,c,d,e) check_bitmap_header_(__LINE__,a,b,c,d,e) + +static void test_ICGetDisplayFormat(void) +{ + static const DWORD testcc = mmioFOURCC('t','e','s','t'); +#ifdef __REACTOS__ + char outbuf[FIELD_OFFSET(BITMAPINFO, bmiColors) + 256 * sizeof(RGBQUAD)]; +#else + char outbuf[FIELD_OFFSET(BITMAPINFO, bmiColors[256])]; +#endif + BITMAPINFO *out_bmi; + LRESULT lres; + BOOL ret; + HIC hic; + + memset(&gdf_in, 0xcc, sizeof(gdf_in)); + gdf_in.biSize = sizeof(gdf_in); + gdf_in.biWidth = 10; + gdf_in.biHeight = 20; + gdf_in.biBitCount = 1; + gdf_in.biCompression = testcc; + + ret = ICInstall(ICTYPE_VIDEO, testcc, (LPARAM)gdf_driver_proc, NULL, ICINSTALL_FUNCTION); + ok(ret, "ICInstall failed\n"); + + hic = ICOpen(ICTYPE_VIDEO, testcc, ICMODE_DECOMPRESS); + ok(ret, "ICOpen failed\n"); + + memset(outbuf, 0, sizeof(outbuf)); + gdf_out = (BITMAPINFOHEADER *)outbuf; + + /* ICGetDisplayFormat tries several default formats; make sure those work */ + get_display_format_test = 0; + hic = ICGetDisplayFormat(hic, &gdf_in, gdf_out, 1, 30, 40); + ok(hic != NULL, "ICGetDisplayFormat failed\n"); + check_bitmap_header(gdf_out, 30, 40, 1, BI_RGB); + + get_display_format_test = 1; + hic = ICGetDisplayFormat(hic, &gdf_in, gdf_out, 1, 30, 40); + ok(hic != NULL, "ICGetDisplayFormat failed\n"); + check_bitmap_header(gdf_out, 30, 40, 16, BI_RGB); + + get_display_format_test = 2; + hic = ICGetDisplayFormat(hic, &gdf_in, gdf_out, 1, 30, 40); + ok(hic != NULL, "ICGetDisplayFormat failed\n"); + check_bitmap_header(gdf_out, 30, 40, 16, BI_BITFIELDS); + + get_display_format_test = 3; + hic = ICGetDisplayFormat(hic, &gdf_in, gdf_out, 1, 30, 40); + ok(hic != NULL, "ICGetDisplayFormat failed\n"); + check_bitmap_header(gdf_out, 30, 40, 24, BI_RGB); + + get_display_format_test = 4; + hic = ICGetDisplayFormat(hic, &gdf_in, gdf_out, 1, 30, 40); + ok(hic != NULL, "ICGetDisplayFormat failed\n"); + check_bitmap_header(gdf_out, 30, 40, 32, BI_RGB); + + get_display_format_test = 5; + hic = ICGetDisplayFormat(hic, &gdf_in, gdf_out, 1, 30, 40); + ok(hic != NULL, "ICGetDisplayFormat failed\n"); + check_bitmap_header(gdf_out, 10, 20, 32, BI_RGB); + + /* if every default format is rejected, the output of + * ICM_DECOMPRESS_GET_FORMAT is returned */ + get_display_format_test = 6; + hic = ICGetDisplayFormat(hic, &gdf_in, gdf_out, 1, 30, 40); + ok(hic != NULL, "ICGetDisplayFormat failed\n"); + check_bitmap_header(gdf_out, 50, 60, 0xdead, 0xbeef); + + /* given bpp is treated as a lower bound */ + get_display_format_test = 1; + hic = ICGetDisplayFormat(hic, &gdf_in, gdf_out, 24, 30, 40); + ok(hic != NULL, "ICGetDisplayFormat failed\n"); + check_bitmap_header(gdf_out, 50, 60, 0xdead, 0xbeef); + + get_display_format_test = 3; + hic = ICGetDisplayFormat(hic, &gdf_in, gdf_out, 24, 30, 40); + ok(hic != NULL, "ICGetDisplayFormat failed\n"); + check_bitmap_header(gdf_out, 30, 40, 24, BI_RGB); + + get_display_format_test = 0; + + /* width or height <= 0 causes the input width and height to be supplied */ + hic = ICGetDisplayFormat(hic, &gdf_in, gdf_out, 1, 0, 40); + ok(hic != NULL, "ICGetDisplayFormat failed\n"); + check_bitmap_header(gdf_out, 10, 20, 1, BI_RGB); + + hic = ICGetDisplayFormat(hic, &gdf_in, gdf_out, 1, 30, 0); + ok(hic != NULL, "ICGetDisplayFormat failed\n"); + check_bitmap_header(gdf_out, 10, 20, 1, BI_RGB); + + hic = ICGetDisplayFormat(hic, &gdf_in, gdf_out, 1, -10, 40); + ok(hic != NULL, "ICGetDisplayFormat failed\n"); + check_bitmap_header(gdf_out, 10, 20, 1, BI_RGB); + + hic = ICGetDisplayFormat(hic, &gdf_in, gdf_out, 1, 30, -10); + ok(hic != NULL, "ICGetDisplayFormat failed\n"); + check_bitmap_header(gdf_out, 10, 20, 1, BI_RGB); + + /* zero bpp causes 32 bpp to be supplied */ + hic = ICGetDisplayFormat(hic, &gdf_in, gdf_out, 0, 30, 40); + ok(hic != NULL, "ICGetDisplayFormat failed\n"); + ok(gdf_out->biBitCount == 32 || gdf_out->biBitCount == 24, + "got %d\n", gdf_out->biBitCount); + ok(gdf_out->biCompression == BI_RGB, "got %#x\n", gdf_out->biCompression); + + /* specifying 8 bpp yields a request for palette colours */ + hic = ICGetDisplayFormat(hic, &gdf_in, gdf_out, 8, 30, 40); + ok(hic != NULL, "ICGetDisplayFormat failed\n"); + check_bitmap_header(gdf_out, 30, 40, 8, BI_RGB); + ok(gdf_out->biClrUsed == 1, "got biClrUsed %u\n", gdf_out->biClrUsed); + out_bmi = (BITMAPINFO *)gdf_out; + ok(!memcmp(&out_bmi->bmiColors[0], &color_yellow, sizeof(color_yellow)), + "got wrong colour\n"); + + lres = ICClose(hic); + ok(lres == ICERR_OK, "got %ld\n", lres); + + ret = ICRemove(ICTYPE_VIDEO, testcc, 0); + ok(ret, "ICRemove failed\n"); +} + START_TEST(msvfw) { test_OpenCase(); test_Locate(); test_ICSeqCompress(); - test_ICGetDisplayFormat(); test_ICInfo(); + test_ICGetDisplayFormat(); }