X-Git-Url: http://git.hungrycats.org/cgi-bin/gitweb.cgi?a=blobdiff_plain;f=utils%2Flogo.c;h=b0d7205186a36a0afec2d803cdeccdc5b3887b41;hb=96a411663168b0ba5432b407a83be55f3df0c802;hp=21cc4d401cd7bfaacbf0b164779697fbc867b4e4;hpb=cccbddbc4140cf9a06d7d95cc5c0ca36eb5d6e28;p=xscreensaver diff --git a/utils/logo.c b/utils/logo.c index 21cc4d40..b0d72051 100644 --- a/utils/logo.c +++ b/utils/logo.c @@ -1,4 +1,4 @@ -/* xscreensaver, Copyright (c) 2001-2002 Jamie Zawinski +/* xscreensaver, Copyright (c) 2001-2002, 2003 Jamie Zawinski * * Permission to use, copy, modify, distribute, and sell this software and its * documentation for any purpose is hereby granted without fee, provided that @@ -29,6 +29,7 @@ #include "utils.h" #include "resources.h" +#include "visual.h" #include #include @@ -48,7 +49,7 @@ static const char hex[128] = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, static XImage * parse_xpm_data (Display *dpy, Visual *visual, Colormap colormap, int depth, unsigned long transparent_color, - unsigned const char * const * data, + const char * const * data, int *width_ret, int *height_ret, unsigned long **pixels_ret, int *npixels_ret, unsigned char **mask_ret) @@ -89,7 +90,7 @@ parse_xpm_data (Display *dpy, Visual *visual, Colormap colormap, int depth, for (i = 0; i < ncolors; i++) { - const unsigned char *line = *data; + const char *line = *data; cmap[i].byte = *line++; while (*line) { @@ -174,10 +175,11 @@ parse_xpm_data (Display *dpy, Visual *visual, Colormap colormap, int depth, ximage->data = (char *) calloc (ximage->height, ximage->bytes_per_line); for (y = 0; y < h; y++) { - const unsigned char *line = *data++; + const char *line = *data++; for (x = 0; x < w; x++) { - int p = rmap[*line++]; + int p = rmap[(int) *line]; + line++; XPutPixel (ximage, x, y, (p == 255 ? transparent_color : pixels[p])); @@ -196,26 +198,24 @@ parse_xpm_data (Display *dpy, Visual *visual, Colormap colormap, int depth, -/* Draws the logo centered in the given Drawable (presumably a Pixmap.) - next_frame_p means randomize the flame shape. +/* Returns a pixmap of the xscreensaver logo. */ Pixmap -xscreensaver_logo (Display *dpy, Window window, Colormap cmap, +xscreensaver_logo (Screen *screen, Visual *visual, + Drawable drawable, Colormap cmap, unsigned long background_color, unsigned long **pixels_ret, int *npixels_ret, Pixmap *mask_ret, Bool big_p) { + Display *dpy = DisplayOfScreen (screen); + int depth = visual_depth (screen, visual); int iw, ih; XImage *image; Pixmap p = 0; - XWindowAttributes xgwa; unsigned char *mask = 0; - XGetWindowAttributes (dpy, window, &xgwa); - - image = parse_xpm_data (dpy, xgwa.visual, xgwa.colormap, xgwa.depth, - background_color, + image = parse_xpm_data (dpy, visual, cmap, depth, background_color, (big_p ? logo_180_xpm : logo_50_xpm), &iw, &ih, pixels_ret, npixels_ret, (mask_ret ? &mask : 0)); @@ -224,7 +224,7 @@ xscreensaver_logo (Display *dpy, Window window, Colormap cmap, { XGCValues gcv; GC gc; - p = XCreatePixmap (dpy, window, iw, ih, xgwa.depth); + p = XCreatePixmap (dpy, drawable, iw, ih, depth); gc = XCreateGC (dpy, p, 0, &gcv); XPutImage (dpy, p, gc, image, 0, 0, 0, 0, iw, ih); free (image->data); @@ -235,7 +235,7 @@ xscreensaver_logo (Display *dpy, Window window, Colormap cmap, if (mask_ret && mask) { *mask_ret = (Pixmap) - XCreatePixmapFromBitmapData (dpy, window, (char *) mask, + XCreatePixmapFromBitmapData (dpy, drawable, (char *) mask, iw, ih, 1L, 0L, 1); free (mask); }