allbery@uunet.UU.NET (Brandon S. Allbery - comp.sources.misc) (11/27/89)
Posting-number: Volume 9, Issue 20 Submitted-by: jef@helios.ee.lbl.gov (Jef Poskanzer) Archive-name: pbmplus/part04 #! /bin/sh # This is a shell archive, meaning: # 1. Remove everything above the #! /bin/sh line. # 2. Save the resulting text in a file. # 3. Execute the file with /bin/sh (not csh) to create the files: # pbm/pbmmake.c # pbm/pbmmake.1 # pbm/pbmtolj.c # pbm/pbmtolj.1 # pbm/pbmtomacp.c # pbm/pbmtomacp.1 # pbm/pbmtoxwd.c # pbm/g3.h # pbm/pbmtog3.c # pbm/pbmtog3.1 # pbm/pbmtoxwd.1 # pbm/brushtopbm.c # pbm/brushtopbm.1 # pbm/mgrtopbm.c # pbm/mgrtopbm.1 # This archive created: Wed Nov 22 21:13:35 1989 # By: Jef Poskanzer (Paratheo-Anametamystikhood Of Eris Esoteric, Ada Lovelace Cabal) export PATH; PATH=/bin:$PATH if test ! -d 'pbm' then echo shar: creating directory "'pbm'" mkdir 'pbm' fi echo shar: extracting "'pbm/pbmmake.c'" '(2177 characters)' if test -f 'pbm/pbmmake.c' then echo shar: will not over-write existing file "'pbm/pbmmake.c'" else sed 's/^X//' << \SHAR_EOF > 'pbm/pbmmake.c' X/* pbmmake.c - create a blank bitmap of a specified size X** X** Copyright (C) 1988 by Jef Poskanzer. X** X** Permission to use, copy, modify, and distribute this software and its X** documentation for any purpose and without fee is hereby granted, provided X** that the above copyright notice appear in all copies and that both that X** copyright notice and this permission notice appear in supporting X** documentation. This software is provided "as is" without express or X** implied warranty. X*/ X X#include <stdio.h> X#include "pbm.h" X#ifdef SYSV X#include <string.h> X#else /*SYSV*/ X#include <strings.h> X#endif /*SYSV*/ X X#define max(a,b) ((a) > (b) ? (a) : (b)) X Xmain( argc, argv ) Xint argc; Xchar *argv[]; X { X register bit color, gray, rowcolor, *bitrow, *bP; X int argn, rows, cols, row, col; X char *usage = "[-white|-black|-gray] <width> <height>"; X X pm_progname = argv[0]; X X argn = 1; X color = 0; X gray = 0; X X /* Check for flags. */ X if ( argn < argc && argv[argn][0] == '-' ) X { X if ( strncmp(argv[argn],"-white",max(strlen(argv[argn]),2)) == 0 ) X color = PBM_WHITE; X else if ( strncmp(argv[argn],"-black",max(strlen(argv[argn]),2)) == 0 ) X color = PBM_BLACK; X else if ( strncmp(argv[argn],"-gray",max(strlen(argv[argn]),2)) == 0 || X strncmp(argv[argn],"-grey",max(strlen(argv[argn]),2)) == 0 ) X gray = 1; X else X pm_usage( usage ); X argn++; X } X X if ( argn == argc ) X pm_usage( usage ); X if ( sscanf( argv[argn], "%d", &cols ) != 1 ) X pm_usage( usage ); X argn++; X if ( argn == argc ) X pm_usage( usage ); X if ( sscanf( argv[argn], "%d", &rows ) != 1 ) X pm_usage( usage ); X argn++; X X if ( argn != argc ) X pm_usage( usage ); X X pbm_writepbminit( stdout, cols, rows ); X bitrow = pbm_allocrow( cols ); X X if ( gray ) X rowcolor = PBM_WHITE; /* arbitrarily make the corner white */ X for ( row = 0; row < rows; row++ ) X { X if ( gray ) X { X color = rowcolor; X rowcolor = 1 - rowcolor; X } X for ( col = 0, bP = bitrow; col < cols; col++, bP++ ) X { X *bP = color; X if ( gray ) X color = 1 - color; X } X pbm_writepbmrow( stdout, bitrow, cols ); X } X X exit( 0 ); X } SHAR_EOF if test 2177 -ne "`wc -c < 'pbm/pbmmake.c'`" then echo shar: error transmitting "'pbm/pbmmake.c'" '(should have been 2177 characters)' fi fi # end of overwriting check if test ! -d 'pbm' then echo shar: creating directory "'pbm'" mkdir 'pbm' fi echo shar: extracting "'pbm/pbmmake.1'" '(912 characters)' if test -f 'pbm/pbmmake.1' then echo shar: will not over-write existing file "'pbm/pbmmake.1'" else sed 's/^X//' << \SHAR_EOF > 'pbm/pbmmake.1' X.TH pbmmake 1 "22 February 1989" X.SH NAME Xpbmmake - create a blank bitmap of a specified size X.SH SYNOPSIS Xpbmmake [-white|-black|-gray] <width> <height> X.SH DESCRIPTION XProduces a portable bitmap of the specified width and height. XThe color defaults to white. X.PP XIn addition to the usual -white and -black, this program implements -gray. XThis gives a simple 50% gray pattern with 1's and 0's alternating. X.PP XAll flags can be abbreviated to their shortest unique prefix. X.SH "SEE ALSO" Xpbm(5) X.SH AUTHOR XCopyright (C) 1989 by Jef Poskanzer. X XPermission to use, copy, modify, and distribute this software and its Xdocumentation for any purpose and without fee is hereby granted, provided Xthat the above copyright notice appear in all copies and that both that Xcopyright notice and this permission notice appear in supporting Xdocumentation. This software is provided "as is" without express or Ximplied warranty. SHAR_EOF if test 912 -ne "`wc -c < 'pbm/pbmmake.1'`" then echo shar: error transmitting "'pbm/pbmmake.1'" '(should have been 912 characters)' fi fi # end of overwriting check if test ! -d 'pbm' then echo shar: creating directory "'pbm'" mkdir 'pbm' fi echo shar: extracting "'pbm/pbmtolj.c'" '(3189 characters)' if test -f 'pbm/pbmtolj.c' then echo shar: will not over-write existing file "'pbm/pbmtolj.c'" else sed 's/^X//' << \SHAR_EOF > 'pbm/pbmtolj.c' X/* pbmtolj.c - read a portable bitmap and produce a LaserJet bitmap file X** X** based on pbmtops.c X** X** Michael Haberler HP Vienna mah@hpuviea.uucp X** mcvax!tuvie!mah X** misfeatures: X** no positioning X** X** Bug fix Dec 12, 1988 : X** lines in putbit() reshuffled X** now runs OK on HP-UX 6.0 with X10R4 and HP Laserjet II X** Bo Thide', Swedish Institute of Space Physics, Uppsala <bt@irfu.se> X** X** Copyright (C) 1988 by Jef Poskanzer and Michael Haberler. X** X** Permission to use, copy, modify, and distribute this software and its X** documentation for any purpose and without fee is hereby granted, provided X** that the above copyright notice appear in all copies and that both that X** copyright notice and this permission notice appear in supporting X** documentation. This software is provided "as is" without express or X** implied warranty. X*/ X X#include <stdio.h> X#include "pbm.h" X#ifdef SYSV X#include <string.h> X#else /*SYSV*/ X#include <strings.h> X#endif /*SYSV*/ X Xint dpi = 75; X Xmain( argc, argv ) Xint argc; Xchar *argv[]; X { X FILE *ifd; X register bit *bitrow, *bP; X int argn, rows, cols, format, rucols, padright, row, col; X char *usage = "[-r resolution] [pbmfile]\n\t\resolution = [75|100|150|300] (dpi)"; X X pm_progname = argv[0]; X X argn = 1; X X /* Check for flags. */ X if ( argc > argn ) X { X if ( argv[argn][0] == '-' ) X { X if ( strcmp( argv[argn], "-r" ) == 0 ) X { X if ( argc == argn + 1 ) X pm_usage( usage ); X if ( sscanf( argv[argn+1], "%d", &dpi ) != 1 ) X pm_usage( usage ); X argn += 2; X } X else X pm_usage( usage ); X } X } X X if ( argc > argn + 1 ) X pm_usage( usage ); X X if ( argc == argn + 1 ) X ifd = pm_openr( argv[argn] ); X else X ifd = stdin; X X pbm_readpbminit( ifd, &cols, &rows, &format ); X bitrow = pbm_allocrow( cols ); X X /* Round cols up to the nearest multiple of 8. */ X rucols = ( cols + 7 ) / 8; X rucols = rucols * 8; X padright = rucols - cols; X X putinit( ); X for ( row = 0; row < rows; row++ ) X { X pbm_readpbmrow( ifd, bitrow, cols, format ); X /* Transfer raster graphics */ X printf("\033*b%dW",rucols/8); X for ( col = 0, bP = bitrow; col < cols; col++, bP++ ) X putbit( *bP ); X for ( col = 0; col < padright; col++ ) X putbit( 0 ); X } X X pm_close( ifd ); X X putrest( ); X X exit( 0 ); X } X X Xint item, bitsperitem, bitshift, itemsperline, firstitem; X Xputinit( ) X { X /* Printer reset. */ X printf("\033E"); X X /* Set raster graphics resolution */ X printf("\033*t%dR",dpi); X X /* Start raster graphics, relative adressing */ X printf("\033*r1A"); X X itemsperline = 0; X bitsperitem = 1; X item = 0; X bitshift = 7; X firstitem = 1; X } X Xputbit( b ) Xbit b; X { X if ( b == PBM_BLACK ) X item += 1 << bitshift; X bitshift--; X if ( bitsperitem == 8 ) { X putitem( ); X bitshift = 7; X } X bitsperitem++; X } X Xputrest( ) X { X if ( bitsperitem > 1 ) X putitem( ); X X /* end raster graphics */ X printf( "\033*rB" ); X X /* Printer reset. */ X printf("\033E"); X } X Xputitem( ) X { X putchar( item ); X bitsperitem = 0; X item = 0; X } SHAR_EOF if test 3189 -ne "`wc -c < 'pbm/pbmtolj.c'`" then echo shar: error transmitting "'pbm/pbmtolj.c'" '(should have been 3189 characters)' fi fi # end of overwriting check if test ! -d 'pbm' then echo shar: creating directory "'pbm'" mkdir 'pbm' fi echo shar: extracting "'pbm/pbmtolj.1'" '(870 characters)' if test -f 'pbm/pbmtolj.1' then echo shar: will not over-write existing file "'pbm/pbmtolj.1'" else sed 's/^X//' << \SHAR_EOF > 'pbm/pbmtolj.1' X.TH pbmtolj 1 "29 August 1988" X.SH NAME Xpbmtolj - convert a portable bitmap into HP LaserJet format X.SH SYNOPSIS Xpbmtolj [ -r <resolution> ] [ <pbmfile> ] X.SH DESCRIPTION XReads a portable bitmap as input. XProduces HP LaserJet data as output. X.PP XThe -r flag specifies the resolution of the output device, in dpi. XTypical values are 75, 100, 150, 300. XThe default is 75. X.PP XNote that there is no ljtopbm tool. X.SH "SEE ALSO" Xpbm(5) X.SH AUTHOR XCopyright (C) 1988 by Jef Poskanzer and Michael Haberler. X XPermission to use, copy, modify, and distribute this software and its Xdocumentation for any purpose and without fee is hereby granted, provided Xthat the above copyright notice appear in all copies and that both that Xcopyright notice and this permission notice appear in supporting Xdocumentation. This software is provided "as is" without express or Ximplied warranty. SHAR_EOF if test 870 -ne "`wc -c < 'pbm/pbmtolj.1'`" then echo shar: error transmitting "'pbm/pbmtolj.1'" '(should have been 870 characters)' fi fi # end of overwriting check if test ! -d 'pbm' then echo shar: creating directory "'pbm'" mkdir 'pbm' fi echo shar: extracting "'pbm/pbmtomacp.c'" '(5862 characters)' if test -f 'pbm/pbmtomacp.c' then echo shar: will not over-write existing file "'pbm/pbmtomacp.c'" else sed 's/^X//' << \SHAR_EOF > 'pbm/pbmtomacp.c' X/* pbmtomacp.c - read a portable bitmap and produce a MacPaint bitmap file X** X** Copyright (C) 1988 by Douwe vand der Schaaf. X** X** Permission to use, copy, modify, and distribute this software and its X** documentation for any purpose and without fee is hereby granted, provided X** that the above copyright notice appear in all copies and that both that X** copyright notice and this permission notice appear in supporting X** documentation. This software is provided "as is" without express or X** implied warranty. X*/ X X#include <stdio.h> X#include "pbm.h" X#include "macp.h" X X#define TRUE 1 X#define FALSE 0 X#define EQUAL 1 X#define UNEQUAL 0 X XFILE *fdout; Xchar *usage = "[-l left] [-r right] [-b bottom] [-t top] [pbmfile]"; X Xmain(argc, argv) Xint argc; Xchar *argv[]; X{ FILE *ifd; X register bit **bits, **bitsr; X int argn, rows, cols; X int left,bottom,right,top; X int lflg, rflg, tflg, bflg; X char name[100]; X X pm_progname = argv[0]; X X argn = 1; X fdout = stdout; X lflg = rflg = tflg = bflg = 0; X X while ( argn < argc && argv[argn][0] == '-' ) X { switch ( argv[argn][1] ) X { case 'l': X lflg++; X argn++; X left = atoi( argv[argn] ); X break; X X case 'r': X rflg++; X argn++; X right = atoi( argv[argn] ); X break; X X case 't': X tflg++; X argn++; X top = atoi( argv[argn] ); X break; X X case 'b': X bflg++; X argn++; X bottom = atoi( argv[argn] ); X break; X X case '?': X default: X pm_usage( usage ); X } X argn++; X } X X if ( argn == argc ) X { ifd = stdin; X strcpy( name, "noname" ); X } X else X { ifd = pm_openr( argv[argn] ); X strcpy( name, argv[argn] ); X } X X bitsr = pbm_readpbm( ifd, &cols, &rows ); X X pm_close( ifd ); X X bits = pbm_allocarray( MAX_COLS, MAX_LINES ); X X if( !lflg ) X left = 0; X X if( rflg ) X { if( right - left >= MAX_COLS ) X right = left + MAX_COLS - 1; X } X else X right = ( left + MAX_COLS > cols ) ? ( cols - 1 ) : ( left + MAX_COLS - 1 ); X X if( !tflg ) X top = 0; X X if( bflg ) X { if( bottom - top >= MAX_LINES ) X bottom = top + MAX_LINES - 1; X } X else X bottom = ( top + MAX_LINES > rows ) ? X ( rows - 1 ) : ( top + MAX_LINES - 1 ); X X if( right <= left || left < 0 || right - left + 1 > MAX_COLS ) X pm_error("error in right (= %d) and/or left (=%d)",right,left, 0,0,0 ); X if( bottom <= top || top < 0 || bottom - top + 1 > MAX_LINES ) X pm_error("error in bottom (= %d) and/or top (=%d)",bottom,top, 0,0,0 ); X X fillbits( bits, bitsr, top, left, bottom, right ); X X writemacp( bits ); X X} /* main */ X X/* - - - - - - - - - - - - - - - - - - - - - - - - - - */ X X/* centreer het over te zenden plaatje in het MacPaint document X * X * Het plaatje wordt vanaf al of niet opgegeven (left, bottom) X * in een pbm bitmap van de juist macpaint afmetingen gezet, X * en eventueel afgekapt. X */ Xfillbits( bits, bitsr, top, left, bottom, right ) Xbit **bits, **bitsr; Xint top, left, bottom, right; X{ register bit *bi, *bir; X register int i, j; X register int bottomr, leftr, topr, rightr; X int width, height; X X width = right - left + 1; X leftr = (MAX_COLS - width) / 2; X rightr = leftr + width - 1; X X height = bottom - top + 1; X topr = ( MAX_LINES - height ) / 2; X bottomr = topr + height - 1; X X for( i = 0; i < topr; i++ ) X { bi = bits[i]; X for( j = 0; j < MAX_COLS; j++ ) X *bi++ = 0; X } X X for( i = topr; i <= bottomr; i++ ) X { bi = bits[i]; X { for( j = 0; j < leftr; j++ ) X *bi++ = 0; X bir = bitsr[ i - topr + top ]; X for( j = leftr; j <= rightr; j++ ) X *bi++ = bir[j - leftr + left]; X for( j = rightr + 1; j < MAX_COLS; j++ ) X *bi++ = 0; X } } X X for( i = bottomr + 1; i < MAX_LINES; i++ ) X { bi = bits[i]; X for( j = 0; j < MAX_COLS; j++ ) X *bi++ = 0; X } X} /* fillbits */ X X/* - - - - - - - - - - - - - - - - - - - - - - - - - - */ X Xwritemacp( bits ) Xbit **bits; X{ register int i; X bit pb[MAX_COLS * 2]; X int npb; X X header(); X for( i=0; i < MAX_LINES; i++ ) X { npb = packit( pb, bits[i] ); X sendbytes( pb, npb ); X } X} /* writemacp */ X X/* - - - - - - - - - - - - - - - - - - - - - - - - - - */ X X/* pack regel van MacPaint doc in Apple's format X * return value = # of bytes in pb X */ Xint Xpackit( pb, bits ) Xbit *pb, *bits; X{ register int charcount, npb, newcount, flg; X bit temp[72]; X bit *count, *srcb, *destb, save; X X srcb = bits; destb = temp; X filltemp( destb, srcb ); X srcb = temp; X destb = pb; X npb = 0; X charcount = BYTES_WIDE; X flg = EQUAL; X while( charcount ) X { save = *srcb++; X charcount--; X newcount = 1; X while( (*srcb == save) && charcount ) X { srcb++; X newcount++; X charcount--; X } X if( newcount > 2 ) X { count = destb++; X *count = 257 - newcount; X *destb++ = save; X npb += 2; X flg = EQUAL; X } X else X { if( flg == EQUAL ) X { count = destb++; X *count = newcount - 1; X npb++; X } X else X *count += newcount; X while( newcount-- ) X { *destb++ = save; X npb++; X } X flg = UNEQUAL; X } } X return npb; X} /* packit */ X X/* - - - - - - - - - - - - - - - - - - - - - - - - - - */ X Xfilltemp( dest, src ) Xbit *src, *dest; X{ register unsigned char ch, zero, acht; X register int i, j; X X zero = '\0'; X acht = 8; X i = BYTES_WIDE; X while( i-- ) X { ch = zero; X j = acht; X while( j-- ) X { ch <<= 1; X if( *src++ ) X ch++; X } X *dest++ = ch; X } X} /* filltemp */ X X/* - - - - - - - - - - - - - - - - - - - - - - - - - - */ X Xsendbytes( pb, npb ) Xbit *pb; Xregister int npb; X{ register bit *b; X X b = pb; X while( npb-- ) X putc( *b++, fdout ); X} /* sendbytes */ X X/* - - - - - - - - - - - - - - - - - - - - - - - - - - */ X Xheader() X{ register int i; X register char ch; X X /* header contains nothing ... */ X ch = '\0'; X for(i = 0; i < HEADER_LENGTH; i++ ) X putc( ch, fdout ); X} /* header */ SHAR_EOF if test 5862 -ne "`wc -c < 'pbm/pbmtomacp.c'`" then echo shar: error transmitting "'pbm/pbmtomacp.c'" '(should have been 5862 characters)' fi fi # end of overwriting check if test ! -d 'pbm' then echo shar: creating directory "'pbm'" mkdir 'pbm' fi echo shar: extracting "'pbm/pbmtomacp.1'" '(1100 characters)' if test -f 'pbm/pbmtomacp.1' then echo shar: will not over-write existing file "'pbm/pbmtomacp.1'" else sed 's/^X//' << \SHAR_EOF > 'pbm/pbmtomacp.1' X.TH pbmtomacp 1 "31 August 1988" X.SH NAME Xpbmtomacp - convert a portable bitmap into a MacPaint file X.SH SYNOPSIS Xpbmtomacp [-l left] [-r right] [-b bottom] [-t top] [pbmfile] X.SH DESCRIPTION XReads a portable bitmap as input. XIf no input-file is given, standard input is assumed. XProduces a MacPaint file as output. X.PP XLeft, right,bottom & top let you define a square into the pbm file, Xthat must be converted. XDefault is the whole file. XIf the file is too large for a MacPaint-file, the bitmap is cut to fit Xfrom ( left, top ). X.SH BUGS XThe source code contains comments in a language other than English. X.SH "SEE ALSO" Xmacptopbm(1), pbm(5) X.SH AUTHOR XCopyright (C) 1988 by Douwe van der Schaaf. XUSENET: ..!mcvax!uvapsy!vdschaaf X XPermission to use, copy, modify, and distribute this software and its Xdocumentation for any purpose and without fee is hereby granted, provided Xthat the above copyright notice appear in all copies and that both that Xcopyright notice and this permission notice appear in supporting Xdocumentation. This software is provided "as is" without express or Ximplied warranty. SHAR_EOF if test 1100 -ne "`wc -c < 'pbm/pbmtomacp.1'`" then echo shar: error transmitting "'pbm/pbmtomacp.1'" '(should have been 1100 characters)' fi fi # end of overwriting check if test ! -d 'pbm' then echo shar: creating directory "'pbm'" mkdir 'pbm' fi echo shar: extracting "'pbm/pbmtoxwd.c'" '(3517 characters)' if test -f 'pbm/pbmtoxwd.c' then echo shar: will not over-write existing file "'pbm/pbmtoxwd.c'" else sed 's/^X//' << \SHAR_EOF > 'pbm/pbmtoxwd.c' X/* pbmtoxwd.c - read a portable bitmap and produce an X11 window dump X** X** Copyright (C) 1988 by Jef Poskanzer. X** X** Permission to use, copy, modify, and distribute this software and its X** documentation for any purpose and without fee is hereby granted, provided X** that the above copyright notice appear in all copies and that both that X** copyright notice and this permission notice appear in supporting X** documentation. This software is provided "as is" without express or X** implied warranty. X*/ X X#include <stdio.h> X#include "pbm.h" X#include "x11wd.h" X#ifdef SYSV X#include <string.h> X#define index strchr X#else /*SYSV*/ X#include <strings.h> X#endif /*SYSV*/ X Xmain( argc, argv ) Xint argc; Xchar *argv[]; X { X FILE *ifd; X register bit *bitrow, *bP; X int rows, cols, format, padright, row, col; X char name[100], *cp; X X pm_progname = argv[0]; X X if ( argc > 2 ) X pm_usage( "[pbmfile]" ); X X if ( argc == 2 ) X { X ifd = pm_openr( argv[1] ); X strcpy( name, argv[1] ); X if ( strcmp( name, "-" ) == 0 ) X strcpy( name, "noname" ); X X if ( ( cp = index( name, '.' ) ) != 0 ) X *cp = '\0'; X } X else X { X ifd = stdin; X strcpy( name, "noname" ); X } X X pbm_readpbminit( ifd, &cols, &rows, &format ); X bitrow = pbm_allocrow( cols ); X X /* Compute padding to round cols up to the nearest multiple of 32. */ X padright = ( ( cols + 31 ) / 32 ) * 32 - cols; X X putinit( cols, rows, name ); X for ( row = 0; row < rows; row++ ) X { X pbm_readpbmrow( ifd, bitrow, cols, format ); X for ( col = 0, bP = bitrow; col < cols; col++, bP++ ) X putbit( *bP ); X for ( col = 0; col < padright; col++ ) X putbit( 0 ); X } X X if ( ifd != stdin ) X fclose( ifd ); X X putrest( ); X X exit( 0 ); X } X X Xlong item; Xint bitsperitem, bitshift; X X Xputinit( cols, rows, name ) Xint cols, rows; Xchar *name; X { X X11WDFileHeader h11; X X11XColor color; X X h11.header_size = sizeof(h11) + (strlen(name) + 1) * sizeof(char); X h11.file_version = X11WD_FILE_VERSION; X h11.pixmap_format = ZPixmap; X h11.pixmap_depth = 1; X h11.pixmap_width = cols; X h11.pixmap_height = rows; X h11.xoffset = 0; X h11.byte_order = MSBFirst; X h11.bitmap_unit = 32; X h11.bitmap_bit_order = MSBFirst; X h11.bitmap_pad = 32; X h11.bits_per_pixel = 1; X h11.bytes_per_line = ( ( cols + 31 ) / 32 ) * 4; X h11.visual_class = StaticGray; X h11.red_mask = 0; X h11.green_mask = 0; X h11.blue_mask = 0; X h11.bits_per_rgb = 1; X h11.colormap_entries = 2; X h11.ncolors = 2; X h11.window_width = cols; X h11.window_height = rows; X h11.window_x = 0; /* arbitrary */ X h11.window_y = 0; /* arbitrary */ X h11.window_bdrwidth = 0; X fwrite( &h11, sizeof(h11), 1, stdout ); X X fwrite( name, sizeof(char), strlen(name) + 1, stdout ); X X color.pixel = 0; X color.red = 65535; X color.green = 65535; X color.blue = 65535; X color.flags = 7; X color.pad = 0; X fwrite( &color, sizeof(color), 1, stdout ); X color.pixel = 1; X color.red = 0; X color.green = 0; X color.blue = 0; X fwrite( &color, sizeof(color), 1, stdout ); X X item = 0; X bitsperitem = 0; X bitshift = 31; X } X Xputbit( b ) Xbit b; X { X if ( bitsperitem == 32 ) X putitem( ); X bitsperitem++; X if ( b == PBM_BLACK ) X item += 1 << bitshift; X bitshift--; X } X Xputrest( ) X { X if ( bitsperitem > 0 ) X putitem( ); X } X Xputitem( ) X { X fwrite( &item, sizeof(item), 1, stdout ); X item = 0; X bitsperitem = 0; X bitshift = 31; X } SHAR_EOF if test 3517 -ne "`wc -c < 'pbm/pbmtoxwd.c'`" then echo shar: error transmitting "'pbm/pbmtoxwd.c'" '(should have been 3517 characters)' fi fi # end of overwriting check if test ! -d 'pbm' then echo shar: creating directory "'pbm'" mkdir 'pbm' fi echo shar: extracting "'pbm/g3.h'" '(6520 characters)' if test -f 'pbm/g3.h' then echo shar: will not over-write existing file "'pbm/g3.h'" else sed 's/^X//' << \SHAR_EOF > 'pbm/g3.h' X/* g3.h - header file for group 3 FAX compression filters X*/ X X#ifndef _G3_H_ X#define _G3_H_ X Xtypedef struct tableentry { X int tabid; X int code; X int length; X int count; X } tableentry; X X#define TWTABLE 23 X#define MWTABLE 24 X#define TBTABLE 25 X#define MBTABLE 26 X#define EXTABLE 27 X#define VRTABLE 28 X Xstruct tableentry twtable[] = { X { TWTABLE, 0x35, 8, 0 }, X { TWTABLE, 0x7, 6, 1 }, X { TWTABLE, 0x7, 4, 2 }, X { TWTABLE, 0x8, 4, 3 }, X { TWTABLE, 0xb, 4, 4 }, X { TWTABLE, 0xc, 4, 5 }, X { TWTABLE, 0xe, 4, 6 }, X { TWTABLE, 0xf, 4, 7 }, X { TWTABLE, 0x13, 5, 8 }, X { TWTABLE, 0x14, 5, 9 }, X { TWTABLE, 0x7, 5, 10 }, X { TWTABLE, 0x8, 5, 11 }, X { TWTABLE, 0x8, 6, 12 }, X { TWTABLE, 0x3, 6, 13 }, X { TWTABLE, 0x34, 6, 14 }, X { TWTABLE, 0x35, 6, 15 }, X { TWTABLE, 0x2a, 6, 16 }, X { TWTABLE, 0x2b, 6, 17 }, X { TWTABLE, 0x27, 7, 18 }, X { TWTABLE, 0xc, 7, 19 }, X { TWTABLE, 0x8, 7, 20 }, X { TWTABLE, 0x17, 7, 21 }, X { TWTABLE, 0x3, 7, 22 }, X { TWTABLE, 0x4, 7, 23 }, X { TWTABLE, 0x28, 7, 24 }, X { TWTABLE, 0x2b, 7, 25 }, X { TWTABLE, 0x13, 7, 26 }, X { TWTABLE, 0x24, 7, 27 }, X { TWTABLE, 0x18, 7, 28 }, X { TWTABLE, 0x2, 8, 29 }, X { TWTABLE, 0x3, 8, 30 }, X { TWTABLE, 0x1a, 8, 31 }, X { TWTABLE, 0x1b, 8, 32 }, X { TWTABLE, 0x12, 8, 33 }, X { TWTABLE, 0x13, 8, 34 }, X { TWTABLE, 0x14, 8, 35 }, X { TWTABLE, 0x15, 8, 36 }, X { TWTABLE, 0x16, 8, 37 }, X { TWTABLE, 0x17, 8, 38 }, X { TWTABLE, 0x28, 8, 39 }, X { TWTABLE, 0x29, 8, 40 }, X { TWTABLE, 0x2a, 8, 41 }, X { TWTABLE, 0x2b, 8, 42 }, X { TWTABLE, 0x2c, 8, 43 }, X { TWTABLE, 0x2d, 8, 44 }, X { TWTABLE, 0x4, 8, 45 }, X { TWTABLE, 0x5, 8, 46 }, X { TWTABLE, 0xa, 8, 47 }, X { TWTABLE, 0xb, 8, 48 }, X { TWTABLE, 0x52, 8, 49 }, X { TWTABLE, 0x53, 8, 50 }, X { TWTABLE, 0x54, 8, 51 }, X { TWTABLE, 0x55, 8, 52 }, X { TWTABLE, 0x24, 8, 53 }, X { TWTABLE, 0x25, 8, 54 }, X { TWTABLE, 0x58, 8, 55 }, X { TWTABLE, 0x59, 8, 56 }, X { TWTABLE, 0x5a, 8, 57 }, X { TWTABLE, 0x5b, 8, 58 }, X { TWTABLE, 0x4a, 8, 59 }, X { TWTABLE, 0x4b, 8, 60 }, X { TWTABLE, 0x32, 8, 61 }, X { TWTABLE, 0x33, 8, 62 }, X { TWTABLE, 0x34, 8, 63 }, X }; X Xstruct tableentry mwtable[] = { X { MWTABLE, 0x1b, 5, 64 }, X { MWTABLE, 0x12, 5, 128 }, X { MWTABLE, 0x17, 6, 192 }, X { MWTABLE, 0x37, 7, 256 }, X { MWTABLE, 0x36, 8, 320 }, X { MWTABLE, 0x37, 8, 384 }, X { MWTABLE, 0x64, 8, 448 }, X { MWTABLE, 0x65, 8, 512 }, X { MWTABLE, 0x68, 8, 576 }, X { MWTABLE, 0x67, 8, 640 }, X { MWTABLE, 0xcc, 9, 704 }, X { MWTABLE, 0xcd, 9, 768 }, X { MWTABLE, 0xd2, 9, 832 }, X { MWTABLE, 0xd3, 9, 896 }, X { MWTABLE, 0xd4, 9, 960 }, X { MWTABLE, 0xd5, 9, 1024 }, X { MWTABLE, 0xd6, 9, 1088 }, X { MWTABLE, 0xd7, 9, 1152 }, X { MWTABLE, 0xd8, 9, 1216 }, X { MWTABLE, 0xd9, 9, 1280 }, X { MWTABLE, 0xda, 9, 1344 }, X { MWTABLE, 0xdb, 9, 1408 }, X { MWTABLE, 0x98, 9, 1472 }, X { MWTABLE, 0x99, 9, 1536 }, X { MWTABLE, 0x9a, 9, 1600 }, X { MWTABLE, 0x18, 6, 1664 }, X { MWTABLE, 0x9b, 9, 1728 }, X }; X Xstruct tableentry tbtable[] = { X { TBTABLE, 0x37, 10, 0 }, X { TBTABLE, 0x2, 3, 1 }, X { TBTABLE, 0x3, 2, 2 }, X { TBTABLE, 0x2, 2, 3 }, X { TBTABLE, 0x3, 3, 4 }, X { TBTABLE, 0x3, 4, 5 }, X { TBTABLE, 0x2, 4, 6 }, X { TBTABLE, 0x3, 5, 7 }, X { TBTABLE, 0x5, 6, 8 }, X { TBTABLE, 0x4, 6, 9 }, X { TBTABLE, 0x4, 7, 10 }, X { TBTABLE, 0x5, 7, 11 }, X { TBTABLE, 0x7, 7, 12 }, X { TBTABLE, 0x4, 8, 13 }, X { TBTABLE, 0x7, 8, 14 }, X { TBTABLE, 0x18, 9, 15 }, X { TBTABLE, 0x17, 10, 16 }, X { TBTABLE, 0x18, 10, 17 }, X { TBTABLE, 0x8, 10, 18 }, X { TBTABLE, 0x67, 11, 19 }, X { TBTABLE, 0x68, 11, 20 }, X { TBTABLE, 0x6c, 11, 21 }, X { TBTABLE, 0x37, 11, 22 }, X { TBTABLE, 0x28, 11, 23 }, X { TBTABLE, 0x17, 11, 24 }, X { TBTABLE, 0x18, 11, 25 }, X { TBTABLE, 0xca, 12, 26 }, X { TBTABLE, 0xcb, 12, 27 }, X { TBTABLE, 0xcc, 12, 28 }, X { TBTABLE, 0xcd, 12, 29 }, X { TBTABLE, 0x68, 12, 30 }, X { TBTABLE, 0x69, 12, 31 }, X { TBTABLE, 0x6a, 12, 32 }, X { TBTABLE, 0x6b, 12, 33 }, X { TBTABLE, 0xd2, 12, 34 }, X { TBTABLE, 0xd3, 12, 35 }, X { TBTABLE, 0xd4, 12, 36 }, X { TBTABLE, 0xd5, 12, 37 }, X { TBTABLE, 0xd6, 12, 38 }, X { TBTABLE, 0xd7, 12, 39 }, X { TBTABLE, 0x6c, 12, 40 }, X { TBTABLE, 0x6d, 12, 41 }, X { TBTABLE, 0xda, 12, 42 }, X { TBTABLE, 0xdb, 12, 43 }, X { TBTABLE, 0x54, 12, 44 }, X { TBTABLE, 0x55, 12, 45 }, X { TBTABLE, 0x56, 12, 46 }, X { TBTABLE, 0x57, 12, 47 }, X { TBTABLE, 0x64, 12, 48 }, X { TBTABLE, 0x65, 12, 49 }, X { TBTABLE, 0x52, 12, 50 }, X { TBTABLE, 0x53, 12, 51 }, X { TBTABLE, 0x24, 12, 52 }, X { TBTABLE, 0x37, 12, 53 }, X { TBTABLE, 0x38, 12, 54 }, X { TBTABLE, 0x27, 12, 55 }, X { TBTABLE, 0x28, 12, 56 }, X { TBTABLE, 0x58, 12, 57 }, X { TBTABLE, 0x59, 12, 58 }, X { TBTABLE, 0x2b, 12, 59 }, X { TBTABLE, 0x2c, 12, 60 }, X { TBTABLE, 0x5a, 12, 61 }, X { TBTABLE, 0x66, 12, 62 }, X { TBTABLE, 0x67, 12, 63 }, X }; X Xstruct tableentry mbtable[] = { X { MBTABLE, 0xf, 10, 64 }, X { MBTABLE, 0xc8, 12, 128 }, X { MBTABLE, 0xc9, 12, 192 }, X { MBTABLE, 0x5b, 12, 256 }, X { MBTABLE, 0x33, 12, 320 }, X { MBTABLE, 0x34, 12, 384 }, X { MBTABLE, 0x35, 12, 448 }, X { MBTABLE, 0x6c, 13, 512 }, X { MBTABLE, 0x6d, 13, 576 }, X { MBTABLE, 0x4a, 13, 640 }, X { MBTABLE, 0x4b, 13, 704 }, X { MBTABLE, 0x4c, 13, 768 }, X { MBTABLE, 0x4d, 13, 832 }, X { MBTABLE, 0x72, 13, 896 }, X { MBTABLE, 0x73, 13, 960 }, X { MBTABLE, 0x74, 13, 1024 }, X { MBTABLE, 0x75, 13, 1088 }, X { MBTABLE, 0x76, 13, 1152 }, X { MBTABLE, 0x77, 13, 1216 }, X { MBTABLE, 0x52, 13, 1280 }, X { MBTABLE, 0x53, 13, 1344 }, X { MBTABLE, 0x54, 13, 1408 }, X { MBTABLE, 0x55, 13, 1472 }, X { MBTABLE, 0x5a, 13, 1536 }, X { MBTABLE, 0x5b, 13, 1600 }, X { MBTABLE, 0x64, 13, 1664 }, X { MBTABLE, 0x65, 13, 1728 }, X }; X Xstruct tableentry extable[] = { X { EXTABLE, 0x8, 11, 1792 }, X { EXTABLE, 0xc, 11, 1856 }, X { EXTABLE, 0xd, 11, 1920 }, X { EXTABLE, 0x12, 12, 1984 }, X { EXTABLE, 0x13, 12, 2048 }, X { EXTABLE, 0x14, 12, 2112 }, X { EXTABLE, 0x15, 12, 2176 }, X { EXTABLE, 0x16, 12, 2240 }, X { EXTABLE, 0x17, 12, 2304 }, X { EXTABLE, 0x1c, 12, 2368 }, X { EXTABLE, 0x1d, 12, 2432 }, X { EXTABLE, 0x1e, 12, 2496 }, X { EXTABLE, 0x1f, 12, 2560 }, X }; X X#endif /*_G3_H_*/ SHAR_EOF if test 6520 -ne "`wc -c < 'pbm/g3.h'`" then echo shar: error transmitting "'pbm/g3.h'" '(should have been 6520 characters)' fi fi # end of overwriting check if test ! -d 'pbm' then echo shar: creating directory "'pbm'" mkdir 'pbm' fi echo shar: extracting "'pbm/pbmtog3.c'" '(3447 characters)' if test -f 'pbm/pbmtog3.c' then echo shar: will not over-write existing file "'pbm/pbmtog3.c'" else sed 's/^X//' << \SHAR_EOF > 'pbm/pbmtog3.c' X/* pbmtog3.c - read a portable bitmap and produce a Group 3 FAX file X** X** Copyright (C) 1989 by Paul Haeberli <paul@manray.sgi.com>. X** X** Permission to use, copy, modify, and distribute this software and its X** documentation for any purpose and without fee is hereby granted, provided X** that the above copyright notice appear in all copies and that both that X** copyright notice and this permission notice appear in supporting X** documentation. This software is provided "as is" without express or X** implied warranty. X*/ X X#include <stdio.h> X#include "pbm.h" X#include "g3.h" X#ifdef SYSV X#include <string.h> X#else /*SYSV*/ X#include <strings.h> X#endif /*SYSV*/ X X#define max(a,b) ((a) > (b) ? (a) : (b)) X Xint reversebits; X Xmain( argc, argv ) Xint argc; Xchar *argv[]; X { X FILE *ifd; X bit *bitrow; X int argn, rows, cols, format, row, col, i; X char *usage = " [-reversebits] [pbmfile]"; X X pm_progname = argv[0]; X X argn = 1; X reversebits = 0; X X if ( argn < argc && argv[argn][0] == '-' ) X { X if ( strncmp(argv[argn],"-reversebits",max(strlen(argv[argn]),2)) == 0 ) X reversebits = 1; X else X pm_usage( usage ); X argn++; X } X X if ( argn == argc ) X ifd = stdin; X else X { X ifd = pm_openr( argv[argn] ); X argn++; X } X X if ( argn != argc ) X pm_usage( usage ); X X pbm_readpbminit( ifd, &cols, &rows, &format ); X bitrow = pbm_allocrow( cols ); X X /* Write out four extra rows to get things stabilized. */ X for ( col = 0; col < cols; col++ ) X bitrow[col] = PBM_WHITE; X tofax( bitrow, cols ); X tofax( bitrow, cols ); X tofax( bitrow, cols ); X tofax( bitrow, cols ); X X /* Write out bitmap. */ X putinit(); X for ( row = 0; row < rows; row++ ) X { X pbm_readpbmrow( ifd, bitrow, cols, format ); X tofax( bitrow, cols ); X } X X /* And finish off. */ X for( i = 0; i < 6; i++ ) X puteol( ); X flushbits( ); X X pm_close( ifd ); X X exit( 0 ); X } X Xtofax(bitrow,n) Xbit *bitrow; Xint n; X{ X int c = 0; X X while(n>0) { X c = 0; X while(*bitrow == PBM_WHITE && n>0) { X bitrow++; X c++; X n--; X } X putwhitespan(c); X c = 0; X if(n==0) X break; X while(*bitrow == PBM_BLACK && n>0) { X bitrow++; X c++; X n--; X } X putblackspan(c); X } X puteol(); X} X Xputwhitespan(c) Xint c; X{ X int tpos; X tableentry *te; X X if(c>=64) { X tpos = (c/64)-1; X te = mwtable+tpos; X c -= te->count; X putcode(te); X } X tpos = c; X te = twtable+tpos; X putcode(te); X} X Xputblackspan(c) Xint c; X{ X int tpos; X tableentry *te; X X if(c>=64) { X tpos = (c/64)-1; X te = mbtable+tpos; X c -= te->count; X putcode(te); X } X tpos = c; X te = tbtable+tpos; X putcode(te); X} X Xputcode(te) Xtableentry *te; X{ X unsigned int mask; X int code; X X mask = 1<<(te->length-1); X code = te->code; X while(mask) { X if(code&mask) X putbit(1); X else X putbit(0); X mask >>= 1; X } X X} X Xputeol() X{ X int i; X X for(i=0; i<11; i++) X putbit(0); X putbit(1); X} X Xint shdata; Xint shbit = 0x80; X Xputinit() X{ X shdata = 0; X shbit = reversebits ? 0x01 : 0x80; X} X Xint putbit(d) Xint d; X{ X if(d) X shdata = shdata|shbit; X if ( reversebits ) X shbit = shbit<<1; X else X shbit = shbit>>1; X if((shbit&0xff) == 0) { X putchar(shdata); X shdata = 0; X shbit = reversebits ? 0x01 : 0x80; X } X} X Xflushbits( ) X{ X if ( ( reversebits && shbit != 0x01 ) || X ( ! reversebits && shbit != 0x80 ) ) { X putchar(shdata); X shdata = 0; X shbit = reversebits ? 0x01 : 0x80; X } X} SHAR_EOF if test 3447 -ne "`wc -c < 'pbm/pbmtog3.c'`" then echo shar: error transmitting "'pbm/pbmtog3.c'" '(should have been 3447 characters)' fi fi # end of overwriting check if test ! -d 'pbm' then echo shar: creating directory "'pbm'" mkdir 'pbm' fi echo shar: extracting "'pbm/pbmtog3.1'" '(778 characters)' if test -f 'pbm/pbmtog3.1' then echo shar: will not over-write existing file "'pbm/pbmtog3.1'" else sed 's/^X//' << \SHAR_EOF > 'pbm/pbmtog3.1' X.TH pbmtog3 1 "02 October 1989" X.SH NAME Xg3topbm - convert a portable bitmap into a Group 3 FAX file X.SH SYNOPSIS Xpbmtog3 [pbmfile] X.SH DESCRIPTION XReads a portable bitmap as output. XProduces a Group 3 FAX file as input. X.SH REFERENCES XThe standard for Group 3 FAX is defined in CCITT Recommendation T.4. X.SH "SEE ALSO" Xg3topbm(1), pbm(5) X.SH AUTHOR XCopyright (C) 1989 by Paul Haeberli <paul@manray.sgi.com>. X XPermission to use, copy, modify, and distribute this software and its Xdocumentation for any purpose and without fee is hereby granted, provided Xthat the above copyright notice appear in all copies and that both that Xcopyright notice and this permission notice appear in supporting Xdocumentation. This software is provided "as is" without express or Ximplied warranty. SHAR_EOF if test 778 -ne "`wc -c < 'pbm/pbmtog3.1'`" then echo shar: error transmitting "'pbm/pbmtog3.1'" '(should have been 778 characters)' fi fi # end of overwriting check if test ! -d 'pbm' then echo shar: creating directory "'pbm'" mkdir 'pbm' fi echo shar: extracting "'pbm/pbmtoxwd.1'" '(756 characters)' if test -f 'pbm/pbmtoxwd.1' then echo shar: will not over-write existing file "'pbm/pbmtoxwd.1'" else sed 's/^X//' << \SHAR_EOF > 'pbm/pbmtoxwd.1' X.TH pbmtoxwd 1 "31 August 1988" X.SH NAME Xpbmtoxwd - convert a portable bitmap into an X11 window dump X.SH SYNOPSIS Xpbmtoxwd [pbmfile] X.SH DESCRIPTION XReads a portable bitmap as input. XProduces an X11 window dump as output. XThis window dump can be displayed using the xwud tool. X.SH "SEE ALSO" Xxwdtopbm(1), pbm(5), ppmtoxwd(1), xwdtoppm(1) X.SH AUTHOR XCopyright (C) 1988 by Jef Poskanzer. X XPermission to use, copy, modify, and distribute this software and its Xdocumentation for any purpose and without fee is hereby granted, provided Xthat the above copyright notice appear in all copies and that both that Xcopyright notice and this permission notice appear in supporting Xdocumentation. This software is provided "as is" without express or Ximplied warranty. SHAR_EOF if test 756 -ne "`wc -c < 'pbm/pbmtoxwd.1'`" then echo shar: error transmitting "'pbm/pbmtoxwd.1'" '(should have been 756 characters)' fi fi # end of overwriting check if test ! -d 'pbm' then echo shar: creating directory "'pbm'" mkdir 'pbm' fi echo shar: extracting "'pbm/brushtopbm.c'" '(2237 characters)' if test -f 'pbm/brushtopbm.c' then echo shar: will not over-write existing file "'pbm/brushtopbm.c'" else sed 's/^X//' << \SHAR_EOF > 'pbm/brushtopbm.c' X/* brushtopbm.c - read a doodle brush file and write a portable bitmap X** X** Copyright (C) 1988 by Jef Poskanzer. X** X** Permission to use, copy, modify, and distribute this software and its X** documentation for any purpose and without fee is hereby granted, provided X** that the above copyright notice appear in all copies and that both that X** copyright notice and this permission notice appear in supporting X** documentation. This software is provided "as is" without express or X** implied warranty. X*/ X X#include <stdio.h> X#include "pbm.h" X Xmain( argc, argv ) Xint argc; Xchar *argv[]; X { X FILE *ifd; X register bit *bitrow, *bP; X bit getbit(); X int rows, cols, padright, row, col; X X pm_progname = argv[0]; X X if ( argc > 2 ) X pm_usage( "[brushfile]" ); X X if ( argc == 2 ) X ifd = pm_openr( argv[1] ); X else X ifd = stdin; X X getinit( ifd, &cols, &rows ); X X pbm_writepbminit( stdout, cols, rows ); X bitrow = pbm_allocrow( cols ); X X /* Compute padding to round cols up to the next multiple of 16. */ X padright = ( ( cols + 15 ) / 16 ) * 16 - cols; X X for ( row = 0; row < rows; row++ ) X { X /* Get data. */ X for ( col = 0, bP = bitrow; col < cols; col++, bP++ ) X *bP = getbit( ifd ); X /* Discard line padding. */ X for ( col = 0; col < padright; col++ ) X (void) getbit( ifd ); X /* Write row. */ X pbm_writepbmrow( stdout, bitrow, cols ); X } X X pm_close( ifd ); X X exit( 0 ); X } X X Xint item, bitsperitem, bitshift; X Xgetinit( file, colp, rowp ) XFILE *file; Xint *colp, *rowp; X { X int i; X X if ( getc( file ) != 1 ) X pm_error( "bad magic number 1", 0,0,0,0,0 ); X if ( getc( file ) != 0 ) X pm_error( "bad magic number 2", 0,0,0,0,0 ); X *colp = getc( file ) << 8; X *colp += getc( file ); X *rowp = getc( file ) << 8; X *rowp += getc( file ); X bitsperitem = 8; X X /* Junk rest of header. */ X for ( i = 0; i < 10; i++ ) /* 10 is just a guess at the header size */ X (void) getc( file ); X } X Xbit Xgetbit( file ) XFILE *file; X { X bit b; X X if ( bitsperitem == 8 ) X { X item = getc( file ); X bitsperitem = 0; X bitshift = 7; X } X bitsperitem++; X b = ( ( item >> bitshift) & 1 ) ? PBM_WHITE : PBM_BLACK; X bitshift--; X return b; X } SHAR_EOF if test 2237 -ne "`wc -c < 'pbm/brushtopbm.c'`" then echo shar: error transmitting "'pbm/brushtopbm.c'" '(should have been 2237 characters)' fi fi # end of overwriting check if test ! -d 'pbm' then echo shar: creating directory "'pbm'" mkdir 'pbm' fi echo shar: extracting "'pbm/brushtopbm.1'" '(731 characters)' if test -f 'pbm/brushtopbm.1' then echo shar: will not over-write existing file "'pbm/brushtopbm.1'" else sed 's/^X//' << \SHAR_EOF > 'pbm/brushtopbm.1' X.TH brushtopbm 1 "28 August 1988" X.SH NAME Xbrushtopbm - convert a doodle brush file into a portable bitmap X.SH SYNOPSIS Xbrushtopbm [brushfile] X.SH DESCRIPTION XReads a Xerox doodle brush file as input. XProduces a portable bitmap as output. X.PP XNote that there is currently no pbmtobrush tool. X.SH "SEE ALSO" Xpbm(5) X.SH AUTHOR XCopyright (C) 1988 by Jef Poskanzer. X XPermission to use, copy, modify, and distribute this software and its Xdocumentation for any purpose and without fee is hereby granted, provided Xthat the above copyright notice appear in all copies and that both that Xcopyright notice and this permission notice appear in supporting Xdocumentation. This software is provided "as is" without express or Ximplied warranty. SHAR_EOF if test 731 -ne "`wc -c < 'pbm/brushtopbm.1'`" then echo shar: error transmitting "'pbm/brushtopbm.1'" '(should have been 731 characters)' fi fi # end of overwriting check if test ! -d 'pbm' then echo shar: creating directory "'pbm'" mkdir 'pbm' fi echo shar: extracting "'pbm/mgrtopbm.c'" '(3045 characters)' if test -f 'pbm/mgrtopbm.c' then echo shar: will not over-write existing file "'pbm/mgrtopbm.c'" else sed 's/^X//' << \SHAR_EOF > 'pbm/mgrtopbm.c' X/* mgrtopbm.c - read a MGR bitmap and produce a portable bitmap X** X** Copyright (C) 1989 by Jef Poskanzer. X** X** Permission to use, copy, modify, and distribute this software and its X** documentation for any purpose and without fee is hereby granted, provided X** that the above copyright notice appear in all copies and that both that X** copyright notice and this permission notice appear in supporting X** documentation. This software is provided "as is" without express or X** implied warranty. X*/ X X#include <stdio.h> X#include "pbm.h" X#include "mgr.h" X Xmain( argc, argv ) Xint argc; Xchar *argv[]; X { X FILE *ifd; X register bit *bitrow, *bP; X bit getbit(); X int rows, cols, depth, padright, row, col; X X pm_progname = argv[0]; X X if ( argc > 2 ) X pm_usage( "[mgrfile]" ); X X if ( argc == 2 ) X ifd = pm_openr( argv[1] ); X else X ifd = stdin; X X getinit( ifd, &cols, &rows, &depth, &padright ); X if ( depth != 1 ) X pm_error( "MGR file has depth of %d, must be 1", depth, 0,0,0,0 ); X X pbm_writepbminit( stdout, cols, rows ); X bitrow = pbm_allocrow( cols ); X X for ( row = 0; row < rows; row++ ) X { X /* Get data, bit-reversed within each byte. */ X for ( col = 0, bP = bitrow; col < cols; col++, bP++ ) X *bP = getbit( ifd ); X /* Discard line padding */ X for ( col = 0; col < padright; col ++ ) X (void) getbit( ifd ); X pbm_writepbmrow( stdout, bitrow, cols ); X } X X pm_close( ifd ); X X exit( 0 ); X } X X Xunsigned char item; Xint bitsperitem, bitshift; X Xgetinit( file, colsP, rowsP, depthP, padrightP ) XFILE *file; Xint *colsP, *rowsP, *depthP, *padrightP; X { X struct b_header head; X int pad; X X if ( fread( &head, sizeof(struct old_b_header), 1, file ) != 1 ) X pm_perror( "reading header" ); X if ( head.magic[0] == 'y' && head.magic[1] == 'z' ) X { /* new style bitmap */ X if ( fread( &head.depth, sizeof(head) - sizeof(struct old_b_header), 1, file ) != 1 ) X pm_perror( "reading rest of header" ); X *depthP = (int) head.depth - ' '; X pad = 8; X } X else if ( head.magic[0] == 'x' && head.magic[1] == 'z' ) X { /* old style bitmap with 32-bit padding */ X *depthP = 1; X pad = 32; X } X else if ( head.magic[0] == 'z' && head.magic[1] == 'z' ) X { /* old style bitmap with 16-bit padding */ X *depthP = 1; X pad = 16; X } X else if ( head.magic[0] == 'z' && head.magic[1] == 'y' ) X { /* old style 8-bit pixmap with 16-bit padding */ X *depthP = 8; X pad = 16; X } X else X pm_error( X "bad magic chars in MGR file: '%c%c'", X head.magic[0], head.magic[1], 0,0,0 ); X *colsP = ( ( (int) head.h_wide - ' ' ) << 6 ) + ( (int) head.l_wide - ' ' ); X *rowsP = ( ( (int) head.h_high - ' ' ) << 6 ) + ( (int) head.l_high - ' ' ); X *padrightP = ( ( *colsP + pad - 1 ) / pad ) * pad - *colsP; X X bitsperitem = 8; X } X Xbit Xgetbit( file ) XFILE *file; X { X bit b; X X if ( bitsperitem == 8 ) X { X item = getc( file ); X bitsperitem = 0; X bitshift = 7; X } X bitsperitem++; X b = ( ( item >> bitshift) & 1 ) ? PBM_BLACK : PBM_WHITE; X bitshift--; X return b; X } SHAR_EOF if test 3045 -ne "`wc -c < 'pbm/mgrtopbm.c'`" then echo shar: error transmitting "'pbm/mgrtopbm.c'" '(should have been 3045 characters)' fi fi # end of overwriting check if test ! -d 'pbm' then echo shar: creating directory "'pbm'" mkdir 'pbm' fi echo shar: extracting "'pbm/mgrtopbm.1'" '(664 characters)' if test -f 'pbm/mgrtopbm.1' then echo shar: will not over-write existing file "'pbm/mgrtopbm.1'" else sed 's/^X//' << \SHAR_EOF > 'pbm/mgrtopbm.1' X.TH mgrtopbm 1 "24 January 1989" X.SH NAME Xmgrtopbm - convert a MGR bitmap into a portable bitmap X.SH SYNOPSIS Xmgrtopbm [mgrfile] X.SH DESCRIPTION XReads a MGR bitmap as input. XProduces a portable bitmap as output. X.SH "SEE ALSO" Xpbmtomgr(1), pbm(5) X.SH AUTHOR XCopyright (C) 1989 by Jef Poskanzer. X XPermission to use, copy, modify, and distribute this software and its Xdocumentation for any purpose and without fee is hereby granted, provided Xthat the above copyright notice appear in all copies and that both that Xcopyright notice and this permission notice appear in supporting Xdocumentation. This software is provided "as is" without express or Ximplied warranty. SHAR_EOF if test 664 -ne "`wc -c < 'pbm/mgrtopbm.1'`" then echo shar: error transmitting "'pbm/mgrtopbm.1'" '(should have been 664 characters)' fi fi # end of overwriting check # End of shell archive exit 0