SDL_WM_SetIcon will derive ‘mask’ using the color key if SDL_SRCCOLORKEY is
set on the source surface and mask is NULL. I need to do conversion
on my source (making sure it’s 32x32), which leaves me with an alpha
channel surface, not a color keyed one, and SDL_WM_SetIcon doesn’t
support SDL_SRCALPHA.
The attached patch makes it set the mask based on the source alpha
channel if SDL_SRCALPHA is set; zero alpha values are transparent,
nonzero values are opaque.–
Glenn Maynard
-------------- next part --------------
— /home/glenn/SDL12/src/video/SDL_video.c 2002-10-05 12:50:56.000000000 -0400
+++ SDL_video.c 2002-11-17 01:41:52.000000000 -0500
@@ -125,6 +125,14 @@
SDL_VideoDevice *current_video = NULL;
+/* SM: Default refresh rate of 0 uses the default. */
+int refresh_rate = 0;
+
+void SDL_SM_SetRefreshRate(unsigned rate)
+{
- refresh_rate = rate;
+}
/* Various local functions */
int SDL_VideoInit(const char *driver_name, Uint32 flags);
void SDL_VideoQuit(void);
@@ -1640,8 +1648,9 @@
}
}
-/* Utility function used by SDL_WM_SetIcon() */
-static void CreateMaskFromColorKey(SDL_Surface *icon, Uint8 mask)
+/ Utility function used by SDL_WM_SetIcon();
-
- flags & 1 for color key, flags & 2 for alpha channel. */
+static void CreateMaskFromColorKeyOrAlpha(SDL_Surface *icon, Uint8 *mask, int flags)
{
int x, y;
Uint32 colorkey;
@@ -1667,9 +1676,12 @@
pixels = (Uint16 )icon->pixels +
yicon->pitch/2;
for ( x=0; xw; ++x ) {
- flags & 1 for color key, flags & 2 for alpha channel. */
-
if ( *pixels++ == colorkey ) {
-
if ( (flags & 1) && *pixels == colorkey ) {
-
SET_MASKBIT(icon, x, y, mask);
-
} else if((flags & 2) && (*pixels & icon->format->Amask) == 0) { SET_MASKBIT(icon, x, y, mask); }
-
pixels++; } } }
@@ -1680,9 +1692,12 @@
pixels = (Uint32 )icon->pixels +
yicon->pitch/4;
for ( x=0; xw; ++x ) {
-
if ( *pixels++ == colorkey ) {
-
if ( (flags & 1) && *pixels == colorkey ) {
-
SET_MASKBIT(icon, x, y, mask);
-
} else if((flags & 2) && (*pixels & icon->format->Amask) == 0) { SET_MASKBIT(icon, x, y, mask); }
-
pixels++; } } }
@@ -1702,13 +1717,16 @@
/* Generate a mask if necessary, and create the icon! /
if ( mask == NULL ) {
int mask_len = icon->h(icon->w+7)/8;
-
int flags = 0; mask = (Uint8 *)malloc(mask_len); if ( mask == NULL ) { return; } memset(mask, ~0, mask_len);
-
if ( icon->flags & SDL_SRCCOLORKEY ) {
-
CreateMaskFromColorKey(icon, mask);
-
if ( icon->flags & SDL_SRCCOLORKEY ) flags |= 1;
-
if ( icon->flags & SDL_SRCALPHA ) flags |= 2;
-
if( flags ) {
-
CreateMaskFromColorKeyOrAlpha(icon, mask, flags); } video->SetIcon(video, icon, mask); free(mask);