Path: utzoo!mnetor!uunet!lll-winken!lll-lcc!ames!hao!gatech!udel!rochester!cornell!batcomputer!sun!naughton From: naughton@sun.soe.clarkson.edu (Patrick Naughton) Newsgroups: comp.windows.x Subject: Re: set background Message-ID: <471@sun.soe.clarkson.edu> Date: 1 Mar 88 04:01:02 GMT References: <2371@mandrill.CWRU.Edu> Organization: Clarkson University, Potsdam, NY Lines: 298 From article <2371@mandrill.CWRU.Edu>, by bammi@mandrill.CWRU.Edu (Jwahar R. Bammi): > > We `snarfed' up some interesting sounding files from > UCBVAX (~ftp/xbackgrounds/*). We unfortunately cannot > figure out what format these files are in. > xsetroot -bitmap does not bite. > Any suggestions? > -- > usenet: {decvax,cbosgd,sun}!mandrill!bammi jwahar r. bammi > csnet: bammi@mandrill.CWRU.edu > arpa: bammi@mandrill.CWRU.edu > compuServe: 71515,155 I found the same files lying around with some old X10R4 stuff. So I took some of the code from there and modified xsetroot to handle these files, which I am told are "standard Sun raster format". Below there are three files: 1. the context diffs for xsetroot.c 2. the context diffs for xsetroot.man 3. the new file mostly borrowed from the X10 program xback. Apply the patches and change the makefile to link raster.c in with xsetroot and you should be all set. If the images are not readily available send me e-mail and I will put them on zap.mit.edu. Also if someone has more images than I have, let's get them together in one tar.Z file. I have the following images... max-brandy steinheim m.monroe diplomacy aves.maxim yosemite stars godzilla daybreak astronaut twodollar rhine fullmoon cheesecake tiffany john-yoko far-side aves.pionus And those of you who were apalled by some of the images people contributed to my last program "xmac" need not to worry... These are all "clean". Have fun. -Patrick ___________________________________________ | | | Internet: naughton@sun.soe.clarkson.edu | | BITNET: naughton@CLUTX.BITNET | | uucp: {rpics, gould}!clutx!naughton | |___________________________________________| ---------------- start of xsetroot.c.diff --------- cut here ------------------ *** xsetroot.c Mon Feb 29 21:51:07 1988 --- xsetroot.c.orig Thu Feb 4 11:24:20 1988 *************** *** 11,19 **** * * Author: Mark Lillibridge, MIT Project Athena * 11-Jun-87 - * Additions: Patrick Naughton, Clarkson University - * 29-Feb-88 - * Added -sunraster to load old X10 'background' files. */ /* Include routines to handle parsing defaults */ --- 11,16 ---- *************** *** 23,34 **** usage() { ! outl("%s: usage: %s [-fg ] [-bg ] [-rv] [-help] [-def] [-name ] [-cursor ] [-solid ] [-gray] [-grey] [-bitmap ] [-sunraster ] [-mod ] [:]\n\nNOTE: Use only one of -solid, -gray, -grey, -bitmap, -sunraster, and -mod\n\n", program_name, program_name); exit(1); } extern Pixmap MakeModulaBitmap(); - extern Pixmap ReadSunRasterFile(); main(argc, argv) int argc; --- 20,30 ---- usage() { ! outl("%s: usage: %s [-fg ] [-bg ] [-rv] [-help] [-def] [-name ] [-cursor ] [-solid ] [-gray] [-grey] [-bitmap ] [-mod ] [:]\n\nNOTE: *** Use only one of -solid, -gray, -grey, -bitmap, and -mod ***\n\n", program_name, program_name); exit(1); } extern Pixmap MakeModulaBitmap(); main(argc, argv) int argc; *************** *** 43,49 **** char *solid_color = 0; int gray = 0; char *bitmap_file = 0; - char *sunraster_file = 0; int mod_x = -1; int mod_y = -1; register int i; --- 39,44 ---- *************** *** 93,104 **** excl++; continue; } - if (!strcmp("-sunraster", argv[i])) { - if (++i>=argc) usage(); - sunraster_file = argv[i]; - excl++; - continue; - } if (!strcmp("-mod", argv[i])) { if (++i>=argc) usage(); mod_x = atoi(argv[i]); --- 88,93 ---- *************** *** 148,159 **** SetBackgroundToBitmap(bitmap, ww, hh); } - /* Handle -sunraster option */ - if (sunraster_file) { - bitmap = ReadSunRasterFile(dpy, screen, sunraster_file, &ww, &hh); - SetBackgroundToBitmap(bitmap, ww, hh); - } - /* Handle set background to a modula pattern */ if (mod_x != -1) SetBackgroundToBitmap(MakeModulaBitmap(mod_x, mod_y), 16, 16); --- 137,142 ---- *************** *** 317,336 **** return(c); } - - - Pixmap ReadSunRasterFile(dpy, screen, fname, w, h) - Display *dpy; - int screen; - char *fname; - int *w, *h; - { - unsigned short *imagep; - - if (read_raster(fname, w, h, &imagep)) - Fatal_Error("Sun Raster file: %s not found.", fname); - return( - XCreateBitmapFromData(dpy, RootWindow(dpy, screen), imagep, *w, *h) - ); - } - --- 300,302 ---- ---------------- end of xsetroot.c.diff --------- cut here ------------------ ---------------- start of xsetroot.man.diff ----- cut here ------------------ *** xsetroot.man Mon Feb 29 20:24:00 1988 --- xsetroot.man.orig Mon Feb 29 22:46:40 1988 *************** *** 11,19 **** [-bitmap .I filename ] - [-sunraster - .I filename - ] [-mod .I x y ] --- 11,16 ---- *************** *** 54,61 **** .IR -solid , .IR -gray , .IR -grey , ! .IR -bitmap , ! .IR -sunraster and .IR -mod ) may be specified at a time. --- 51,57 ---- .IR -solid , .IR -gray , .IR -grey , ! .IR -bitmap and .IR -mod ) may be specified at a time. *************** *** 80,87 **** .I bitmap(1) program. The entire background will be made up of repeated "tiles" of the bitmap. - .IP "-sunraster filename" - These bitmaps are Sun's standard rasterfile format. .IP "-mod x y" This is used if you want a plaid-like grid pattern on your screen. x and y are integers ranging from 1 to 16. Try the different combinations. --- 76,81 ---- ---------------- end of xsetroot.man.diff ------- cut here ------------------ ---------------- start of raster.c -------------- cut here ------------------ /* * RASTER.C * * Copyright (c) 1987 John Coker * john@renoir.Berkeley.EDU * University of California, Berkeley * * Changed to be used by xsetroot under X11 by Patrick Naughton * (naughton@sun.soe.clarson.edu) * see comment below for only change. * */ #include #include #include #define swap(s) ((((s) >> 8) & 0xFF) | (((s) << 8) & 0xFF00)) #define RMAGIC 0555 struct header { short magic; short width; short height; short xxx; }; read_raster(filename, widthp, heightp, datap) char *filename; int *widthp, *heightp; unsigned short **datap; { extern char *malloc(); extern int errno; struct header header; int fd, line, size; register unsigned short *sp, *end; int doswap = 0; *datap = NULL; if (filename == NULL || *filename == '\0') { filename = "(stdin)"; fd = fileno(stdin); } else if ((fd = open(filename, O_RDONLY, 0)) < 0) { /* can't open input file */ return (-1); } if (read(fd, &header, sizeof (header)) != sizeof (header)) { errno = EINVAL; return (-1); } if (swap(header.magic) == RMAGIC) { header.magic = swap(header.magic); header.width = swap(header.width); header.height = swap(header.height); doswap = 1; } if (header.magic != RMAGIC) { errno = EINVAL; return (-1); } if (header.width <= 0 || header.height <= 0) { errno = EINVAL; return (-1); } line = (header.width + 15) / 16; size = header.height * line * 2; if ((*datap = (unsigned short *)malloc(size)) == NULL) return (-1); if (read(fd, *datap, size) != size) { free(*datap); *datap = NULL; errno = EINVAL; return (-1); } if (fd != fileno(stdin)) close(fd); /* CHANGED: Sort of a hack here.... I had NOT do this because the images were being swapped when they weren't supposed to be... (PJN) if (doswap) { end = *datap + (size / 2); for (sp = *datap; sp < end; sp++) *sp = swap(*sp); } */ *widthp = header.width; *heightp = header.height; return (0); } ---------------- end of raster.c ---------------- cut here ------------------ [the end... you got it all.]