[Commits] SDL: Fixed bug 4043 - SDL_windowswindow.c incorrect icon height

libsdl.org revision control commits-owner at libsdl.org
Mon Jan 15 10:34:54 PST 2018


details:   https://hg.libsdl.org/SDL/rev/44536468cdd2
changeset: 11825:44536468cdd2
user:      Sam Lantinga <slouken at libsdl.org>
date:      Mon Jan 15 10:29:53 2018 -0800
description:
Fixed bug 4043 - SDL_windowswindow.c incorrect icon height

Needed to allocate space for the mask in the ICONIMAGE structure

diffstat:

 src/video/windows/SDL_windowswindow.c |  10 +++++++---
 1 files changed, 7 insertions(+), 3 deletions(-)

diffs (29 lines):

diff -r 00fb5966c44f -r 44536468cdd2 src/video/windows/SDL_windowswindow.c
--- a/src/video/windows/SDL_windowswindow.c	Wed Jan 10 18:00:51 2018 -0800
+++ b/src/video/windows/SDL_windowswindow.c	Mon Jan 15 10:29:53 2018 -0800
@@ -438,11 +438,12 @@
     HWND hwnd = ((SDL_WindowData *) window->driverdata)->hwnd;
     HICON hicon = NULL;
     BYTE *icon_bmp;
-    int icon_len, y;
+    int icon_len, mask_len, y;
     SDL_RWops *dst;
 
-    /* Create temporary bitmap buffer */
-    icon_len = 40 + icon->h * icon->w * sizeof(Uint32);
+    /* Create temporary buffer for ICONIMAGE structure */
+    mask_len = (icon->h * (icon->w + 7)/8);
+    icon_len = 40 + icon->h * icon->w * sizeof(Uint32) + mask_len;
     icon_bmp = SDL_stack_alloc(BYTE, icon_len);
     dst = SDL_RWFromMem(icon_bmp, icon_len);
     if (!dst) {
@@ -471,6 +472,9 @@
         SDL_RWwrite(dst, src, icon->w * sizeof(Uint32), 1);
     }
 
+    /* Write the mask */
+    SDL_memset(icon_bmp + icon_len - mask_len, 0xFF, mask_len);
+
     hicon = CreateIconFromResource(icon_bmp, icon_len, TRUE, 0x00030000);
 
     SDL_RWclose(dst);


More information about the commits mailing list