Skip to content

Commit

Permalink
Use icon width * sizeof(Uint32) instead of icon pitch when copying to…
Browse files Browse the repository at this point in the history
… icon resource data
  • Loading branch information
slouken committed Jan 18, 2017
1 parent 5718293 commit 95defd6
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions src/video/windows/SDL_windowswindow.c
Expand Up @@ -409,7 +409,7 @@ WIN_SetWindowIcon(_THIS, SDL_Window * window, SDL_Surface * icon)
SDL_RWops *dst;

/* Create temporary bitmap buffer */
icon_len = 40 + icon->h * icon->w * 4;
icon_len = 40 + icon->h * icon->w * sizeof(Uint32);
icon_bmp = SDL_stack_alloc(BYTE, icon_len);
dst = SDL_RWFromMem(icon_bmp, icon_len);
if (!dst) {
Expand All @@ -424,7 +424,7 @@ WIN_SetWindowIcon(_THIS, SDL_Window * window, SDL_Surface * icon)
SDL_WriteLE16(dst, 1);
SDL_WriteLE16(dst, 32);
SDL_WriteLE32(dst, BI_RGB);
SDL_WriteLE32(dst, icon->h * icon->w * 4);
SDL_WriteLE32(dst, icon->h * icon->w * sizeof(Uint32));
SDL_WriteLE32(dst, 0);
SDL_WriteLE32(dst, 0);
SDL_WriteLE32(dst, 0);
Expand All @@ -435,7 +435,7 @@ WIN_SetWindowIcon(_THIS, SDL_Window * window, SDL_Surface * icon)
y = icon->h;
while (y--) {
Uint8 *src = (Uint8 *) icon->pixels + y * icon->pitch;
SDL_RWwrite(dst, src, icon->pitch, 1);
SDL_RWwrite(dst, src, icon->w * sizeof(Uint32), 1);
}

hicon = CreateIconFromResource(icon_bmp, icon_len, TRUE, 0x00030000);
Expand Down

0 comments on commit 95defd6

Please sign in to comment.