shithub: choc

Download patch

ref: fa497db8c7fd6af3803019a99dad13ba5dd5e0bd
parent: 47a4af665d94308cd200f4f3959692c1d3062c6e
author: Simon Howard <[email protected]>
date: Fri Apr 25 19:33:00 EDT 2008

Generate transparency mask for the application icon from black parts of
the image.

Subversion-branch: /trunk/chocolate-doom
Subversion-revision: 1128

--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -178,7 +178,7 @@
 
 if HAVE_PYTHON
 
-icon.c : ../data/doom.png
+icon.c : ../data/doom.ico
 	../data/convert-icon $^ $@
 
 endif
--- a/src/i_video.c
+++ b/src/i_video.c
@@ -849,7 +849,24 @@
 void I_SetWindowIcon(void)
 {
     SDL_Surface *surface;
+    Uint8 *mask;
+    int i;
 
+    // Generate the mask
+  
+    mask = malloc(icon_w * icon_h / 8);
+    memset(mask, 0, icon_w * icon_h / 8);
+
+    for (i=0; i<icon_w * icon_h; ++i) 
+    {
+        if (icon_data[i * 3] != 0x00
+         || icon_data[i * 3 + 1] != 0x00
+         || icon_data[i * 3 + 2] != 0x00)
+        {
+            mask[i / 8] |= 1 << (7 - i % 8);
+        }
+    }
+
     surface = SDL_CreateRGBSurfaceFrom(icon_data,
                                        icon_w,
                                        icon_h,
@@ -860,8 +877,9 @@
                                        0xff << 16,
                                        0);
 
-    SDL_WM_SetIcon(surface, NULL);
+    SDL_WM_SetIcon(surface, mask);
     SDL_FreeSurface(surface);
+    free(mask);
 }
 
 // Pick the modes list to use: