[PATCH] user32/cursoricon: Fix CreateIcon() bitmap mask handling.

Huw Davies huw at codeweavers.com
Tue Apr 3 06:58:22 CDT 2018


On Fri, Mar 30, 2018 at 07:32:31PM +0800, Zhiyi Zhang wrote:
> 
> Signed-off-by: Zhiyi Zhang <zzhang at codeweavers.com>
> ---
>  dlls/user32/cursoricon.c       |  80 +++++++++++----------
>  dlls/user32/tests/cursoricon.c | 160
> ++++++++++++++++++++++++++++++++++++-----
>  2 files changed, 187 insertions(+), 53 deletions(-)
> 
> 

There's a lot going on in this patch and the vague commit message doesn't
help.  I'd suggest a patch that fixes CreateIconIndirect() first and
a second patch to fix CreateIcon(), then write more description commit
messages.

> diff --git a/dlls/user32/cursoricon.c b/dlls/user32/cursoricon.c
> index 8e272f09ce..69c7a937ff 100644
> --- a/dlls/user32/cursoricon.c
> +++ b/dlls/user32/cursoricon.c
> @@ -92,6 +92,9 @@ struct animated_cursoricon_object
>      HICON                    frames[1];  /* list of animated cursor frames */
>  };
>  
> +static void stretch_blt_icon(HDC hdc_dst, int dst_x, int dst_y, int dst_width, int dst_height,
> +                             HBITMAP src, int width, int height);
> +
>  static HBITMAP create_color_bitmap( int width, int height )
>  {
>      HDC hdc = get_display_dc();
> @@ -1561,20 +1564,38 @@ HICON WINAPI CreateIcon(
>  {
>      ICONINFO iinfo;
>      HICON hIcon;
> +    HBITMAP hbmMask_upperhalf;
> +    HBITMAP hbmMask_lowerhalf;
> +    HDC hdc;
>  
>      TRACE_(icon)("%dx%d, planes %d, bpp %d, xor %p, and %p\n",
>                   nWidth, nHeight, bPlanes, bBitsPixel, lpXORbits, lpANDbits);
>  
>      iinfo.fIcon = TRUE;
> -    iinfo.xHotspot = nWidth / 2;
> -    iinfo.yHotspot = nHeight / 2;

So this leaves x/yHotspot uninitialized...

> diff --git a/dlls/user32/tests/cursoricon.c b/dlls/user32/tests/cursoricon.c
> index 5099c08d70..e5faa0050e 100644
> --- a/dlls/user32/tests/cursoricon.c
> +++ b/dlls/user32/tests/cursoricon.c
> @@ -803,23 +803,27 @@ static void test_CreateIcon(void)
>      void *bits;
>      UINT display_bpp;
>      int i;
> +    BOOL is_color;
>  
>      hdc = GetDC(0);
>      display_bpp = GetDeviceCaps(hdc, BITSPIXEL);
> +    is_color = display_bpp > 1;
>  

Did you really try this on a 1 bpp display?

Huw.



More information about the wine-devel mailing list