bammi@mandrill.CWRU.Edu (Jwahar R. Bammi) (02/27/88)
We `snarfed' up some interesting sounding files from UCBVAX (~ftp/xbackgrounds/*). We unfortunately cannot figure out what format these files are in. xsetroot -bitmap <file> 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
jef@LBL-RTSG.ARPA (Jef Poskanzer) (02/29/88)
In the referenced message, bammi@mandrill.UUCP (Jwahar R. Bammi) wrote: }We `snarfed' up some interesting sounding files from }UCBVAX (~ftp/xbackgrounds/*). We unfortunately cannot }figure out what format these files are in. } xsetroot -bitmap <file> does not bite. }Any suggestions? I took a look at these files. They are not in any bitmap format I'm familiar with. However, their format is remarkably similar to the "compact" format from my portable bitmap toolkit. I guess someone has hacked their X bitmap reading routine to accept this format in addition to the standard format. Unfortunately, that person is not speaking up. Anyway, after a little poking around with od, I was able to write a filter to convert them into my portable bitmap format. If you already have the pbm package, the appended program will let you use these bitmaps. If you don't have pbm, get it! I've already posted instructions on how to do so. By the way, the latest version of pbm on zap.mit.edu has cut and paste programs added. Using pbmcut, bitmap, and pbmpaste, I was able to add a tiny Starship Enterprise to the fullmoon bitmap... --- Jef Jef Poskanzer jef@lbl-rtsg.arpa ...well!pokey When you don't know what you are doing, do it neatly. - - - - - - - - - - /* xxxtopbm.c - read an xxx bitmap and write a portable bitmap ** ** Copyright (C) 1988 by Jef Poskanzer. ** ** Permission to use, copy, modify, and distribute this software and its ** documentation for any purpose and without fee is hereby granted, provided ** that the above copyright notice appear in all copies and that both that ** copyright notice and this permission notice appear in supporting ** documentation. This software is provided "as is" without express or ** implied warranty. */ #include <stdio.h> #include "pbm.h" main( argc, argv ) int argc; char *argv[]; { FILE *ifd; bit **bits, getbit(); int rows, cols, row, col, subcol; if ( argc > 2 ) { fprintf( stderr, "usage: %s [xxxfile]\n", argv[0] ); exit( 1 ); } if ( argc == 2 ) { ifd = fopen( argv[1], "r" ); if ( ifd == NULL ) { fprintf( stderr, "%s: can't open.\n", argv[1] ); exit( 1 ); } } else ifd = stdin; getinit( ifd, &cols, &rows ); bits = pbm_allocarray( cols, rows ); for ( row = 0; row < rows; row++ ) for ( col = 0; col < cols; col += 8 ) for ( subcol = col + 7; subcol >= col; subcol-- ) bits[row][subcol] = getbit( ifd ); if ( ifd != stdin ) fclose( ifd ); pbm_writepbm( stdout, bits, cols, rows ); exit( 0 ); } int item, bitsperitem, bitshift; getinit( file, colp, rowp ) FILE *file; int *colp, *rowp; { if ( getc( file ) != 109 ) { fprintf( stderr, "Bad magic number 1.\n" ); exit( 1 ); } if ( getc( file ) != 1 ) { fprintf( stderr, "Bad magic number 2.\n" ); exit( 1 ); } *colp = getc( file ); *colp += getc( file ) << 8; *rowp = getc( file ); *rowp += getc( file ) << 8; bitsperitem = 8; if ( getc( file ) != 0 ) { fprintf( stderr, "Bad magic number 3.\n" ); exit( 1 ); } if ( getc( file ) != 46 ) { fprintf( stderr, "Bad magic number 4.\n" ); exit( 1 ); } } bit getbit( file ) FILE *file; { bit b; if ( bitsperitem == 8 ) { item = getc( file ); bitsperitem = 0; bitshift = 7; } bitsperitem++; b = ( item >> bitshift) & 1; bitshift--; return ( b ); }
deboor@nutmeg.Berkeley.EDU.berkeley.edu (Adam R de Boor) (03/01/88)
Those bitmap files are in sun's standard rasterfile format. a
Jef Poskanzer <jef@lbl-rtsg.arpa> (03/01/88)
In the referenced message, deboor@nutmeg.Berkeley.EDU (Adam R de Boor) wrote:
}Those bitmap files are in sun's standard rasterfile format.
No, they are not:
% screenload aves.maxim
screenload: Error reading rasterfile header
%
% od -b aves.maxim | head
0000000 155 001 200 004 204 003 000 056 377 377 377 377 377 377 377 377
0000020 377 377 377 377 377 377 377 377 377 377 377 377 377 377 377 377
0000040 211 210 044 222 104 021 211 044 111 042 105 222 044 112 222 044
0000060 051 111 051 051 051 051 222 224 244 044 111 111 111 222 112 112
0000100 111 051 251 112 252 224 052 251 122 052 051 045 245 044 111 111
0000120 222 244 044 211 044 051 111 222 104 242 110 222 050 222 044 044
0000140 012 111 022 111 104 022 022 022 021 021 021 022 042 042 042 102
0000160 020 101 010 101 020 202 020 101 020 102 020 010 041 020 004 101
0000200 010 204 020 041 104 204 100 004 041 004 102 204 020 021 042 104
0000220 010 102 204 010 102 104 020 041 110 044 222 220 210 220 210 110
%
% od -b dump | head
0000000 131 246 152 225 000 000 004 200 000 000 003 204 000 000 000 001
0000020 000 001 372 100 000 000 000 001 000 000 000 000 000 000 000 000
0000040 377 377 377 377 377 377 377 377 377 377 377 377 377 377 377 377
0000060 377 377 377 377 377 377 377 377 221 021 044 111 042 210 221 044
0000100 222 104 242 111 044 122 111 044 224 222 224 224 224 224 111 051
0000120 045 044 222 222 222 111 122 122 222 224 225 122 125 051 124 225
0000140 112 124 224 244 245 044 222 222 111 045 044 221 044 224 222 111
0000160 042 105 022 111 024 111 044 044 120 222 110 222 042 110 110 110
0000200 210 210 210 110 104 104 104 102 010 202 020 202 010 101 010 202
0000220 010 102 010 020 204 010 040 202 020 041 010 204 042 041 002 040
Still waiting to hear from whoever is responsible for these bitmaps.
---
Jef
Jef Poskanzer jef@lbl-rtsg.arpa ...well!pokey
Use only as directed.
naughton@sun.soe.clarkson.edu (Patrick Naughton) (03/01/88)
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 <file> 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 <color>] [-bg <color>] [-rv] [-help] [-def] [-name <string>] [-cursor <cursor file> <mask file>] [-solid <color>] [-gray] [-grey] [-bitmap <filename>] [-sunraster <filename>] [-mod <x> <y>] [<host>:<display>]\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 <color>] [-bg <color>] [-rv] [-help] [-def] [-name <string>] [-cursor <cursor file> <mask file>] [-solid <color>] [-gray] [-grey] [-bitmap <filename>] [-mod <x> <y>] [<host>:<display>]\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 <stdio.h> #include <errno.h> #include <sys/file.h> #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.]