Commit 2e620148 authored by Nikolay Sivov's avatar Nikolay Sivov Committed by Alexandre Julliard

comctl32/imagelist: Implement IImageList::GetItemFlags().

parent e6e77f14
...@@ -76,7 +76,7 @@ struct _IMAGELIST ...@@ -76,7 +76,7 @@ struct _IMAGELIST
HBRUSH hbrBlend50; HBRUSH hbrBlend50;
INT cInitial; INT cInitial;
UINT uBitsPixel; UINT uBitsPixel;
char *has_alpha; DWORD *item_flags;
BOOL color_table_set; BOOL color_table_set;
LONG ref; /* reference count */ LONG ref; /* reference count */
...@@ -217,7 +217,7 @@ static void add_dib_bits( HIMAGELIST himl, int pos, int count, int width, int he ...@@ -217,7 +217,7 @@ static void add_dib_bits( HIMAGELIST himl, int pos, int count, int width, int he
if (has_alpha) if (has_alpha)
{ {
himl->has_alpha[pos + n] = 1; himl->item_flags[pos + n] = ILIF_ALPHA;
if (mask_info && himl->hbmMask) /* generate the mask from the alpha channel */ if (mask_info && himl->hbmMask) /* generate the mask from the alpha channel */
{ {
...@@ -251,7 +251,7 @@ static BOOL add_with_alpha( HIMAGELIST himl, HDC hdc, int pos, int count, ...@@ -251,7 +251,7 @@ static BOOL add_with_alpha( HIMAGELIST himl, HDC hdc, int pos, int count,
if (!GetObjectW( hbmImage, sizeof(bm), &bm )) return FALSE; if (!GetObjectW( hbmImage, sizeof(bm), &bm )) return FALSE;
/* if either the imagelist or the source bitmap don't have an alpha channel, bail out now */ /* if either the imagelist or the source bitmap don't have an alpha channel, bail out now */
if (!himl->has_alpha) return FALSE; if ((himl->flags & 0xfe) != ILC_COLOR32) return FALSE;
if (bm.bmBitsPixel != 32) return FALSE; if (bm.bmBitsPixel != 32) return FALSE;
SelectObject( hdc, hbmImage ); SelectObject( hdc, hbmImage );
...@@ -368,17 +368,8 @@ IMAGELIST_InternalExpandBitmaps(HIMAGELIST himl, INT nImageCount) ...@@ -368,17 +368,8 @@ IMAGELIST_InternalExpandBitmaps(HIMAGELIST himl, INT nImageCount)
himl->hbmMask = hbmNewBitmap; himl->hbmMask = hbmNewBitmap;
} }
if (himl->has_alpha) himl->item_flags = HeapReAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, himl->item_flags,
{ nNewCount * sizeof(*himl->item_flags));
char *new_alpha = HeapReAlloc( GetProcessHeap(), HEAP_ZERO_MEMORY, himl->has_alpha, nNewCount );
if (new_alpha) himl->has_alpha = new_alpha;
else
{
heap_free( himl->has_alpha );
himl->has_alpha = NULL;
}
}
himl->cMaxImage = nNewCount; himl->cMaxImage = nNewCount;
DeleteDC (hdcBitmap); DeleteDC (hdcBitmap);
...@@ -844,10 +835,7 @@ ImageList_Create (INT cx, INT cy, UINT flags, ...@@ -844,10 +835,7 @@ ImageList_Create (INT cx, INT cy, UINT flags,
else else
himl->hbmMask = 0; himl->hbmMask = 0;
if (ilc == ILC_COLOR32) himl->item_flags = heap_alloc_zero( himl->cMaxImage * sizeof(*himl->item_flags) );
himl->has_alpha = heap_alloc_zero( himl->cMaxImage );
else
himl->has_alpha = NULL;
/* create blending brushes */ /* create blending brushes */
hbmTemp = CreateBitmap (8, 8, 1, 1, aBitBlend25); hbmTemp = CreateBitmap (8, 8, 1, 1, aBitBlend25);
...@@ -1433,7 +1421,7 @@ ImageList_DrawIndirect (IMAGELISTDRAWPARAMS *pimldp) ...@@ -1433,7 +1421,7 @@ ImageList_DrawIndirect (IMAGELISTDRAWPARAMS *pimldp)
oldImageFg = SetTextColor( hImageDC, RGB( 0, 0, 0 ) ); oldImageFg = SetTextColor( hImageDC, RGB( 0, 0, 0 ) );
oldImageBk = SetBkColor( hImageDC, RGB( 0xff, 0xff, 0xff ) ); oldImageBk = SetBkColor( hImageDC, RGB( 0xff, 0xff, 0xff ) );
has_alpha = (himl->has_alpha && himl->has_alpha[pimldp->i]); has_alpha = himl->item_flags[pimldp->i] & ILIF_ALPHA;
if (!bMask && (has_alpha || (fState & ILS_ALPHA) || (fState & ILS_SATURATE))) if (!bMask && (has_alpha || (fState & ILS_ALPHA) || (fState & ILS_SATURATE)))
{ {
COLORREF colour, blend_col = CLR_NONE; COLORREF colour, blend_col = CLR_NONE;
...@@ -1632,8 +1620,7 @@ ImageList_Duplicate (HIMAGELIST himlSrc) ...@@ -1632,8 +1620,7 @@ ImageList_Duplicate (HIMAGELIST himlSrc)
himlSrc->hdcMask, 0, 0, SRCCOPY); himlSrc->hdcMask, 0, 0, SRCCOPY);
himlDst->cCurImage = himlSrc->cCurImage; himlDst->cCurImage = himlSrc->cCurImage;
if (himlSrc->has_alpha && himlDst->has_alpha) memcpy( himlDst->item_flags, himlSrc->item_flags, himlDst->cCurImage * sizeof(*himlDst->item_flags) );
memcpy( himlDst->has_alpha, himlSrc->has_alpha, himlDst->cCurImage );
} }
return himlDst; return himlDst;
} }
...@@ -2300,7 +2287,7 @@ HIMAGELIST WINAPI ImageList_Read(IStream *pstm) ...@@ -2300,7 +2287,7 @@ HIMAGELIST WINAPI ImageList_Read(IStream *pstm)
} }
else mask_info = NULL; else mask_info = NULL;
if (himl->has_alpha && image_info->bmiHeader.biBitCount == 32) if ((himl->flags & 0xfe) == ILC_COLOR32 && image_info->bmiHeader.biBitCount == 32)
{ {
DWORD *ptr = image_bits; DWORD *ptr = image_bits;
BYTE *mask_ptr = mask_bits; BYTE *mask_ptr = mask_bits;
...@@ -2396,11 +2383,8 @@ ImageList_Remove (HIMAGELIST himl, INT i) ...@@ -2396,11 +2383,8 @@ ImageList_Remove (HIMAGELIST himl, INT i)
for (nCount = 0; nCount < MAX_OVERLAYIMAGE; nCount++) for (nCount = 0; nCount < MAX_OVERLAYIMAGE; nCount++)
himl->nOvlIdx[nCount] = -1; himl->nOvlIdx[nCount] = -1;
if (himl->has_alpha) heap_free( himl->item_flags );
{ himl->item_flags = heap_alloc_zero( himl->cMaxImage * sizeof(*himl->item_flags) );
heap_free( himl->has_alpha );
himl->has_alpha = heap_alloc_zero( himl->cMaxImage );
}
hbmNewImage = ImageList_CreateImage(himl->hdcImage, himl, himl->cMaxImage); hbmNewImage = ImageList_CreateImage(himl->hdcImage, himl, himl->cMaxImage);
SelectObject (himl->hdcImage, hbmNewImage); SelectObject (himl->hdcImage, hbmNewImage);
...@@ -2615,7 +2599,7 @@ ImageList_ReplaceIcon (HIMAGELIST himl, INT nIndex, HICON hIcon) ...@@ -2615,7 +2599,7 @@ ImageList_ReplaceIcon (HIMAGELIST himl, INT nIndex, HICON hIcon)
himl->cCurImage++; himl->cCurImage++;
} }
if (himl->has_alpha && GetIconInfo (hBestFitIcon, &ii)) if ((himl->flags & 0xfe) == ILC_COLOR32 && GetIconInfo (hBestFitIcon, &ii))
{ {
HDC hdcImage = CreateCompatibleDC( 0 ); HDC hdcImage = CreateCompatibleDC( 0 );
GetObjectW (ii.hbmMask, sizeof(BITMAP), &bmp); GetObjectW (ii.hbmMask, sizeof(BITMAP), &bmp);
...@@ -2940,16 +2924,8 @@ ImageList_SetImageCount (HIMAGELIST himl, UINT iImageCount) ...@@ -2940,16 +2924,8 @@ ImageList_SetImageCount (HIMAGELIST himl, UINT iImageCount)
DeleteDC (hdcBitmap); DeleteDC (hdcBitmap);
if (himl->has_alpha) himl->item_flags = HeapReAlloc( GetProcessHeap(), HEAP_ZERO_MEMORY, himl->item_flags,
{ nNewCount * sizeof(*himl->item_flags));
char *new_alpha = HeapReAlloc( GetProcessHeap(), HEAP_ZERO_MEMORY, himl->has_alpha, nNewCount );
if (new_alpha) himl->has_alpha = new_alpha;
else
{
heap_free( himl->has_alpha );
himl->has_alpha = NULL;
}
}
/* Update max image count and current image count */ /* Update max image count and current image count */
himl->cMaxImage = nNewCount; himl->cMaxImage = nNewCount;
...@@ -3292,7 +3268,7 @@ static ULONG WINAPI ImageListImpl_Release(IImageList2 *iface) ...@@ -3292,7 +3268,7 @@ static ULONG WINAPI ImageListImpl_Release(IImageList2 *iface)
if (This->hbrBlend50) DeleteObject (This->hbrBlend50); if (This->hbrBlend50) DeleteObject (This->hbrBlend50);
This->IImageList2_iface.lpVtbl = NULL; This->IImageList2_iface.lpVtbl = NULL;
heap_free(This->has_alpha); heap_free(This->item_flags);
heap_free(This); heap_free(This);
} }
...@@ -3626,11 +3602,16 @@ static HRESULT WINAPI ImageListImpl_GetDragImage(IImageList2 *iface, POINT *ppt, ...@@ -3626,11 +3602,16 @@ static HRESULT WINAPI ImageListImpl_GetDragImage(IImageList2 *iface, POINT *ppt,
return ret; return ret;
} }
static HRESULT WINAPI ImageListImpl_GetItemFlags(IImageList2 *iface, int i, static HRESULT WINAPI ImageListImpl_GetItemFlags(IImageList2 *iface, int i, DWORD *flags)
DWORD *dwFlags)
{ {
FIXME("STUB: %p %d %p\n", iface, i, dwFlags); HIMAGELIST This = impl_from_IImageList2(iface);
return E_NOTIMPL;
if (i < 0 || i >= This->cCurImage)
return E_INVALIDARG;
*flags = This->item_flags[i];
return S_OK;
} }
static HRESULT WINAPI ImageListImpl_GetOverlayImage(IImageList2 *iface, int iOverlay, static HRESULT WINAPI ImageListImpl_GetOverlayImage(IImageList2 *iface, int iOverlay,
......
...@@ -1502,6 +1502,9 @@ static void test_ImageList_DrawIndirect(void) ...@@ -1502,6 +1502,9 @@ static void test_ImageList_DrawIndirect(void)
UINT32 *bits = 0; UINT32 *bits = 0;
UINT32 maskBits = 0x00000000, inverseMaskBits = 0xFFFFFFFF; UINT32 maskBits = 0x00000000, inverseMaskBits = 0xFFFFFFFF;
int bpp, broken_value; int bpp, broken_value;
IImageList *imgl;
DWORD flags;
HRESULT hr;
BITMAPINFO bitmapInfo = {{sizeof(BITMAPINFOHEADER), 2, 1, 1, 32, BI_RGB, BITMAPINFO bitmapInfo = {{sizeof(BITMAPINFOHEADER), 2, 1, 1, 32, BI_RGB,
0, 0, 0, 0, 0}}; 0, 0, 0, 0, 0}};
...@@ -1524,6 +1527,9 @@ static void test_ImageList_DrawIndirect(void) ...@@ -1524,6 +1527,9 @@ static void test_ImageList_DrawIndirect(void)
ok(himl != 0, "ImageList_Create failed\n"); ok(himl != 0, "ImageList_Create failed\n");
if(!himl) goto cleanup; if(!himl) goto cleanup;
hr = pHIMAGELIST_QueryInterface(himl, &IID_IImageList, (void **) &imgl);
ok(hr == S_OK, "Failed to get interface, hr %#x.\n", hr);
/* Add a no-alpha image */ /* Add a no-alpha image */
hbmImage = create_test_bitmap(hdcDst, 2, 1, 32, bits_image); hbmImage = create_test_bitmap(hdcDst, 2, 1, 32, bits_image);
if(!hbmImage) goto cleanup; if(!hbmImage) goto cleanup;
...@@ -1532,6 +1538,16 @@ static void test_ImageList_DrawIndirect(void) ...@@ -1532,6 +1538,16 @@ static void test_ImageList_DrawIndirect(void)
ok(iImage != -1, "ImageList_Add failed\n"); ok(iImage != -1, "ImageList_Add failed\n");
if(iImage == -1) goto cleanup; if(iImage == -1) goto cleanup;
hr = IImageList_GetItemFlags(imgl, 1000, &flags);
ok(hr == E_INVALIDARG, "Unexpected hr %#x.\n", hr);
hr = IImageList_GetItemFlags(imgl, 1000, NULL);
ok(hr == E_INVALIDARG, "Unexpected hr %#x.\n", hr);
hr = IImageList_GetItemFlags(imgl, iImage, &flags);
ok(hr == S_OK, "Failed to get item flags, hr %#x.\n", hr);
ok(!flags, "Unexpected flags %#x.\n", flags);
/* Add an alpha image */ /* Add an alpha image */
hbmAlphaImage = create_test_bitmap(hdcDst, 2, 1, 32, bits_alpha); hbmAlphaImage = create_test_bitmap(hdcDst, 2, 1, 32, bits_alpha);
if(!hbmAlphaImage) goto cleanup; if(!hbmAlphaImage) goto cleanup;
...@@ -1540,6 +1556,10 @@ static void test_ImageList_DrawIndirect(void) ...@@ -1540,6 +1556,10 @@ static void test_ImageList_DrawIndirect(void)
ok(iAlphaImage != -1, "ImageList_Add failed\n"); ok(iAlphaImage != -1, "ImageList_Add failed\n");
if(iAlphaImage == -1) goto cleanup; if(iAlphaImage == -1) goto cleanup;
hr = IImageList_GetItemFlags(imgl, iAlphaImage, &flags);
ok(hr == S_OK, "Failed to get item flags, hr %#x.\n", hr);
ok(flags & ILIF_ALPHA, "Unexpected flags %#x.\n", flags);
/* Add a transparent alpha image */ /* Add a transparent alpha image */
hbmTransparentImage = create_test_bitmap(hdcDst, 2, 1, 32, bits_transparent); hbmTransparentImage = create_test_bitmap(hdcDst, 2, 1, 32, bits_transparent);
if(!hbmTransparentImage) goto cleanup; if(!hbmTransparentImage) goto cleanup;
...@@ -1548,6 +1568,10 @@ static void test_ImageList_DrawIndirect(void) ...@@ -1548,6 +1568,10 @@ static void test_ImageList_DrawIndirect(void)
ok(iTransparentImage != -1, "ImageList_Add failed\n"); ok(iTransparentImage != -1, "ImageList_Add failed\n");
if(iTransparentImage == -1) goto cleanup; if(iTransparentImage == -1) goto cleanup;
hr = IImageList_GetItemFlags(imgl, iTransparentImage, &flags);
ok(hr == S_OK, "Failed to get item flags, hr %#x.\n", hr);
ok(flags & ILIF_ALPHA, "Unexpected flags %#x.\n", flags);
/* 32-bit Tests */ /* 32-bit Tests */
bitmapInfo.bmiHeader.biBitCount = 32; bitmapInfo.bmiHeader.biBitCount = 32;
hbmDst = CreateDIBSection(hdcDst, &bitmapInfo, DIB_RGB_COLORS, (void**)&bits, NULL, 0); hbmDst = CreateDIBSection(hdcDst, &bitmapInfo, DIB_RGB_COLORS, (void**)&bits, NULL, 0);
...@@ -1713,7 +1737,7 @@ static void test_iimagelist(void) ...@@ -1713,7 +1737,7 @@ static void test_iimagelist(void)
if (!himl) if (!himl)
return; return;
hr = (pHIMAGELIST_QueryInterface)(himl, &IID_IImageList, (void **) &imgl); hr = pHIMAGELIST_QueryInterface(himl, &IID_IImageList, (void **) &imgl);
ok(SUCCEEDED(hr), "HIMAGELIST_QueryInterface failed, hr=%x\n", hr); ok(SUCCEEDED(hr), "HIMAGELIST_QueryInterface failed, hr=%x\n", hr);
if (hr == S_OK) if (hr == S_OK)
......
...@@ -63,7 +63,8 @@ cpp_quote("#endif") ...@@ -63,7 +63,8 @@ cpp_quote("#endif")
cpp_quote("HRESULT WINAPI ImageList_CoCreateInstance(REFCLSID,const IUnknown *, REFIID,void **);") cpp_quote("HRESULT WINAPI ImageList_CoCreateInstance(REFCLSID,const IUnknown *, REFIID,void **);")
const UINT ILIF_ALPHA = 1; cpp_quote("#define ILIF_ALPHA 0x00000001")
cpp_quote("#define ILIF_LOWQUALITY 0x00000002")
[ [
uuid(46eb5926-582e-4017-9fdf-e8998daa0950), uuid(46eb5926-582e-4017-9fdf-e8998daa0950),
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment