[PATCH 0/2] MR10037: comctl32/imagelist: Fix swapping images in ImageList_Copy().
hdcBmp has hbmTempMask selected after the last SelectObject(), we need to select hbmTempImage into hdcBmp. Otherwise, a mask bitmap is copied into a color bitmap. -- https://gitlab.winehq.org/wine/wine/-/merge_requests/10037
From: Zhiyi Zhang <zzhang@codeweavers.com> --- dlls/comctl32/tests/imagelist.c | 34 +++++++++++++++++++++++++++++++++ 1 file changed, 34 insertions(+) diff --git a/dlls/comctl32/tests/imagelist.c b/dlls/comctl32/tests/imagelist.c index c8a1a25b71d..4c9084bab85 100644 --- a/dlls/comctl32/tests/imagelist.c +++ b/dlls/comctl32/tests/imagelist.c @@ -2466,9 +2466,18 @@ static void test_color_table(UINT ilc) static void test_copy(void) { + /* each line is a 1x1 bitmap */ + static const UINT32 test_bitmaps[] = + { + 0x00654321, + 0x00ABCDEF, + }; HIMAGELIST dst, src; + HBITMAP hbm; + UINT32 bits; BOOL ret; int count; + HDC hdc; dst = pImageList_Create(5, 11, ILC_COLOR, 1, 1); count = pImageList_GetImageCount(dst); @@ -2485,6 +2494,31 @@ static void test_copy(void) pImageList_Destroy(dst); pImageList_Destroy(src); + + /* Test swapping images */ + src = pImageList_Create(1, 1, ILC_COLOR32 | ILC_MASK, 2, 1); + + hdc = CreateCompatibleDC(0); + hbm = create_test_bitmap(hdc, 1, 1, 32, &test_bitmaps[0]); + ret = pImageList_AddMasked(src, hbm, RGB(0xff, 0x00, 0x00)); + ok(ret == 0, "ImageList_AddMasked() returned %d, expected %d.\n", ret, 0); + DeleteObject(hbm); + hbm = create_test_bitmap(hdc, 1, 1, 32, &test_bitmaps[1]); + ret = pImageList_AddMasked(src, hbm, RGB(0xff, 0x00, 0x00)); + ok(ret == 1, "ImageList_AddMasked() returned %d, expected %d.\n", ret, 1); + DeleteObject(hbm); + DeleteDC(hdc); + + ret = pImageList_Copy(src, 0, src, 1, ILCF_SWAP); + ok(ret, "ImageList_Copy() failed.\n"); + + image_list_get_image_bits_by_bitmap(src, 0, &bits); + ok(colour_match(bits, test_bitmaps[1]), "Got unexpected color %08x.\n", bits); + image_list_get_image_bits_by_bitmap(src, 1, &bits); + todo_wine + ok(colour_match(bits, test_bitmaps[0]), "Got unexpected color %08x.\n", bits); + + pImageList_Destroy(src); } static void test_loadimage(void) -- GitLab https://gitlab.winehq.org/wine/wine/-/merge_requests/10037
From: Zhiyi Zhang <zzhang@codeweavers.com> hdcBmp has hbmTempMask selected after the last SelectObject(), we need to select hbmTempImage into hdcBmp. Otherwise, a mask bitmap is copied into a color bitmap. --- dlls/comctl32/imagelist.c | 1 + dlls/comctl32/tests/imagelist.c | 1 - 2 files changed, 1 insertion(+), 1 deletion(-) diff --git a/dlls/comctl32/imagelist.c b/dlls/comctl32/imagelist.c index 93c502ec0bd..ab65bca7c07 100644 --- a/dlls/comctl32/imagelist.c +++ b/dlls/comctl32/imagelist.c @@ -721,6 +721,7 @@ ImageList_Copy (HIMAGELIST himlDst, INT iDst, HIMAGELIST himlSrc, hdcBmp, 0, 0, SRCCOPY); /* image */ + SelectObject (hdcBmp, hbmTempImage); BitBlt (himlSrc->hdcImage, ptSrc.x, ptSrc.y, himlSrc->cx, himlSrc->cy, hdcBmp, 0, 0, SRCCOPY); /* delete temporary bitmaps */ diff --git a/dlls/comctl32/tests/imagelist.c b/dlls/comctl32/tests/imagelist.c index 4c9084bab85..68ad0ce7a4c 100644 --- a/dlls/comctl32/tests/imagelist.c +++ b/dlls/comctl32/tests/imagelist.c @@ -2515,7 +2515,6 @@ static void test_copy(void) image_list_get_image_bits_by_bitmap(src, 0, &bits); ok(colour_match(bits, test_bitmaps[1]), "Got unexpected color %08x.\n", bits); image_list_get_image_bits_by_bitmap(src, 1, &bits); - todo_wine ok(colour_match(bits, test_bitmaps[0]), "Got unexpected color %08x.\n", bits); pImageList_Destroy(src); -- GitLab https://gitlab.winehq.org/wine/wine/-/merge_requests/10037
Looks like this path never worked correctly. -- https://gitlab.winehq.org/wine/wine/-/merge_requests/10037#note_129059
This merge request was approved by Nikolay Sivov. -- https://gitlab.winehq.org/wine/wine/-/merge_requests/10037
participants (3)
-
Nikolay Sivov (@nsivov) -
Zhiyi Zhang -
Zhiyi Zhang (@zhiyi)