Use icon width * sizeof(Uint32) instead of icon pitch when copying to icon resource data
authorSam Lantinga <slouken@libsdl.org>
Tue, 17 Jan 2017 21:18:31 -0800
changeset 10816c8d44526965e
parent 10815 71bbe3233508
child 10817 efc103e60c5b
Use icon width * sizeof(Uint32) instead of icon pitch when copying to icon resource data
src/video/windows/SDL_windowswindow.c
     1.1 --- a/src/video/windows/SDL_windowswindow.c	Mon Jan 16 00:58:28 2017 -0500
     1.2 +++ b/src/video/windows/SDL_windowswindow.c	Tue Jan 17 21:18:31 2017 -0800
     1.3 @@ -409,7 +409,7 @@
     1.4      SDL_RWops *dst;
     1.5  
     1.6      /* Create temporary bitmap buffer */
     1.7 -    icon_len = 40 + icon->h * icon->w * 4;
     1.8 +    icon_len = 40 + icon->h * icon->w * sizeof(Uint32);
     1.9      icon_bmp = SDL_stack_alloc(BYTE, icon_len);
    1.10      dst = SDL_RWFromMem(icon_bmp, icon_len);
    1.11      if (!dst) {
    1.12 @@ -424,7 +424,7 @@
    1.13      SDL_WriteLE16(dst, 1);
    1.14      SDL_WriteLE16(dst, 32);
    1.15      SDL_WriteLE32(dst, BI_RGB);
    1.16 -    SDL_WriteLE32(dst, icon->h * icon->w * 4);
    1.17 +    SDL_WriteLE32(dst, icon->h * icon->w * sizeof(Uint32));
    1.18      SDL_WriteLE32(dst, 0);
    1.19      SDL_WriteLE32(dst, 0);
    1.20      SDL_WriteLE32(dst, 0);
    1.21 @@ -435,7 +435,7 @@
    1.22      y = icon->h;
    1.23      while (y--) {
    1.24          Uint8 *src = (Uint8 *) icon->pixels + y * icon->pitch;
    1.25 -        SDL_RWwrite(dst, src, icon->pitch, 1);
    1.26 +        SDL_RWwrite(dst, src, icon->w * sizeof(Uint32), 1);
    1.27      }
    1.28  
    1.29      hicon = CreateIconFromResource(icon_bmp, icon_len, TRUE, 0x00030000);