SDL_WM_SetIcon

Name

SDL_WM_SetIcon -- Sets the icon for the display window.

Synopsis

#include "SDL.h"

void SDL_WM_SetIcon(SDL_Surface *icon, Uint8 *mask);

Description

Sets the icon for the display window. Win32 icons must be 32x32.

This function must be called before the first call to SDL_SetVideoMode. Note that this means SDL_Image cannot be used.

The mask is a bitmask that describes the shape of the icon. If mask is NULL, the shape is determined by the colorkey or alpha channel of the icon, if any. If neither of those are present, the icon is made opaque (no transparency).

If mask is non-NULL, it points to a bitmap with bits set where the corresponding pixel should be visible. The format of the bitmap is as follows: Scanlines come in the usual top-down order. Each scanline consists of (width / 8) bytes, rounded up. The most significant bit of each byte represents the leftmost pixel. Example

SDL_WM_SetIcon(SDL_LoadBMP("icon.bmp"), NULL);

Comments

Easier option for beginners

by snipes

Another option, if your icon image does not have a colorkey set, is to use the SDL_SetColorKey to set the transparency.

Example:

Uint32          colorkey;
SDL_Surface     *image;

image = SDL_LoadBMP("icon.bmp");

colorkey = SDL_MapRGB(image->format, 255, 0, 255);

SDL_SetColorKey(image, SDL_SRCCOLORKEY, colorkey);              

SDL_WM_SetIcon(image,NULL);

See Also

SDL_SetVideoMode, SDL_WM_SetCaption

SDL_WM_SetIcon (last edited 2009-08-04 17:43:42 by NathanMichaels)