comctl32/imagelist: use proper color format for merged image lists (try 2)
Daniel Jelinski
djelinski1 at gmail.com
Mon Mar 4 23:28:59 CST 2013
-------------- next part --------------
From 724a01f4921510114d69780d7e82ea2800cc20f3 Mon Sep 17 00:00:00 2001
From: Daniel Jelinski <djelinski1 at gmail.com>
Date: Wed, 27 Feb 2013 21:47:43 +0100
Subject: [PATCH] comctl32/imagelist: use proper color format for merged image
lists
this time with tests
---
dlls/comctl32/imagelist.c | 4 ++-
dlls/comctl32/tests/imagelist.c | 55 +++++++++++++++++++++++++++++++++++++++
2 files changed, 58 insertions(+), 1 deletions(-)
diff --git a/dlls/comctl32/imagelist.c b/dlls/comctl32/imagelist.c
index 03c359f..6c1f617 100644
--- a/dlls/comctl32/imagelist.c
+++ b/dlls/comctl32/imagelist.c
@@ -2082,6 +2082,7 @@ ImageList_Merge (HIMAGELIST himl1, INT i1, HIMAGELIST himl2, INT i2,
INT cxDst, cyDst;
INT xOff1, yOff1, xOff2, yOff2;
POINT pt1, pt2;
+ INT uBitsPixel;
TRACE("(himl1=%p i1=%d himl2=%p i2=%d dx=%d dy=%d)\n", himl1, i1, himl2,
i2, dx, dy);
@@ -2121,7 +2122,8 @@ ImageList_Merge (HIMAGELIST himl1, INT i1, HIMAGELIST himl2, INT i2,
yOff2 = 0;
}
- himlDst = ImageList_Create (cxDst, cyDst, ILC_MASK | ILC_COLOR, 1, 1);
+ uBitsPixel = himl1->uBitsPixel > himl2->uBitsPixel ? himl1->uBitsPixel : himl2->uBitsPixel;
+ himlDst = ImageList_Create (cxDst, cyDst, ILC_MASK | uBitsPixel, 1, 1);
if (himlDst)
{
diff --git a/dlls/comctl32/tests/imagelist.c b/dlls/comctl32/tests/imagelist.c
index 19d2437..93b5876 100644
--- a/dlls/comctl32/tests/imagelist.c
+++ b/dlls/comctl32/tests/imagelist.c
@@ -492,6 +492,60 @@ static void test_DrawIndirect(void)
DestroyWindow(hwndfortest);
}
+static int get_color_format(HBITMAP bmp)
+{
+ BITMAPINFO bmi;
+ HDC hdc = CreateCompatibleDC(0);
+ HBITMAP hOldBmp = SelectObject(hdc, bmp);
+ int ret;
+
+ memset(&bmi, 0, sizeof(bmi));
+ bmi.bmiHeader.biSize = sizeof(BITMAPINFOHEADER);
+ ret = GetDIBits(hdc, bmp, 0, 0, 0, &bmi, DIB_RGB_COLORS);
+ ok(ret, "GetDIBits failed\n");
+
+ SelectObject(hdc, hOldBmp);
+ DeleteDC(hdc);
+ return bmi.bmiHeader.biBitCount;
+}
+
+static void test_merge_colors(void)
+{
+ HIMAGELIST himl[5], hmerge;
+ int sizes[] = { ILC_COLOR4, ILC_COLOR8, ILC_COLOR16, ILC_COLOR24, ILC_COLOR32 };
+ HICON hicon1;
+ IMAGEINFO info;
+ int bpp, i, j;
+
+ hicon1 = CreateIcon(hinst, 32, 32, 1, 1, icon_bits, icon_bits);
+ ok(hicon1 != NULL, "failed to create hicon1\n");
+
+ for (i = 0; i < 5; i++)
+ {
+ himl[i] = ImageList_Create(32, 32, sizes[i], 0, 3);
+ ok(himl[i] != NULL, "failed to create himl[%d]\n", i);
+ ok(0 == ImageList_AddIcon(himl[i], hicon1), "add icon1 to himl[%d] failed\n", i);
+ }
+ DestroyIcon(hicon1);
+
+ for (i = 0; i < 5; i++)
+ for (j = 0; j < 5; j++)
+ {
+ hmerge = ImageList_Merge(himl[i], 0, himl[j], 0, 0, 0);
+ ok(hmerge != NULL, "merge himl[%d], himl[%d] failed\n", i, j);
+
+ ImageList_GetImageInfo(hmerge, 0, &info);
+ bpp = get_color_format(info.hbmImage);
+ /* ILC_COLOR[X] is defined as [X] */
+ ok(bpp == (i > j ? sizes[i] : sizes[j]), "wrong biBitCount %d\n", bpp);
+
+ if (hmerge) ImageList_Destroy(hmerge);
+ }
+
+ for (i = 0; i < 5; i++)
+ ImageList_Destroy(himl[i]);
+}
+
static void test_merge(void)
{
HIMAGELIST himl1, himl2, hmerge;
@@ -2017,6 +2071,7 @@ START_TEST(imagelist)
test_imagecount();
test_DrawIndirect();
test_merge();
+ test_merge_colors();
test_imagelist_storage();
test_iconsize();
--
1.7.5.4
More information about the wine-patches
mailing list