1.1 --- a/src/video/SDL_video.c Sat Nov 09 06:20:46 2002 +0000
1.2 +++ b/src/video/SDL_video.c Sun Nov 17 17:55:45 2002 +0000
1.3 @@ -1640,8 +1640,9 @@
1.4 }
1.5 }
1.6
1.7 -/* Utility function used by SDL_WM_SetIcon() */
1.8 -static void CreateMaskFromColorKey(SDL_Surface *icon, Uint8 *mask)
1.9 +/* Utility function used by SDL_WM_SetIcon();
1.10 + * flags & 1 for color key, flags & 2 for alpha channel. */
1.11 +static void CreateMaskFromColorKeyOrAlpha(SDL_Surface *icon, Uint8 *mask, int flags)
1.12 {
1.13 int x, y;
1.14 Uint32 colorkey;
1.15 @@ -1667,9 +1668,12 @@
1.16 pixels = (Uint16 *)icon->pixels +
1.17 y*icon->pitch/2;
1.18 for ( x=0; x<icon->w; ++x ) {
1.19 - if ( *pixels++ == colorkey ) {
1.20 + if ( (flags & 1) && *pixels == colorkey ) {
1.21 + SET_MASKBIT(icon, x, y, mask);
1.22 + } else if((flags & 2) && (*pixels & icon->format->Amask) == 0) {
1.23 SET_MASKBIT(icon, x, y, mask);
1.24 }
1.25 + pixels++;
1.26 }
1.27 }
1.28 }
1.29 @@ -1680,9 +1684,12 @@
1.30 pixels = (Uint32 *)icon->pixels +
1.31 y*icon->pitch/4;
1.32 for ( x=0; x<icon->w; ++x ) {
1.33 - if ( *pixels++ == colorkey ) {
1.34 + if ( (flags & 1) && *pixels == colorkey ) {
1.35 + SET_MASKBIT(icon, x, y, mask);
1.36 + } else if((flags & 2) && (*pixels & icon->format->Amask) == 0) {
1.37 SET_MASKBIT(icon, x, y, mask);
1.38 }
1.39 + pixels++;
1.40 }
1.41 }
1.42 }
1.43 @@ -1702,13 +1709,16 @@
1.44 /* Generate a mask if necessary, and create the icon! */
1.45 if ( mask == NULL ) {
1.46 int mask_len = icon->h*(icon->w+7)/8;
1.47 + int flags = 0;
1.48 mask = (Uint8 *)malloc(mask_len);
1.49 if ( mask == NULL ) {
1.50 return;
1.51 }
1.52 memset(mask, ~0, mask_len);
1.53 - if ( icon->flags & SDL_SRCCOLORKEY ) {
1.54 - CreateMaskFromColorKey(icon, mask);
1.55 + if ( icon->flags & SDL_SRCCOLORKEY ) flags |= 1;
1.56 + if ( icon->flags & SDL_SRCALPHA ) flags |= 2;
1.57 + if( flags ) {
1.58 + CreateMaskFromColorKeyOrAlpha(icon, mask, flags);
1.59 }
1.60 video->SetIcon(video, icon, mask);
1.61 free(mask);