Path: utzoo!mnetor!uunet!lll-winken!lll-lcc!ames!pasteur!ucbvax!LBL-RTSG.ARPA!jef From: jef@LBL-RTSG.ARPA (Jef Poskanzer) Newsgroups: comp.windows.x Subject: Re: set background Message-ID: <880228210948.665@bl-rtsg> Date: 29 Feb 88 05:09:48 GMT References: <2371@mandrill.CWRU.Edu> Sender: daemon@ucbvax.BERKELEY.EDU Organization: Paratheo-Anametamystikhood Of Eris Esoteric, Ada Lovelace Cabal Lines: 138 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 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 #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 ); }