summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSimon Howard2008-04-25 23:33:00 +0000
committerSimon Howard2008-04-25 23:33:00 +0000
commitfa497db8c7fd6af3803019a99dad13ba5dd5e0bd (patch)
treef3807b36e53b5b5550bf19d9488f8cae16ea4b8c
parent47a4af665d94308cd200f4f3959692c1d3062c6e (diff)
downloadchocolate-doom-fa497db8c7fd6af3803019a99dad13ba5dd5e0bd.tar.gz
chocolate-doom-fa497db8c7fd6af3803019a99dad13ba5dd5e0bd.tar.bz2
chocolate-doom-fa497db8c7fd6af3803019a99dad13ba5dd5e0bd.zip
Generate transparency mask for the application icon from black parts of
the image. Subversion-branch: /trunk/chocolate-doom Subversion-revision: 1128
-rw-r--r--src/Makefile.am2
-rw-r--r--src/i_video.c20
2 files changed, 20 insertions, 2 deletions
diff --git a/src/Makefile.am b/src/Makefile.am
index 8c69a161..f4565395 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -178,7 +178,7 @@ EXTRA_DIST = \
if HAVE_PYTHON
-icon.c : ../data/doom.png
+icon.c : ../data/doom.ico
../data/convert-icon $^ $@
endif
diff --git a/src/i_video.c b/src/i_video.c
index 66b9ccaf..7222d1b0 100644
--- a/src/i_video.c
+++ b/src/i_video.c
@@ -849,6 +849,23 @@ void I_SetWindowCaption(void)
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,
@@ -860,8 +877,9 @@ void I_SetWindowIcon(void)
0xff << 16,
0);
- SDL_WM_SetIcon(surface, NULL);
+ SDL_WM_SetIcon(surface, mask);
SDL_FreeSurface(surface);
+ free(mask);
}
// Pick the modes list to use: