[comp.sources.misc] v05i042: pbm.shar2

jef@helios.ee.lbl.gov (Jef Poskanzer) (11/09/88)

Posting-number: Volume 5, Issue 42
Submitted-by: "Jef Poskanzer" <jef@helios.ee.lbl.gov>
Archive-name: pbm3/Part2

#! /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:
#	xwdtopbm.1
#	pbmtocbm.c
#	pbmtocbm.1
#	pbmtoicon.c
#	pbmtoicon.1
#	pbmtops.c
#	pbmtops.1
#	pbmtoptx.c
#	pbmtoptx.1
#	pbmtorast.c
#	pbmtorast.1
#	pbmtoxbm.c
#	pbmtoxbm.1
#	pbmtox10bm.c
#	pbmtox10bm.1
#	pbmtoascii.c
#	pbmtoascii.1
#	pbmcatlr.c
#	pbmcatlr.1
#	pbmcattb.c
#	pbmcattb.1
#	pbmfliplr.c
#	pbmfliplr.1
# This archive created: Mon Oct 31 18:33:31 1988
# By:	Jef Poskanzer (Paratheo-Anametamystikhood Of Eris Esoteric, Ada Lovelace Cabal)
export PATH; PATH=/bin:$PATH
echo shar: extracting "'xwdtopbm.1'" '(1131 characters)'
if test -f 'xwdtopbm.1'
then
	echo shar: will not over-write existing file "'xwdtopbm.1'"
else
sed 's/^X//' << \SHAR_EOF > 'xwdtopbm.1'
X.TH xwdtopbm 1 "31 August 1988"
X.SH NAME
Xxwdtopbm - convert X11 and X10 window dump files into portable bitmaps
X.SH SYNOPSIS
Xxwdtopbm [xwdfile]
X.SH DESCRIPTION
XReads an X11 or X10 window dump file as input.
XProduces a portable bitmap as output.
X.LP
XUsing this program, you can convert anything on an X workstation's screen
Xinto a pbm bitmap.
XJust display whatever you're interested in, do an xwd, run it through
Xxwdtopbm, and then use pbmcut to select the part you want.
X.LP
XNote that this tool only works for monochrome dump files.
X.SH BUGS
XI haven't tested this tool with very many configurations, so there are
Xprobably bugs.
XPlease let me know if you find any.
X.SH "SEE ALSO"
Xpbmtoxwd(1), pbmtox10wd(1), pbm(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 1131 -ne "`wc -c < 'xwdtopbm.1'`"
then
	echo shar: error transmitting "'xwdtopbm.1'" '(should have been 1131 characters)'
fi
fi # end of overwriting check
echo shar: extracting "'pbmtocbm.c'" '(1104 characters)'
if test -f 'pbmtocbm.c'
then
	echo shar: will not over-write existing file "'pbmtocbm.c'"
else
sed 's/^X//' << \SHAR_EOF > 'pbmtocbm.c'
X/* pbmtocbm.c - read a portable bitmap and produce a compact 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    bit **bits;
X    int rows, cols, row, col;
X
X    if ( argc > 2 )
X	{
X	fprintf( stderr, "usage:  %s [pbmfile]\n", argv[0] );
X	exit( 1 );
X	}
X
X    if ( argc == 2 )
X	{
X        ifd = fopen( argv[1], "r" );
X        if ( ifd == NULL )
X	    {
X	    fprintf( stderr, "%s: can't open.\n", argv[1] );
X	    exit( 1 );
X	    }
X	}
X    else
X	ifd = stdin;
X
X    bits = pbm_readpbm( ifd, &cols, &rows );
X
X    if ( ifd != stdin )
X	fclose( ifd );
X    
X    pbm_writecbm( stdout, bits, cols, rows );
X
X    exit( 0 );
X    }
SHAR_EOF
if test 1104 -ne "`wc -c < 'pbmtocbm.c'`"
then
	echo shar: error transmitting "'pbmtocbm.c'" '(should have been 1104 characters)'
fi
fi # end of overwriting check
echo shar: extracting "'pbmtocbm.1'" '(669 characters)'
if test -f 'pbmtocbm.1'
then
	echo shar: will not over-write existing file "'pbmtocbm.1'"
else
sed 's/^X//' << \SHAR_EOF > 'pbmtocbm.1'
X.TH pbmtocbm 1 "31 August 1988"
X.SH NAME
Xpbmtocbm - convert portable bitmaps into compact bitmaps
X.SH SYNOPSIS
Xpbmtocbm [pbmfile]
X.SH DESCRIPTION
XReads a portable bitmap as input.
XProduces a compact bitmap as output.
X.SH "SEE ALSO"
Xcbmtopbm(1), pbm(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 669 -ne "`wc -c < 'pbmtocbm.1'`"
then
	echo shar: error transmitting "'pbmtocbm.1'" '(should have been 669 characters)'
fi
fi # end of overwriting check
echo shar: extracting "'pbmtoicon.c'" '(2378 characters)'
if test -f 'pbmtoicon.c'
then
	echo shar: will not over-write existing file "'pbmtoicon.c'"
else
sed 's/^X//' << \SHAR_EOF > 'pbmtoicon.c'
X/* pbmtoicon.c - read a portable bitmap and produce a Sun icon file
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    bit **bits;
X    int rows, cols, pad, padleft, padright, row, col;
X    char ch;
X
X    if ( argc > 2 )
X	{
X	fprintf( stderr, "usage:  %s [pbmfile]\n", argv[0] );
X	exit( 1 );
X	}
X
X    if ( argc == 2 )
X	{
X        ifd = fopen( argv[1], "r" );
X        if ( ifd == NULL )
X	    {
X	    fprintf( stderr, "%s: can't open.\n", argv[1] );
X	    exit( 1 );
X	    }
X	}
X    else
X	ifd = stdin;
X
X    bits = pbm_readpbm( ifd, &cols, &rows );
X
X    if ( ifd != stdin )
X	fclose( ifd );
X    
X    /* Round cols up to the nearest multiple of 16. */
X    pad = ( ( cols + 15 ) / 16 ) * 16 - cols;
X    padleft = pad / 2;
X    padright = pad - padleft;
X
X    printf( "/* Format_version=1, Width=%d, Height=%d", cols + pad, rows );
X    printf( ", Depth=1, Valid_bits_per_item=16\n */\n" );
X
X    putinit( );
X    for ( row = 0; row < rows; row++ )
X	{
X	for ( col = 0; col < padleft; col++ )
X	    putbit( 0 );
X        for ( col = 0; col < cols; col++ )
X	    putbit( bits[row][col] );
X	for ( col = 0; col < padright; col++ )
X	    putbit( 0 );
X        }
X    putrest( );
X
X    exit( 0 );
X    }
X
X
Xint item, bitsperitem, bitshift, itemsperline, firstitem;
X
Xputinit( )
X    {
X    itemsperline = 0;
X    bitsperitem = 0;
X    item = 0;
X    bitshift = 15;
X    firstitem = 1;
X    }
X
Xputbit( b )
Xbit b;
X    {
X    if ( bitsperitem == 16 )
X	putitem( );
X    bitsperitem++;
X    if ( b )
X	item += 1 << bitshift;
X    bitshift--;
X    }
X
Xputrest( )
X    {
X    if ( bitsperitem > 0 )
X	putitem( );
X    putchar( '\n' );
X    }
X
Xputitem( )
X    {
X    if ( firstitem )
X	firstitem = 0;
X    else
X	putchar( ',' );
X    if ( itemsperline == 8 )
X	{
X	putchar( '\n' );
X	itemsperline = 0;
X	}
X    if ( itemsperline == 0 )
X	putchar( '\t' );
X    itemsperline++;
X    printf( "0x%04x", item );
X    bitsperitem = 0;
X    item = 0;
X    bitshift = 15;
X    }
SHAR_EOF
if test 2378 -ne "`wc -c < 'pbmtoicon.c'`"
then
	echo shar: error transmitting "'pbmtoicon.c'" '(should have been 2378 characters)'
fi
fi # end of overwriting check
echo shar: extracting "'pbmtoicon.1'" '(662 characters)'
if test -f 'pbmtoicon.1'
then
	echo shar: will not over-write existing file "'pbmtoicon.1'"
else
sed 's/^X//' << \SHAR_EOF > 'pbmtoicon.1'
X.TH pbmtoicon 1 "31 August 1988"
X.SH NAME
Xpbmtoicon - convert portable bitmaps into Sun icons 
X.SH SYNOPSIS
Xpbmtoicon [pbmfile]
X.SH DESCRIPTION
XReads a portable bitmap as input.
XProduces a Sun icon as output.
X.SH "SEE ALSO"
Xicontopbm(1), pbm(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 662 -ne "`wc -c < 'pbmtoicon.1'`"
then
	echo shar: error transmitting "'pbmtoicon.1'" '(should have been 662 characters)'
fi
fi # end of overwriting check
echo shar: extracting "'pbmtops.c'" '(6152 characters)'
if test -f 'pbmtops.c'
then
	echo shar: will not over-write existing file "'pbmtops.c'"
else
sed 's/^X//' << \SHAR_EOF > 'pbmtops.c'
X/* pbmtops.c - read a portable bitmap and produce a PostScript bitmap file
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#ifdef	OS_SYSV
X#include <string.h>
X#else	OS_SYSV
X#include <strings.h>
X#endif	OS_SYSV
X#include "pbm.h"
X
Xmain( argc, argv )
Xint argc;
Xchar *argv[];
X    {
X    FILE *ifd;
X    bit **bits;
X    int argn, rows, cols, padright, row, col;
X    char ch;
X    float scale;
X    char name[100], *cp;
X    char *usage = "usage:  %s [-s scale] [pbmfile]\n";
X
X    argn = 1;
X    scale = 1.0;
X
X    /* Check for flags. */
X    if ( argn < argc )
X	{
X	if ( argv[argn][0] == '-' )
X	    {
X	    if ( ( argv[argn][1] == 's' || argv[argn][1] == 'S' ) &&
X		 argv[argn][2] == '\0' )
X		{
X		argn++;
X		if ( argn == argc )
X		    {
X		    fprintf( stderr, usage, argv[0] );
X		    exit( 1 );
X		    }
X		if ( sscanf( argv[argn], "%f", &scale ) != 1 )
X		    {
X		    fprintf( stderr, usage, argv[0] );
X		    exit( 1 );
X		    }
X		argn++;
X		}
X	    else
X		{
X		fprintf( stderr, usage, argv[0] );
X		exit( 1 );
X		}
X	    }
X	}
X
X    if ( argn == argc )
X	{
X	ifd = stdin;
X	strcpy( name, "noname" );
X	}
X    else
X	{
X        ifd = fopen( argv[argn], "r" );
X        if ( ifd == NULL )
X	    {
X	    fprintf( stderr, "%s: can't open.\n", argv[argn] );
X	    exit( 1 );
X	    }
X	strcpy( name, argv[argn] );
X
X#ifdef	OS_SYSV
X	if ( ( cp = strchr( name, '.' ) ) != 0 )
X#else	OS_SYSV
X	if ( ( cp = index( name, '.' ) ) != 0 )
X#endif	OS_SYSV
X	    *cp = '\0';
X	argn++;
X	}
X
X    if ( argn != argc )
X	{
X	fprintf( stderr, usage, argv[0] );
X	exit( 1 );
X	}
X
X    bits = pbm_readpbm( ifd, &cols, &rows );
X
X    if ( ifd != stdin )
X	fclose( ifd );
X    
X    /* Compute padding to round cols up to the nearest multiple of 8. */
X    padright = ( ( cols + 7 ) / 8 ) * 8 - cols;
X
X    putinit( name, cols, rows, scale );
X    for ( row = 0; row < rows; row++ )
X	{
X        for ( col = 0; col < cols; col++ )
X	    putbit( bits[row][col] );
X	for ( col = 0; col < padright; col++ )
X	    putbit( 0 );
X        }
X    putrest( );
X
X    exit( 0 );
X    }
X
X
Xint item, bitsperitem, bitshift, rlitemsperline;
Xint repeat, itembuf[128], count, repeatitem, repeatcount;
X
Xputinit( name, cols, rows, scale )
Xchar *name;
Xint cols, rows;
Xfloat scale;
X    {
X    int scols, srows;
X
X    scols = cols * scale * 0.96 + 0.5;	/*   0.96 is the multiple of   */
X    srows = rows * scale * 0.96 + 0.5;	/* 72/300 that is closest to 1 */
X
X    printf( "%%! %s.ps\n", name );
X    printf( "\n" );
X    printf( "/rlestr1 1 string def\n" );
X    printf( "/rlestr 128 string def\n" );
X    printf( "/readrlestring {\n" );
X    printf( "  currentfile rlestr1 readhexstring pop  0 get\n" );
X    printf( "  dup 127 le {\n" );
X    printf( "    currentfile rlestr 0  4 3 roll  1 add  getinterval\n" );
X    printf( "    readhexstring  pop\n" );
X    printf( "  } {\n" );
X    printf( "    256 exch sub  dup\n" );
X    printf( "    currentfile rlestr1 readhexstring pop  0 get\n" );
X    printf( "    exch 0 exch 1 exch 1 sub { rlestr exch 2 index put } for\n" );
X    printf( "    pop  rlestr exch 0 exch getinterval\n" );
X    printf( "  } ifelse\n" );
X    printf( "} bind def\n" );
X    printf( "\n" );
X    printf(
X	"%d %d translate\t%% move to lower left corner of box\n",
X	300 - ( scols/2 ), 400 - ( srows/2 ) );
X    printf( "%d %d scale\t\t%% scale box\n", scols, srows );
X    printf( "\n" );
X    printf( "%d %d 1\t\t\t%% width height bits/sample\n", cols, rows );
X    printf(
X	"[ %d 0 0 -%d 0 %d ]\t%% transformation matrix\n", cols, rows, rows );
X    printf( "{ readrlestring }\t%% proc\n" );
X    printf( "image\n" );
X
X    rlitemsperline = 0;
X    item = 0;
X    bitsperitem = 0;
X    bitshift = 7;
X
X    repeat = 1;
X    count = 0;
X    }
X
Xputrlitem( rlitem )
Xint rlitem;
X    {
X    if ( rlitemsperline == 30 )
X	{
X	putchar( '\n' );
X	rlitemsperline = 0;
X	}
X    rlitemsperline++;
X    printf( "%02x", rlitem );
X    }
X
Xputrlbuffer( )
X    {
X    int i;
X
X    if ( repeat )
X	{
X	putrlitem( 256 - count );
X	putrlitem( repeatitem );
X	}
X    else
X	{
X	putrlitem( count - 1 );
X	for ( i = 0; i < count; i++ )
X	    putrlitem( itembuf[i] );
X	}
X    repeat = 1;
X    count = 0;
X    }
X
Xputitem( )
X    {
X    int i;
X
X    if ( count == 128 )
X	putrlbuffer( );
X
X    if ( repeat && count == 0 )
X	{ /* Still initializing a repeat buf. */
X	itembuf[count] = repeatitem = item;
X	count++;
X	}
X    else if ( repeat )
X	{ /* Repeating - watch for end of run. */
X	if ( item == repeatitem )
X	    { /* Run continues. */
X	    itembuf[count] = item;
X	    count++;
X	    }
X	else
X	    { /* Run ended - is it long enough to dump? */
X	    if ( count > 2 )
X		{ /* Yes, dump a repeat-mode buffer and start a new one. */
X		putrlbuffer( );
X		itembuf[count] = repeatitem = item;
X		count++;
X		}
X	    else
X		{ /* Not long enough - convert to non-repeat mode. */
X		repeat = 0;
X		itembuf[count] = repeatitem = item;
X		count++;
X		repeatcount = 1;
X		}
X	    }
X	}
X    else
X	{ /* Not repeating - watch for a run worth repeating. */
X	if ( item == repeatitem )
X	    { /* Possible run continues. */
X	    repeatcount++;
X	    if ( repeatcount > 3 )
X		{ /* Long enough - dump non-repeat part and start repeat. */
X		count = count - ( repeatcount - 1 );
X		putrlbuffer( );
X		count = repeatcount;
X		for ( i = 0; i < count; i++ )
X		    itembuf[i] = item;
X		}
X	    else
X		{ /* Not long enough yet - continue as non-repeat buf. */
X		itembuf[count] = item;
X		count++;
X		}
X	    }
X	else
X	    { /* Broken run. */
X	    itembuf[count] = repeatitem = item;
X	    count++;
X	    repeatcount = 1;
X	    }
X	}
X
X    item = 0;
X    bitsperitem = 0;
X    bitshift = 7;
X    }
X
Xputbit( b )
Xbit b;
X    {
X    if ( bitsperitem == 8 )
X	{
X	putitem( );
X	}
X    if ( ! b )
X	item += 1 << bitshift;
X    bitsperitem++;
X    bitshift--;
X    }
X
Xputrest( )
X    {
X    if ( bitsperitem > 0 )
X	putitem( );
X    if ( count > 0 )
X	putrlbuffer( );
X    printf( "\nshowpage\n" );
X    }
SHAR_EOF
if test 6152 -ne "`wc -c < 'pbmtops.c'`"
then
	echo shar: error transmitting "'pbmtops.c'" '(should have been 6152 characters)'
fi
fi # end of overwriting check
echo shar: extracting "'pbmtops.1'" '(1228 characters)'
if test -f 'pbmtops.1'
then
	echo shar: will not over-write existing file "'pbmtops.1'"
else
sed 's/^X//' << \SHAR_EOF > 'pbmtops.1'
X.TH pbmtops 1 "29 August 1988"
X.SH NAME
Xpbmtops - convert portable bitmaps into PostScript
X.SH SYNOPSIS
Xpbmtops [ -s <scale> ] [ <pbmfile> ]
X.SH DESCRIPTION
XReads a portable bitmap as input.
XProduces PostScript as output.
X.LP
XThe -s flag controls the scale of the result.  The default scale is 1,
Xwhich results in one pbm pixel producing a 3x3 square of PostScript
Xpixels.  On a 300 dpi printer such as the Apple Laserwriter, this makes
Xthe output look about the same size as the input would if it was displayed
Xon a typical 72 dpi screen.
XTo get one pbm pixel per PostScript pixel, use "-s 0.333333".
X.LP
XNote that there is no pstopbm
Xtool - this transformation is one-way, because a pstopbm tool would
Xbe a full-fledged PostScript interpreter, which is beyond the scope
Xof this package.
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 1228 -ne "`wc -c < 'pbmtops.1'`"
then
	echo shar: error transmitting "'pbmtops.1'" '(should have been 1228 characters)'
fi
fi # end of overwriting check
echo shar: extracting "'pbmtoptx.c'" '(1791 characters)'
if test -f 'pbmtoptx.c'
then
	echo shar: will not over-write existing file "'pbmtoptx.c'"
else
sed 's/^X//' << \SHAR_EOF > 'pbmtoptx.c'
X/* pbmtoptx.c - read a portable bitmap and produce a Printronix printer file
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#ifdef	OS_SYSV
X#include <string.h>
X#else	OS_SYSV
X#include <strings.h>
X#endif	OS_SYSV
X#include "pbm.h"
X
Xmain( argc, argv )
Xint argc;
Xchar *argv[];
X    {
X    FILE *ifd;
X    bit **bits;
X    int rows, cols, row, col;
X    char *usage = "usage:  %s [pbmfile]\n";
X
X    if ( argc > 2 )
X	{
X	fprintf( stderr, usage, argv[0] );
X	exit( 1 );
X	}
X
X    if ( argc == 2 )
X	{
X        ifd = fopen( argv[1], "r" );
X        if ( ifd == NULL )
X	    {
X	    fprintf( stderr, "%s: can't open.\n", argv[1] );
X	    exit( 1 );
X	    }
X	}
X    else
X	ifd = stdin;
X
X    bits = pbm_readpbm( ifd, &cols, &rows );
X
X    if ( ifd != stdin )
X	fclose( ifd );
X    
X    putinit( );
X    for ( row = 0; row < rows; row++ )
X	{
X	putchar( 5 );
X        for ( col = 0; col < cols; col++ )
X	    putbit( bits[row][col] );
X	putrest( );
X	putchar( '\n' );
X        }
X
X    exit( 0 );
X    }
X
X
Xchar item;
Xint bitsperitem, bitshift;
X
Xputinit( )
X    {
X    bitsperitem = 0;
X    item = 64;
X    bitshift = 0;
X    }
X
Xputbit( b )
Xbit b;
X    {
X    if ( bitsperitem == 6 )
X	putitem( );
X    if ( b )
X	item += 1 << bitshift;
X    bitsperitem++;
X    bitshift++;
X    }
X
Xputrest( )
X    {
X    if ( bitsperitem > 0 )
X	putitem( );
X    }
X
Xputitem( )
X    {
X    putchar( item );
X    bitsperitem = 0;
X    item = 64;
X    bitshift = 0;
X    }
SHAR_EOF
if test 1791 -ne "`wc -c < 'pbmtoptx.c'`"
then
	echo shar: error transmitting "'pbmtoptx.c'" '(should have been 1791 characters)'
fi
fi # end of overwriting check
echo shar: extracting "'pbmtoptx.1'" '(763 characters)'
if test -f 'pbmtoptx.1'
then
	echo shar: will not over-write existing file "'pbmtoptx.1'"
else
sed 's/^X//' << \SHAR_EOF > 'pbmtoptx.1'
X.TH pbmtoptx 1 "31 August 1988"
X.SH NAME
Xpbmtoptx - convert portable bitmaps into Printronix printer graphics
X.SH SYNOPSIS
Xpbmtoptx [pbmfile]
X.SH DESCRIPTION
XReads a portable bitmap as input.
XProduces a file of Printronix printer graphics as output.
X.LP
XNote that there is no ptxtopbm tool - this transformation is one way.
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 763 -ne "`wc -c < 'pbmtoptx.1'`"
then
	echo shar: error transmitting "'pbmtoptx.1'" '(should have been 763 characters)'
fi
fi # end of overwriting check
echo shar: extracting "'pbmtorast.c'" '(1849 characters)'
if test -f 'pbmtorast.c'
then
	echo shar: will not over-write existing file "'pbmtorast.c'"
else
sed 's/^X//' << \SHAR_EOF > 'pbmtorast.c'
X/* pbmtorast.c - read a portable bitmap and produce a Sun rasterfile
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
X/* Because of the following include, this program compiles only on Suns. */
X#include <pixrect/pixrect_hs.h>
X
Xmain( argc, argv )
Xint argc;
Xchar *argv[];
X    {
X    FILE *ifd;
X    bit **bits;
X    int linebytes;
X    int rows, cols, row, col;
X    struct pixrect *pr;
X    short *data;
X    int shortcount, bitcount;
X
X    if ( argc > 2 )
X	{
X	fprintf( stderr, "usage:  %s [pbmfile]\n", argv[0] );
X	exit( 1 );
X	}
X
X    if ( argc == 2 )
X	{
X	ifd = fopen( argv[1], "r" );
X	if ( ifd == NULL )
X	    {
X	    fprintf( stderr, "%s: can't open.\n", argv[1] );
X	    exit( 1 );
X	    }
X	}
X    else
X	ifd = stdin;
X
X    bits = pbm_readpbm( ifd, &cols, &rows );
X
X    if ( ifd != stdin )
X	fclose( ifd );
X    
X    if ( (pr = mem_create(cols, rows, 1)) == NULL )
X	{
X	fprintf( stderr, "Unable to create new pixrect.\n");
X	exit( 1 );
X	}
X
X    data = ((struct mpr_data *)pr->pr_data)->md_image;
X    linebytes = ((struct mpr_data *)pr->pr_data)->md_linebytes;
X
X    for ( row = 0; row < rows; row++ )
X	{
X	bitcount = 15;
X	shortcount = 0;
X	for ( col = 0; col < cols; col++ )
X	    {
X	    *(data + shortcount) |= (bits[row][col] << bitcount);
X	    bitcount--;
X	    if ( bitcount < 0 )
X		{
X		bitcount = 15;
X		shortcount++;
X		}
X	    }
X	data += linebytes / sizeof(short);
X	}
X
X    pr_dump( pr, stdout, NULL, RT_BYTE_ENCODED, 0 );
X
X    exit( 0 );
X    }
SHAR_EOF
if test 1849 -ne "`wc -c < 'pbmtorast.c'`"
then
	echo shar: error transmitting "'pbmtorast.c'" '(should have been 1849 characters)'
fi
fi # end of overwriting check
echo shar: extracting "'pbmtorast.1'" '(770 characters)'
if test -f 'pbmtorast.1'
then
	echo shar: will not over-write existing file "'pbmtorast.1'"
else
sed 's/^X//' << \SHAR_EOF > 'pbmtorast.1'
X.TH pbmtorast 1 "31 August 1988"
X.SH NAME
Xpbmtorast - convert portable bitmaps into Sun rasters
X.SH SYNOPSIS
Xpbmtorast [pbmfile]
X.SH DESCRIPTION
XReads a portable bitmap as input.
XProduces a Sun raster file as output.
XNOTE: since it uses Sun-specific include files, pbmtorast will compile
Xonly on Suns.
X.SH "SEE ALSO"
Xrasttopbm(1), pbm(5)
X.SH AUTHOR
XBarry Klawans
X
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 770 -ne "`wc -c < 'pbmtorast.1'`"
then
	echo shar: error transmitting "'pbmtorast.1'" '(should have been 770 characters)'
fi
fi # end of overwriting check
echo shar: extracting "'pbmtoxbm.c'" '(2593 characters)'
if test -f 'pbmtoxbm.c'
then
	echo shar: will not over-write existing file "'pbmtoxbm.c'"
else
sed 's/^X//' << \SHAR_EOF > 'pbmtoxbm.c'
X/* pbmtoxbm.c - read a portable bitmap and produce an X11 bitmap file
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#ifdef	OS_SYSV
X#include <string.h>
X#else	OS_SYSV
X#include <strings.h>
X#endif	OS_SYSV
X#include "pbm.h"
X
Xmain( argc, argv )
Xint argc;
Xchar *argv[];
X    {
X    FILE *ifd;
X    bit **bits;
X    int rows, cols, padright, row, col;
X    char name[100], *cp;
X
X    if ( argc > 2 )
X	{
X	fprintf( stderr, "usage:  %s [pbmfile]\n", argv[0] );
X	exit( 1 );
X	}
X
X    if ( argc == 2 )
X	{
X        ifd = fopen( argv[1], "r" );
X        if ( ifd == NULL )
X	    {
X	    fprintf( stderr, "%s: can't open.\n", argv[1] );
X	    exit( 1 );
X	    }
X	strcpy( name, argv[1] );
X
X#ifdef	OS_SYSV
X	if ( ( cp = strchr( name, '.' ) ) != 0 )
X#else	OS_SYSV
X	if ( ( cp = index( name, '.' ) ) != 0 )
X#endif	OS_SYSV
X	    *cp = '\0';
X	}
X    else
X	{
X	ifd = stdin;
X	strcpy( name, "noname" );
X	}
X
X    bits = pbm_readpbm( ifd, &cols, &rows );
X
X    if ( ifd != stdin )
X	fclose( ifd );
X    
X    /* Compute padding to round cols up to the nearest multiple of 8. */
X    padright = ( ( cols + 7 ) / 8 ) * 8 - cols;
X
X    printf( "#define %s_width %d\n", name, cols );
X    printf( "#define %s_height %d\n", name, rows );
X    printf( "static char %s_bits[] = {\n", name );
X
X    putinit( );
X    for ( row = 0; row < rows; row++ )
X	{
X        for ( col = 0; col < cols; col++ )
X	    putbit( bits[row][col] );
X	for ( col = 0; col < padright; col++ )
X	    putbit( 0 );
X        }
X    putrest( );
X
X    exit( 0 );
X    }
X
X
Xint item, bitsperitem, bitshift, itemsperline, firstitem;
X
Xputinit( )
X    {
X    itemsperline = 0;
X    bitsperitem = 0;
X    item = 0;
X    bitshift = 0;
X    firstitem = 1;
X    }
X
Xputbit( b )
Xbit b;
X    {
X    if ( bitsperitem == 8 )
X	putitem( );
X    bitsperitem++;
X    if ( b )
X	item += 1 << bitshift;
X    bitshift++;
X    }
X
Xputrest( )
X    {
X    if ( bitsperitem > 0 )
X	putitem( );
X    printf( "};\n" );
X    }
X
Xputitem( )
X    {
X    if ( firstitem )
X	firstitem = 0;
X    else
X	printf( "," );
X    if ( itemsperline == 15 )
X	{
X	putchar( '\n' );
X	itemsperline = 0;
X	}
X    if ( itemsperline == 0 )
X	printf( " " );
X    itemsperline++;
X    printf( "0x%02x", item );
X    bitsperitem = 0;
X    item = 0;
X    bitshift = 0;
X    }
SHAR_EOF
if test 2593 -ne "`wc -c < 'pbmtoxbm.c'`"
then
	echo shar: error transmitting "'pbmtoxbm.c'" '(should have been 2593 characters)'
fi
fi # end of overwriting check
echo shar: extracting "'pbmtoxbm.1'" '(677 characters)'
if test -f 'pbmtoxbm.1'
then
	echo shar: will not over-write existing file "'pbmtoxbm.1'"
else
sed 's/^X//' << \SHAR_EOF > 'pbmtoxbm.1'
X.TH pbmtoxbm 1 "31 August 1988"
X.SH NAME
Xpbmtoxbm - convert portable bitmaps into X11 bitmaps
X.SH SYNOPSIS
Xpbmtoxbm [pbmfile]
X.SH DESCRIPTION
XReads a portable bitmap as input.
XProduces an X11 bitmap as output.
X.SH "SEE ALSO"
Xpbmtox10bm(1), xbmtopbm(1), pbm(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 677 -ne "`wc -c < 'pbmtoxbm.1'`"
then
	echo shar: error transmitting "'pbmtoxbm.1'" '(should have been 677 characters)'
fi
fi # end of overwriting check
echo shar: extracting "'pbmtox10bm.c'" '(2601 characters)'
if test -f 'pbmtox10bm.c'
then
	echo shar: will not over-write existing file "'pbmtox10bm.c'"
else
sed 's/^X//' << \SHAR_EOF > 'pbmtox10bm.c'
X/* pbmtox10bm.c - read a portable bitmap and produce an X10 bitmap file
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#ifdef	OS_SYSV
X#include <string.h>
X#else	OS_SYSV
X#include <strings.h>
X#endif	OS_SYSV
X#include "pbm.h"
X
Xmain( argc, argv )
Xint argc;
Xchar *argv[];
X    {
X    FILE *ifd;
X    bit **bits;
X    int rows, cols, padright, row, col;
X    char name[100], *cp;
X
X    if ( argc > 2 )
X	{
X	fprintf( stderr, "usage:  %s [pbmfile]\n", argv[0] );
X	exit( 1 );
X	}
X
X    if ( argc == 2 )
X	{
X        ifd = fopen( argv[1], "r" );
X        if ( ifd == NULL )
X	    {
X	    fprintf( stderr, "%s: can't open.\n", argv[1] );
X	    exit( 1 );
X	    }
X	strcpy( name, argv[1] );
X
X#ifdef	OS_SYSV
X	if ( ( cp = strchr( name, '.' ) ) != 0 )
X#else	OS_SYSV
X	if ( ( cp = index( name, '.' ) ) != 0 )
X#endif	OS_SYSV
X	    *cp = '\0';
X	}
X    else
X	{
X	ifd = stdin;
X	strcpy( name, "noname" );
X	}
X
X    bits = pbm_readpbm( ifd, &cols, &rows );
X
X    if ( ifd != stdin )
X	fclose( ifd );
X    
X    /* Compute padding to round cols up to the nearest multiple of 16. */
X    padright = ( ( cols + 15 ) / 16 ) * 16 - cols;
X
X    printf( "#define %s_width %d\n", name, cols );
X    printf( "#define %s_height %d\n", name, rows );
X    printf( "static short %s_bits[] = {\n", name );
X
X    putinit( );
X    for ( row = 0; row < rows; row++ )
X	{
X        for ( col = 0; col < cols; col++ )
X	    putbit( bits[row][col] );
X	for ( col = 0; col < padright; col++ )
X	    putbit( 0 );
X        }
X    putrest( );
X
X    exit( 0 );
X    }
X
X
Xint item, bitsperitem, bitshift, itemsperline, firstitem;
X
Xputinit( )
X    {
X    itemsperline = 0;
X    bitsperitem = 0;
X    item = 0;
X    bitshift = 0;
X    firstitem = 1;
X    }
X
Xputbit( b )
Xbit b;
X    {
X    if ( bitsperitem == 16 )
X	putitem( );
X    bitsperitem++;
X    if ( b )
X	item += 1 << bitshift;
X    bitshift++;
X    }
X
Xputrest( )
X    {
X    if ( bitsperitem > 0 )
X	putitem( );
X    printf( "};\n" );
X    }
X
Xputitem( )
X    {
X    if ( firstitem )
X	firstitem = 0;
X    else
X	printf( "," );
X    if ( itemsperline == 11 )
X	{
X	putchar( '\n' );
X	itemsperline = 0;
X	}
X    if ( itemsperline == 0 )
X	printf( " " );
X    itemsperline++;
X    printf( "0x%04x", item );
X    bitsperitem = 0;
X    item = 0;
X    bitshift = 0;
X    }
SHAR_EOF
if test 2601 -ne "`wc -c < 'pbmtox10bm.c'`"
then
	echo shar: error transmitting "'pbmtox10bm.c'" '(should have been 2601 characters)'
fi
fi # end of overwriting check
echo shar: extracting "'pbmtox10bm.1'" '(827 characters)'
if test -f 'pbmtox10bm.1'
then
	echo shar: will not over-write existing file "'pbmtox10bm.1'"
else
sed 's/^X//' << \SHAR_EOF > 'pbmtox10bm.1'
X.TH pbmtox10bm 1 "31 August 1988"
X.SH NAME
Xpbmtox10bm - convert portable bitmaps into X10 bitmaps
X.SH SYNOPSIS
Xpbmtox10bm [pbmfile]
X.SH DESCRIPTION
XReads a portable bitmap as input.
XProduces an X10 bitmap as output.
XThis older format is maintained for compatibility.
X.LP
XNote that there is no x10bmtopbm tool, because
Xxbmtopbm can read both X11 and X10 bitmaps.
X.SH "SEE ALSO"
Xpbmtoxbm(1), xbmtopbm(1), pbm(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 827 -ne "`wc -c < 'pbmtox10bm.1'`"
then
	echo shar: error transmitting "'pbmtox10bm.1'" '(should have been 827 characters)'
fi
fi # end of overwriting check
echo shar: extracting "'pbmtoascii.c'" '(1670 characters)'
if test -f 'pbmtoascii.c'
then
	echo shar: will not over-write existing file "'pbmtoascii.c'"
else
sed 's/^X//' << \SHAR_EOF > 'pbmtoascii.c'
X/* pbmtoascii.c - read a portable bitmap and produce ASCII graphics
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    bit **bits;
X    int rows, cols, row, col, lastcol;
X
X    if ( argc > 2 )
X	{
X	fprintf( stderr, "usage:  %s [pbmfile]\n", argv[0] );
X	exit( 1 );
X	}
X
X    if ( argc == 2 )
X	{
X        ifd = fopen( argv[1], "r" );
X        if ( ifd == NULL )
X	    {
X	    fprintf( stderr, "%s: can't open.\n", argv[1] );
X	    exit( 1 );
X	    }
X	}
X    else
X	ifd = stdin;
X
X    bits = pbm_readpbm( ifd, &cols, &rows );
X
X    if ( ifd != stdin )
X	fclose( ifd );
X    
X    /* Write out rows by twos. */
X    for ( row = 0; row < rows; row += 2 )
X	{
X	/* Find end of lines. */
X	for ( lastcol = cols-1; lastcol > 0; lastcol-- )
X	    {
X	    if ( bits[row][lastcol] )
X		break;
X	    if ( row+1 < rows && bits[row+1][lastcol] )
X		break;
X	    }
X        for ( col = 0; col <= lastcol; col++ )
X	    {
X	    if ( ! bits[row][col] )
X		{
X		if ( row+1 >= rows || ! bits[row+1][col] )
X		    putchar( ' ' );
X		else
X		    putchar( 'o' );
X		}
X	    else
X		{
X		if ( row+1 >= rows || ! bits[row+1][col] )
X		    putchar( '"' );
X		else
X		    putchar( '$' );
X		}
X	    }
X	putchar( '\n' );
X        }
X
X    exit( 0 );
X    }
SHAR_EOF
if test 1670 -ne "`wc -c < 'pbmtoascii.c'`"
then
	echo shar: error transmitting "'pbmtoascii.c'" '(should have been 1670 characters)'
fi
fi # end of overwriting check
echo shar: extracting "'pbmtoascii.1'" '(751 characters)'
if test -f 'pbmtoascii.1'
then
	echo shar: will not over-write existing file "'pbmtoascii.1'"
else
sed 's/^X//' << \SHAR_EOF > 'pbmtoascii.1'
X.TH pbmtoascii 1 "31 August 1988"
X.SH NAME
Xpbmtoascii - convert portable bitmaps into ASCII graphics
X.SH SYNOPSIS
Xpbmtoascii [pbmfile]
X.SH DESCRIPTION
XReads a portable bitmap as input.
XProduces a somewhat crude ASCII graphic as output.
X.LP
XNote that there is no asciitopbm tool - this transformation is one-way.
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 751 -ne "`wc -c < 'pbmtoascii.1'`"
then
	echo shar: error transmitting "'pbmtoascii.1'" '(should have been 751 characters)'
fi
fi # end of overwriting check
echo shar: extracting "'pbmcatlr.c'" '(2899 characters)'
if test -f 'pbmcatlr.c'
then
	echo shar: will not over-write existing file "'pbmcatlr.c'"
else
sed 's/^X//' << \SHAR_EOF > 'pbmcatlr.c'
X/* pbmcatlr.c - concatenate portable bitmaps left to right
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
X#define MAXFILES 100
X
Xmain( argc, argv )
Xint argc;
Xchar *argv[];
X    {
X    FILE *ifd[MAXFILES];
X    bit **bits[MAXFILES], **newbits, background;
X    int argn, backdefault, nfiles, i, c;
X    int rows[MAXFILES], cols[MAXFILES], row, col;
X    int newrows, newcols, newcol, padtop;
X    char *usage = "usage:  %s [-0]/[-w]/[-1]/[-b] pbmfile pbmfile ...\n";
X
X    argn = 1;
X    backdefault = 1;
X
X    /* Check for flags. */
X    if ( argn < argc )
X	{
X	if ( argv[argn][0] == '-' )
X	    {
X	    if ( ( argv[argn][1] == '0' || argv[argn][1] == 'w' ||
X		   argv[argn][1] == 'W') && argv[argn][2] == '\0' )
X		{
X		backdefault = 0;
X		background = 0;
X		}
X	    else if ( ( argv[argn][1] == '1' || argv[argn][1] == 'b' ||
X			argv[argn][1] == 'B' ) && argv[argn][2] == '\0' )
X		{
X		backdefault = 0;
X		background = 1;
X		}
X	    else
X		{
X		fprintf( stderr, usage, argv[0] );
X		exit( 1 );
X		}
X	    argn++;
X	    }
X	}
X
X    if ( argn < argc )
X	{
X	nfiles = argc - argn;
X	for ( i = 0; i < nfiles; i++ )
X	    {
X	    if ( strcmp( argv[argn+i], "-" ) == 0 )
X		ifd[i] = stdin;
X	    else
X		{
X		ifd[i] = fopen( argv[argn+i], "r" );
X		if ( ifd[i] == NULL )
X		    {
X		    fprintf( stderr, "%s: can't open.\n", argv[argn+i] );
X		    exit( 1 );
X		    }
X		}
X	    }
X	}
X    else
X	{
X	nfiles = 1;
X	ifd[0] = stdin;
X	}
X
X    newcols = 0;
X    newrows = 0;
X    for ( i = 0; i < nfiles; i++ )
X	{
X	bits[i] = pbm_readpbm( ifd[i], &cols[i], &rows[i] );
X	if ( ifd[i] != stdin )
X	    fclose( ifd[i] );
X	newcols += cols[i];
X	if ( rows[i] > newrows )
X	    newrows = rows[i];
X	}
X
X    newbits = pbm_allocarray( newcols, newrows );
X
X    newcol = 0;
X
X    for ( i = 0; i < nfiles; i++ )
X	{
X	if ( backdefault )
X	    {
X	    /* Make a reasonable guess as to what the background is. */
X	    c = (int) bits[i][0][0] + (int) bits[i][0][cols[i]-1] +
X		(int) bits[i][rows[i]-1][0] +
X		(int) bits[i][rows[i]-1][cols[i]-1];
X	    background = ( c <= 2 ) ? 0 : 1;
X	    }
X
X	padtop = (newrows - rows[i]) / 2;
X
X	for ( col = 0; col <= cols[i]; col++ )
X	    {
X	    for ( row = 0; row < padtop; row++ )
X		newbits[row][newcol+col] = background;
X	    for ( row = 0; row < rows[i]; row++ )
X		newbits[padtop+row][newcol+col] = bits[i][row][col];
X	    for ( row = padtop+rows[i]; row < newrows; row++ )
X		newbits[row][newcol+col] = background;
X	    }
X
X	newcol += cols[i];
X	}
X
X    pbm_writepbm( stdout, newbits, newcols, newrows );
X
X    exit( 0 );
X    }
SHAR_EOF
if test 2899 -ne "`wc -c < 'pbmcatlr.c'`"
then
	echo shar: error transmitting "'pbmcatlr.c'" '(should have been 2899 characters)'
fi
fi # end of overwriting check
echo shar: extracting "'pbmcatlr.1'" '(994 characters)'
if test -f 'pbmcatlr.1'
then
	echo shar: will not over-write existing file "'pbmcatlr.1'"
else
sed 's/^X//' << \SHAR_EOF > 'pbmcatlr.1'
X.TH pbmcatlr 1 "31 August 1988"
X.SH NAME
Xpbmcatlr - concatenate portable bitmaps left to right
X.SH SYNOPSIS
Xpbmcatlr [-0]/[-w]/[-1]/[-b] pbmfile pbmfile ...
X.SH DESCRIPTION
XReads portable bitmaps as input.
XConcatenates them left to right and produces a portable bitmap as output.
XIf the bitmaps are not all the same height, the shorter ones are centered
Xvertically with the edges filled in.
XThe -0/-w and -1/-b flags specify what color to use for this fill -- if neither
Xis specified, the program makes a guess as to which would look better.
X.SH "SEE ALSO"
Xpbmcattb(1), pbm(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 994 -ne "`wc -c < 'pbmcatlr.1'`"
then
	echo shar: error transmitting "'pbmcatlr.1'" '(should have been 994 characters)'
fi
fi # end of overwriting check
echo shar: extracting "'pbmcattb.c'" '(2905 characters)'
if test -f 'pbmcattb.c'
then
	echo shar: will not over-write existing file "'pbmcattb.c'"
else
sed 's/^X//' << \SHAR_EOF > 'pbmcattb.c'
X/* pbmcattb.c - concatenate portable bitmaps top to bottom
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
X#define MAXFILES 100
X
Xmain( argc, argv )
Xint argc;
Xchar *argv[];
X    {
X    FILE *ifd[MAXFILES];
X    bit **bits[MAXFILES], **newbits, background;
X    int argn, backdefault, nfiles, i, c;
X    int rows[MAXFILES], cols[MAXFILES], row, col;
X    int newrows, newcols, newrow, padleft;
X    char *usage = "usage:  %s [-0]/[-w]/[-1]/[-b] pbmfile pbmfile ...\n";
X
X    argn = 1;
X    backdefault = 1;
X
X    /* Check for flags. */
X    if ( argn < argc )
X	{
X	if ( argv[argn][0] == '-' )
X	    {
X	    if ( ( argv[argn][1] == '0' || argv[argn][1] == 'w' ||
X		   argv[argn][1] == 'W' ) && argv[argn][2] == '\0' )
X		{
X		backdefault = 0;
X		background = 0;
X		}
X	    else if ( ( argv[argn][1] == '1' || argv[argn][1] == 'b' ||
X			argv[argn][1] == 'B' ) && argv[argn][2] == '\0' )
X		{
X		backdefault = 0;
X		background = 1;
X		}
X	    else
X		{
X		fprintf( stderr, usage, argv[0] );
X		exit( 1 );
X		}
X	    argn++;
X	    }
X	}
X
X    if ( argn < argc )
X	{
X	nfiles = argc - argn;
X	for ( i = 0; i < nfiles; i++ )
X	    {
X	    if ( strcmp( argv[argn+i], "-" ) == 0 )
X		ifd[i] = stdin;
X	    else
X		{
X		ifd[i] = fopen( argv[argn+i], "r" );
X		if ( ifd[i] == NULL )
X		    {
X		    fprintf( stderr, "%s: can't open.\n", argv[argn+i] );
X		    exit( 1 );
X		    }
X		}
X	    }
X	}
X    else
X	{
X	nfiles = 1;
X	ifd[0] = stdin;
X	}
X
X    newcols = 0;
X    newrows = 0;
X    for ( i = 0; i < nfiles; i++ )
X	{
X	bits[i] = pbm_readpbm( ifd[i], &cols[i], &rows[i] );
X	if ( ifd[i] != stdin )
X	    fclose( ifd[i] );
X	if ( cols[i] > newcols )
X	    newcols = cols[i];
X	newrows += rows[i];
X	}
X
X    newbits = pbm_allocarray( newcols, newrows );
X
X    newrow = 0;
X
X    for ( i = 0; i < nfiles; i++ )
X	{
X	if ( backdefault )
X	    {
X	    /* Make a reasonable guess as to what the background is. */
X	    c = (int) bits[i][0][0] + (int) bits[i][0][cols[i]-1] +
X		(int) bits[i][rows[i]-1][0] +
X		(int) bits[i][rows[i]-1][cols[i]-1];
X	    background = ( c <= 2 ) ? 0 : 1;
X	    }
X
X	padleft = (newcols - cols[i]) / 2;
X
X	for ( row = 0; row < rows[i]; row++ )
X	    {
X	    for ( col = 0; col < padleft; col++ )
X		newbits[newrow+row][col] = background;
X	    for ( col = 0; col <= cols[i]; col++ )
X		newbits[newrow+row][padleft+col] = bits[i][row][col];
X	    for ( col = padleft+cols[i]; col < newcols; col++ )
X		newbits[newrow+row][col] = background;
X	    }
X
X	newrow += rows[i];
X	}
X
X    pbm_writepbm( stdout, newbits, newcols, newrows );
X
X    exit( 0 );
X    }
SHAR_EOF
if test 2905 -ne "`wc -c < 'pbmcattb.c'`"
then
	echo shar: error transmitting "'pbmcattb.c'" '(should have been 2905 characters)'
fi
fi # end of overwriting check
echo shar: extracting "'pbmcattb.1'" '(996 characters)'
if test -f 'pbmcattb.1'
then
	echo shar: will not over-write existing file "'pbmcattb.1'"
else
sed 's/^X//' << \SHAR_EOF > 'pbmcattb.1'
X.TH pbmcattb 1 "31 August 1988"
X.SH NAME
Xpbmcattb - concatenate portable bitmaps top to bottom
X.SH SYNOPSIS
Xpbmcattb [-0]/[-w]/[-1]/[-b] pbmfile pbmfile ...
X.SH DESCRIPTION
XReads portable bitmaps as input.
XConcatenates them top to bottom and produces a portable bitmap as output.
XIf the bitmaps are not all the same width, the narrower ones are centered
Xhorizontally with the edges filled in.
XThe -0/-w and -1/-b flags specify what color to use for this fill -- if neither
Xis specified, the program makes a guess as to which would look better.
X.SH "SEE ALSO"
Xpbmcatlr(1), pbm(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 996 -ne "`wc -c < 'pbmcattb.1'`"
then
	echo shar: error transmitting "'pbmcattb.1'" '(should have been 996 characters)'
fi
fi # end of overwriting check
echo shar: extracting "'pbmfliplr.c'" '(1305 characters)'
if test -f 'pbmfliplr.c'
then
	echo shar: will not over-write existing file "'pbmfliplr.c'"
else
sed 's/^X//' << \SHAR_EOF > 'pbmfliplr.c'
X/* pbmfliplr.c - read a portable bitmap and flip it left for right
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    bit **bits, b;
X    int rows, cols, row, col;
X
X    if ( argc > 2 )
X	{
X	fprintf( stderr, "usage:  %s [pbmfile]\n", argv[0] );
X	exit( 1 );
X	}
X
X    if ( argc == 2 )
X	{
X        ifd = fopen( argv[1], "r" );
X        if ( ifd == NULL )
X	    {
X	    fprintf( stderr, "%s: can't open.\n", argv[1] );
X	    exit( 1 );
X	    }
X	}
X    else
X	ifd = stdin;
X
X    bits = pbm_readpbm( ifd, &cols, &rows );
X
X    if ( ifd != stdin )
X	fclose( ifd );
X
X    for ( row = 0; row < rows; row++ )
X        for ( col = 0; col < cols / 2; col++ )
X	    {
X	    b = bits[row][col];
X	    bits[row][col] = bits[row][cols-col-1];
X	    bits[row][cols-col-1] = b;
X	    }
X
X    pbm_writepbm( stdout, bits, cols, rows );
X
X    exit( 0 );
X    }
SHAR_EOF
if test 1305 -ne "`wc -c < 'pbmfliplr.c'`"
then
	echo shar: error transmitting "'pbmfliplr.c'" '(should have been 1305 characters)'
fi
fi # end of overwriting check
echo shar: extracting "'pbmfliplr.1'" '(709 characters)'
if test -f 'pbmfliplr.1'
then
	echo shar: will not over-write existing file "'pbmfliplr.1'"
else
sed 's/^X//' << \SHAR_EOF > 'pbmfliplr.1'
X.TH pbmfliplr 1 "31 August 1988"
X.SH NAME
Xpbmfliplr - flip a portable bitmap left for right
X.SH SYNOPSIS
Xpbmfliplr [pbmfile]
X.SH DESCRIPTION
XReads a portable bitmap as input.
XFlips it left for right and produces a portable bitmap as output.
X.SH "SEE ALSO"
Xpbmfliptb(1), pbmtrnspos(1), pbm(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 709 -ne "`wc -c < 'pbmfliplr.1'`"
then
	echo shar: error transmitting "'pbmfliplr.1'" '(should have been 709 characters)'
fi
fi # end of overwriting check
#	End of shell archive
exit 0