You can use SDL_ConvertSurfaceFormat() now
Also, icon is guaranteed not to be NULL going into this function.
This commit is contained in:
parent
5b710cfee4
commit
8457ab1e62
1 changed files with 37 additions and 43 deletions
|
@ -286,12 +286,9 @@ WIN_SetWindowIcon(_THIS, SDL_Window * window, SDL_Surface * icon)
|
|||
{
|
||||
HWND hwnd = ((SDL_WindowData *) window->driverdata)->hwnd;
|
||||
HICON hicon = NULL;
|
||||
|
||||
if (icon) {
|
||||
BYTE *icon_bmp;
|
||||
int icon_len;
|
||||
SDL_RWops *dst;
|
||||
SDL_PixelFormat format;
|
||||
SDL_Surface *surface;
|
||||
|
||||
/* Create temporary bitmap buffer */
|
||||
|
@ -317,8 +314,7 @@ WIN_SetWindowIcon(_THIS, SDL_Window * window, SDL_Surface * icon)
|
|||
SDL_WriteLE32(dst, 0);
|
||||
|
||||
/* Convert the icon to a 32-bit surface with alpha channel */
|
||||
SDL_InitFormat(&format, SDL_PIXELFORMAT_ARGB8888);
|
||||
surface = SDL_ConvertSurface(icon, &format, 0);
|
||||
surface = SDL_ConvertSurfaceFormat(icon, SDL_PIXELFORMAT_ARGB8888, 0);
|
||||
if (surface) {
|
||||
/* Write the pixels upside down into the bitmap buffer */
|
||||
int y = surface->h;
|
||||
|
@ -330,13 +326,11 @@ WIN_SetWindowIcon(_THIS, SDL_Window * window, SDL_Surface * icon)
|
|||
|
||||
/* TODO: create the icon in WinCE (CreateIconFromResource isn't available) */
|
||||
#ifndef _WIN32_WCE
|
||||
hicon =
|
||||
CreateIconFromResource(icon_bmp, icon_len, TRUE, 0x00030000);
|
||||
hicon = CreateIconFromResource(icon_bmp, icon_len, TRUE, 0x00030000);
|
||||
#endif
|
||||
}
|
||||
SDL_RWclose(dst);
|
||||
SDL_stack_free(icon_bmp);
|
||||
}
|
||||
|
||||
/* Set the icon for the window */
|
||||
SendMessage(hwnd, WM_SETICON, ICON_SMALL, (LPARAM) hicon);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue