user32: Use create_cursoricon_object in CreateIconIndirect.

Signed-off-by: Jacek Caban <jacek@codeweavers.com>
Signed-off-by: Huw Davies <huw@codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
This commit is contained in:
Jacek Caban 2022-02-22 13:41:52 +01:00 committed by Alexandre Julliard
parent f0176397ad
commit a37a0a94d4
1 changed files with 31 additions and 42 deletions

View File

@ -2373,10 +2373,10 @@ static void stretch_blt_icon( HDC hdc_dst, int dst_x, int dst_y, int dst_width,
*/ */
HICON WINAPI CreateIconIndirect(PICONINFO iconinfo) HICON WINAPI CreateIconIndirect(PICONINFO iconinfo)
{ {
struct cursoricon_frame frame = { 0 };
struct cursoricon_desc desc = { .frames = &frame };
BITMAP bmpXor, bmpAnd; BITMAP bmpXor, bmpAnd;
HICON hObj; HICON ret;
HBITMAP color = 0, mask;
int width, height;
HDC hdc; HDC hdc;
TRACE("color %p, mask %p, hotspot %ux%u, fIcon %d\n", TRACE("color %p, mask %p, hotspot %ux%u, fIcon %d\n",
@ -2397,59 +2397,48 @@ HICON WINAPI CreateIconIndirect(PICONINFO iconinfo)
bmpXor.bmWidth, bmpXor.bmHeight, bmpXor.bmWidthBytes, bmpXor.bmWidth, bmpXor.bmHeight, bmpXor.bmWidthBytes,
bmpXor.bmPlanes, bmpXor.bmBitsPixel); bmpXor.bmPlanes, bmpXor.bmBitsPixel);
width = bmpXor.bmWidth; frame.width = bmpXor.bmWidth;
height = bmpXor.bmHeight; frame.height = bmpXor.bmHeight;
color = create_color_bitmap( width, height ); frame.color = create_color_bitmap( frame.width, frame.height );
} }
else else
{ {
width = bmpAnd.bmWidth; frame.width = bmpAnd.bmWidth;
height = bmpAnd.bmHeight; frame.height = bmpAnd.bmHeight;
} }
mask = CreateBitmap( width, height, 1, 1, NULL ); frame.mask = CreateBitmap( frame.width, frame.height, 1, 1, NULL );
hdc = CreateCompatibleDC( 0 ); hdc = CreateCompatibleDC( 0 );
SelectObject( hdc, mask ); SelectObject( hdc, frame.mask );
stretch_blt_icon( hdc, 0, 0, width, height, iconinfo->hbmMask, bmpAnd.bmWidth, bmpAnd.bmHeight ); stretch_blt_icon( hdc, 0, 0, frame.width, frame.height, iconinfo->hbmMask,
bmpAnd.bmWidth, bmpAnd.bmHeight );
if (color) if (frame.color)
{ {
SelectObject( hdc, color ); SelectObject( hdc, frame.color );
stretch_blt_icon( hdc, 0, 0, width, height, iconinfo->hbmColor, width, height ); stretch_blt_icon( hdc, 0, 0, frame.width, frame.height, iconinfo->hbmColor,
frame.width, frame.height );
} }
else height /= 2; else frame.height /= 2;
DeleteDC( hdc ); DeleteDC( hdc );
hObj = alloc_icon_handle( FALSE, 0 ); frame.alpha = create_alpha_bitmap( iconinfo->hbmColor, NULL, NULL );
if (hObj)
{
struct cursoricon_object *info = get_icon_ptr( hObj );
struct cursoricon_frame *frame;
info->is_icon = iconinfo->fIcon; if (iconinfo->fIcon)
frame = get_icon_frame( info, 0 );
frame->delay = ~0;
frame->width = width;
frame->height = height;
frame->color = color;
frame->mask = mask;
frame->alpha = create_alpha_bitmap( iconinfo->hbmColor, NULL, NULL );
if (info->is_icon)
{ {
frame->hotspot.x = width / 2; frame.hotspot.x = frame.width / 2;
frame->hotspot.y = height / 2; frame.hotspot.y = frame.height / 2;
} }
else else
{ {
frame->hotspot.x = iconinfo->xHotspot; frame.hotspot.x = iconinfo->xHotspot;
frame->hotspot.y = iconinfo->yHotspot; frame.hotspot.y = iconinfo->yHotspot;
} }
release_icon_frame( info, frame ); ret = create_cursoricon_object( &desc, iconinfo->fIcon, 0, 0, 0 );
release_user_handle_ptr( info ); if (!ret) free_icon_frame( &frame );
} return ret;
return hObj;
} }
/****************************************************************************** /******************************************************************************