Setting the program icon with a mask

Greetings!

I know how to set a program icon with SDL_WM_SetIcon(), but what I don’t
know, is the mask thing. So, in what format should the mask be in etc.?
I tried with an Uint8 array [32*32], filling it with zeros and ones, but
it didn’t work.

Thanks in advance!
Bye,–
Mika Halttunen
@Mika_Halttunen

In Bug Squish (in fact, most of my games), I create a 100% opaque mask
for the square-shaped icon I used:

int masklen;
Uint8 * mask;
SDL_Surface * icon;

/* Load icon from PNG: */

icon = IMG_Load(“icon.png”);

/* Create mask: */

masklen = (((icon -> w) + 7) / 8) * (icon -> h);
mask = malloc(masklen * sizeof(Uint8));
memset(mask, 0xFF, masklen);

/* Set icon: */

SDL_WM_SetIcon(icon, mask);

/* Free icon surface & mask: */

free(mask);
SDL_FreeSurface(icon);

Some error checking would be good in there, too :wink:

I don’t think I’ve ever tried making an icon with any transparency, though.

Good luck!

-bill!On Tue, Sep 23, 2003 at 12:06:41PM +0300, Mika Halttunen wrote:

Greetings!

I know how to set a program icon with SDL_WM_SetIcon(), but what I don’t
know, is the mask thing. So, in what format should the mask be in etc.?
I tried with an Uint8 array [32*32], filling it with zeros and ones, but
it didn’t work.


bill at newbreedsoftware.com Got kids? Get Tux Paint!
http://newbreedsoftware.com/bill/ http://newbreedsoftware.com/tuxpaint/

By the way, if you pass in NULL for the mask, SDL will use a 100% opaque
mask itself, and will look for colorkey or alpha information in the surface
you pass to create a mask itself.

See ya!
-Sam Lantinga, Software Engineer, Blizzard Entertainment> On Tue, Sep 23, 2003 at 12:06:41PM +0300, Mika Halttunen wrote:

Greetings!

I know how to set a program icon with SDL_WM_SetIcon(), but what I don’t
know, is the mask thing. So, in what format should the mask be in etc.?
I tried with an Uint8 array [32*32], filling it with zeros and ones, but
it didn’t work.

In Bug Squish (in fact, most of my games), I create a 100% opaque mask
for the square-shaped icon I used:

I know how to set a program icon with SDL_WM_SetIcon(), but what I don’t
know, is the mask thing. So, in what format should the mask be in etc.?
I tried with an Uint8 array [32*32], filling it with zeros and ones, but
it didn’t work.

In Bug Squish (in fact, most of my games), I create a 100% opaque mask
for the square-shaped icon I used:

By the way, if you pass in NULL for the mask, SDL will use a 100% opaque
mask itself, and will look for colorkey or alpha information in the surface
you pass to create a mask itself.

Thanks guys! It works now. I should have figured out that colorkey stuff
myself, though :)–
Mika Halttunen
@Mika_Halttunen