http://slackware.bholcomb.com/slackware/slackware-11.0/source/xap/xscreensaver/xscree...
[xscreensaver] / utils / logo.c
1 /* xscreensaver, Copyright (c) 2001-2006 Jamie Zawinski <jwz@jwz.org>
2  *
3  * Permission to use, copy, modify, distribute, and sell this software and its
4  * documentation for any purpose is hereby granted without fee, provided that
5  * the above copyright notice appear in all copies and that both that
6  * copyright notice and this permission notice appear in supporting
7  * documentation.  No representations are made about the suitability of this
8  * software for any purpose.  It is provided "as is" without express or 
9  * implied warranty.
10  */
11
12 /* XScreenSaver Logo designed by Angela Goodman <rzr_grl@yahoo.com>
13  */
14
15 /* If you are looking in here because you're trying to figure out how to
16    change the logo that xscreensaver displays on the splash screen and
17    password dialog, please don't.  The logo is xscreensaver's identity.
18    You wouldn't alter the name or copyright notice on a program that
19    you didn't write; please don't alter its logo either.
20  */
21
22 #include "utils.h"
23 #include "resources.h"
24 #include "visual.h"
25 #include "minixpm.h"
26
27 #include <stdio.h>
28
29 #include "images/logo-50.xpm"
30 #include "images/logo-180.xpm"
31
32 /* Returns a pixmap of the xscreensaver logo.
33  */
34 Pixmap
35 xscreensaver_logo (Screen *screen, Visual *visual,
36                    Drawable drawable, Colormap cmap,
37                    unsigned long background_color,
38                    unsigned long **pixels_ret, int *npixels_ret,
39                    Pixmap *mask_ret,
40                    Bool big_p)
41 {
42   Display *dpy = DisplayOfScreen (screen);
43   int depth = visual_depth (screen, visual);
44   int iw, ih;
45   XImage *image;
46   Pixmap p = 0;
47   unsigned char *mask = 0;
48
49   image = minixpm_to_ximage (dpy, visual, cmap, depth, background_color,
50                              (big_p ? logo_180_xpm : logo_50_xpm),
51                              &iw, &ih, pixels_ret, npixels_ret,
52                              (mask_ret ? &mask : 0));
53
54   if (image)
55     {
56       XGCValues gcv;
57       GC gc;
58       p = XCreatePixmap (dpy, drawable, iw, ih, depth);
59       gc = XCreateGC (dpy, p, 0, &gcv);
60       XPutImage (dpy, p, gc, image, 0, 0, 0, 0, iw, ih);
61       free (image->data);
62       image->data = 0;
63       XDestroyImage (image);
64       XFreeGC (dpy, gc);
65
66       if (mask_ret && mask)
67         {
68           *mask_ret = (Pixmap)
69             XCreatePixmapFromBitmapData (dpy, drawable, (char *) mask,
70                                          iw, ih, 1L, 0L, 1);
71           free (mask);
72         }
73     }
74   return p;
75 }