PBMPLUS, part 7 of 18

Jef Poskanzer pokey at well.UUCP
Thu Sep 14 21:25:00 AEST 1989


#! /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/cmuwm.h
#	pbm/cmuwmtopbm.c
#	pbm/cmuwmtopbm.1
#	pbm/pbmtocmuwm.c
#	pbm/pbmtocmuwm.1
#	pbm/pbmmask.c
#	pbm/pbmmask.1
#	pbm/pbmtobbnbg.c
#	pbm/pbmtobbnbg.1
#	pbm/pbmtomgr.c
#	pbm/pbmtomgr.1
# This archive created: Thu Sep 14 03:43:34 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/cmuwm.h'" '(194 characters)'
if test -f 'pbm/cmuwm.h'
then
	echo shar: will not over-write existing file "'pbm/cmuwm.h'"
else
sed 's/^X//' << \SHAR_EOF > 'pbm/cmuwm.h'
X/* cmuwm.h - definitions for the CMU window manager format
X*/
X
Xstruct cmuwm_header
X    {
X    long magic;
X    long width;
X    long height;
X    short depth;
X    };
X
X#define CMUWM_MAGIC 0xf10040bb
SHAR_EOF
if test 194 -ne "`wc -c < 'pbm/cmuwm.h'`"
then
	echo shar: error transmitting "'pbm/cmuwm.h'" '(should have been 194 characters)'
fi
fi # end of overwriting check
if test ! -d 'pbm'
then
	echo shar: creating directory "'pbm'"
	mkdir 'pbm'
fi
echo shar: extracting "'pbm/cmuwmtopbm.c'" '(2800 characters)'
if test -f 'pbm/cmuwmtopbm.c'
then
	echo shar: will not over-write existing file "'pbm/cmuwmtopbm.c'"
else
sed 's/^X//' << \SHAR_EOF > 'pbm/cmuwmtopbm.c'
X/* cmuwmtopbm.c - read a CMU window manager 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 "cmuwm.h"
X
Xmain( argc, argv )
Xint argc;
Xchar *argv[];
X    {
X    FILE *ifd;
X    register bit *bitrow, *bP;
X    int rows, cols, depth, padright, row, col;
X    bit getbit();
X
X    pm_progname = argv[0];
X
X    if ( argc > 2 )
X	pm_usage( "[cmuwmfile]" );
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(
X	    "CMU window manager file has depth of %d, must be 1",
X	    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. */
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    long magic;
X    long get_big_long();
X    short get_big_short();
X
X    magic = get_big_long( file );
X    if ( magic != CMUWM_MAGIC )
X	pm_error( "bad magic number in CMU window manager file", 0,0,0,0,0 );
X    *colsP = get_big_long( file );
X    *rowsP = get_big_long( file );
X    *depthP = get_big_short( file );
X    *padrightP = ( ( *colsP + 7 ) / 8 ) * 8 - *colsP;
X
X    bitsperitem = 0;
X    }
X
Xbit
Xgetbit( file )
XFILE *file;
X    {
X    bit b;
X    unsigned char get_byte();
X
X    if ( bitsperitem == 0 )
X	{
X	item = get_byte( file );
X	bitsperitem = 8;
X	bitshift = 7;
X	}
X    b = ( ( item >> bitshift) & 1 ) ? PBM_WHITE : PBM_BLACK;
X    bitsperitem--;
X    bitshift--;
X    return b;
X    }
X
Xunsigned char
Xget_byte( f )
XFILE *f;
X    {
X    int i;
X
X    i = getc( f );
X    if ( i == EOF )
X	pm_error( "premature EOF", 0,0,0,0,0 );
X
X    return (unsigned char) i;
X    }
X
Xshort
Xget_big_short( f )
XFILE *f;
X    {
X    short s;
X
X    s = get_byte( f ) << 8;
X    s |= get_byte( f );
X
X    return s;
X    }
X
Xlong
Xget_big_long( f )
XFILE *f;
X    {
X    long l;
X
X    l = get_byte( f ) << 24;
X    l |= get_byte( f ) << 16;
X    l |= get_byte( f ) << 8;
X    l |= get_byte( f );
X
X    return l;
X    }
SHAR_EOF
if test 2800 -ne "`wc -c < 'pbm/cmuwmtopbm.c'`"
then
	echo shar: error transmitting "'pbm/cmuwmtopbm.c'" '(should have been 2800 characters)'
fi
fi # end of overwriting check
if test ! -d 'pbm'
then
	echo shar: creating directory "'pbm'"
	mkdir 'pbm'
fi
echo shar: extracting "'pbm/cmuwmtopbm.1'" '(702 characters)'
if test -f 'pbm/cmuwmtopbm.1'
then
	echo shar: will not over-write existing file "'pbm/cmuwmtopbm.1'"
else
sed 's/^X//' << \SHAR_EOF > 'pbm/cmuwmtopbm.1'
X.TH cmuwmtopbm 1 "15 April 1989"
X.SH NAME
Xcmuwmtopbm - convert a CMU window manager bitmap into a portable bitmap
X.SH SYNOPSIS
Xcmuwmtopbm [cmuwmfile]
X.SH DESCRIPTION
XReads a CMU window manager bitmap as input.
XProduces a portable bitmap as output.
X.SH "SEE ALSO"
Xpbmtocmuwm(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 702 -ne "`wc -c < 'pbm/cmuwmtopbm.1'`"
then
	echo shar: error transmitting "'pbm/cmuwmtopbm.1'" '(should have been 702 characters)'
fi
fi # end of overwriting check
if test ! -d 'pbm'
then
	echo shar: creating directory "'pbm'"
	mkdir 'pbm'
fi
echo shar: extracting "'pbm/pbmtocmuwm.c'" '(2432 characters)'
if test -f 'pbm/pbmtocmuwm.c'
then
	echo shar: will not over-write existing file "'pbm/pbmtocmuwm.c'"
else
sed 's/^X//' << \SHAR_EOF > 'pbm/pbmtocmuwm.c'
X/* pbmtocmuwm.c - read a portable bitmap and produce a CMU window manager 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 "cmuwm.h"
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
X    pm_progname = argv[0];
X
X    if ( argc > 2 )
X	pm_usage( "[pbmfile]" );
X
X    if ( argc == 2 )
X	ifd = pm_openr( argv[1] );
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    padright = ( ( cols + 7 ) / 8 ) * 8 - cols;
X
X    putinit( rows, cols );
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    pm_close( ifd );
X
X    putrest( );
X
X    exit( 0 );
X    }
X
X
Xunsigned char item;
Xint bitsperitem, bitshift;
X
Xputinit( rows, cols )
Xint rows, cols;
X    {
X    put_big_long( stdout, CMUWM_MAGIC );
X    put_big_long( stdout, cols );
X    put_big_long( stdout, rows );
X    put_big_short( stdout, 1 );
X
X    item = 0;
X    bitsperitem = 0;
X    bitshift = 7;
X    }
X
Xputbit( b )
Xbit b;
X    {
X    if ( bitsperitem == 8 )
X	putitem( );
X    if ( b == PBM_WHITE )
X	item += 1 << bitshift;
X    bitsperitem++;
X    bitshift--;
X    }
X
Xputrest( )
X    {
X    if ( bitsperitem > 0 )
X	putitem( );
X    }
X
Xputitem( )
X    {
X    put_byte( stdout, item );
X    item = 0;
X    bitsperitem = 0;
X    bitshift = 7;
X    }
X
X
Xput_byte( f, b )
XFILE *f;
Xunsigned char b;
X    {
X    if ( putc( b, f ) == EOF )
X	{
X	perror( "put_byte" );
X	exit( 1 );
X	}
X    }
X
Xput_big_short( f, s )
XFILE *f;
Xshort s;
X    {
X    put_byte( f, s >> 8 );
X    put_byte( f, s & 0xff );
X    }
X
Xput_big_long( f, l )
XFILE *f;
Xlong l;
X    {
X    put_byte( f, l >> 24 );
X    put_byte( f, ( l >> 16 ) & 0xff );
X    put_byte( f, ( l >> 8 ) & 0xff );
X    put_byte( f, l & 0xff );
X    }
SHAR_EOF
if test 2432 -ne "`wc -c < 'pbm/pbmtocmuwm.c'`"
then
	echo shar: error transmitting "'pbm/pbmtocmuwm.c'" '(should have been 2432 characters)'
fi
fi # end of overwriting check
if test ! -d 'pbm'
then
	echo shar: creating directory "'pbm'"
	mkdir 'pbm'
fi
echo shar: extracting "'pbm/pbmtocmuwm.1'" '(700 characters)'
if test -f 'pbm/pbmtocmuwm.1'
then
	echo shar: will not over-write existing file "'pbm/pbmtocmuwm.1'"
else
sed 's/^X//' << \SHAR_EOF > 'pbm/pbmtocmuwm.1'
X.TH pbmtocmuwm 1 "15 April 1989"
X.SH NAME
Xpbmtocmuwm - convert a portable bitmap into a CMU window manager bitmap
X.SH SYNOPSIS
Xpbmtocmuwm [pbmfile]
X.SH DESCRIPTION
XReads a portable bitmap as input.
XProduces a CMU window manager bitmap as output.
X.SH "SEE ALSO"
Xcmuwmtopbm(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 700 -ne "`wc -c < 'pbm/pbmtocmuwm.1'`"
then
	echo shar: error transmitting "'pbm/pbmtocmuwm.1'" '(should have been 700 characters)'
fi
fi # end of overwriting check
if test ! -d 'pbm'
then
	echo shar: creating directory "'pbm'"
	mkdir 'pbm'
fi
echo shar: extracting "'pbm/pbmmask.c'" '(3601 characters)'
if test -f 'pbm/pbmmask.c'
then
	echo shar: will not over-write existing file "'pbm/pbmmask.c'"
else
sed 's/^X//' << \SHAR_EOF > 'pbm/pbmmask.c'
X/* pbmmask.c - create a mask bitmap from 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
Xbit **bits, **mask, backcolor;
Xint rows, cols;
X
Xmain( argc, argv )
Xint argc;
Xchar *argv[];
X    {
X    FILE *ifd;
X    register int row, col, wcount;
X
X    pm_progname = argv[0];
X
X    if ( argc > 2 )
X	pm_usage( "[pbmfile]" );
X
X    if ( argc == 2 )
X	ifd = pm_openr( argv[1] );
X    else
X	ifd = stdin;
X
X    bits = pbm_readpbm( ifd, &cols, &rows );
X    pm_close( ifd );
X    mask = pbm_allocarray( cols, rows );
X
X    /* Clear out the mask. */
X    for ( row = 0; row < rows; row++ )
X        for ( col = 0; col < cols; col++ )
X	    mask[row][col] = PBM_BLACK;
X
X    /* Figure out the background color, by counting along the edge. */
X    wcount = 0;
X    for ( row = 0; row < rows; row++ )
X	{
X	if ( bits[row][0] == PBM_WHITE )
X	    wcount++;
X	if ( bits[row][cols - 1] == PBM_WHITE )
X	    wcount++;
X	}
X    for ( col = 1; col < cols - 1; col++ )
X	{
X	if ( bits[0][col] == PBM_WHITE )
X	    wcount++;
X	if ( bits[rows - 1][col] == PBM_WHITE )
X	    wcount++;
X	}
X    if ( wcount >= rows + cols - 2 )
X	backcolor = PBM_WHITE;
X    else
X	backcolor = PBM_BLACK;
X
X    /* Flood the entire edge.  Probably the first call will be enough, but
X    ** might as well be sure. */
X    for ( col = cols - 3; col >= 2; col -= 2 )
X	{
X	addflood( col, rows - 1 );
X	addflood( col, 0 );
X	}
X    for ( row = rows - 1; row >= 0; row -= 2 )
X	{
X	addflood( cols - 1, row );
X	addflood( 0, row );
X	}
X    flood( );
X
X    /* All done. */
X    pbm_writepbm( stdout, mask, cols, rows );
X
X    exit( 0 );
X    }
X
X#define FLOODSTACKSIZE 50000
Xshort fcols[FLOODSTACKSIZE], frows[FLOODSTACKSIZE];
Xint fstackp = 0;
X
Xaddflood( col, row )
Xint col, row;
X    {
X    if ( bits[row][col] == backcolor && mask[row][col] == PBM_BLACK )
X	{
X	if ( fstackp >= FLOODSTACKSIZE )
X	    pm_error( "flood stack overflow", 0,0,0,0,0 );
X	fcols[fstackp] = col;
X	frows[fstackp] = row;
X	fstackp++;
X	}
X    }
X
Xflood( )
X    {
X    register int col, row, c;
X
X    while ( fstackp > 0 )
X	{
X	fstackp--;
X	col = fcols[fstackp];
X	row = frows[fstackp];
X	if ( bits[row][col] == backcolor && mask[row][col] == PBM_BLACK )
X	    {
X	    mask[row][col] = PBM_WHITE;
X	    if ( row - 1 >= 0 )
X		addflood( col, row - 1 );
X	    if ( row + 1 < rows )
X		addflood( col, row + 1 );
X	    for ( c = col + 1; c < cols; c++ )
X		{
X		if ( bits[row][c] == backcolor && mask[row][c] == PBM_BLACK )
X		    {
X		    mask[row][c] = PBM_WHITE;
X		    if ( row - 1 >= 0 && ( bits[row - 1][c - 1] != backcolor || mask[row - 1][c - 1] != PBM_BLACK ) )
X			addflood( c, row - 1 );
X		    if ( row + 1 < rows && ( bits[row + 1][c - 1] != backcolor || mask[row + 1][c - 1] != PBM_BLACK ) )
X			addflood( c, row + 1 );
X		    }
X		else
X		    break;
X		}
X	    for ( c = col - 1; c >= 0; c-- )
X		{
X		if ( bits[row][c] == backcolor && mask[row][c] == PBM_BLACK )
X		    {
X		    mask[row][c] = PBM_WHITE;
X		    if ( row - 1 >= 0 && ( bits[row - 1][c + 1] != backcolor || mask[row - 1][c + 1] != PBM_BLACK ) )
X			addflood( c, row - 1 );
X		    if ( row + 1 < rows && ( bits[row + 1][c + 1] != backcolor || mask[row + 1][c + 1] != PBM_BLACK ) )
X			addflood( c, row + 1 );
X		    }
X		else
X		    break;
X		}
X	    }
X	}
X    }
SHAR_EOF
if test 3601 -ne "`wc -c < 'pbm/pbmmask.c'`"
then
	echo shar: error transmitting "'pbm/pbmmask.c'" '(should have been 3601 characters)'
fi
fi # end of overwriting check
if test ! -d 'pbm'
then
	echo shar: creating directory "'pbm'"
	mkdir 'pbm'
fi
echo shar: extracting "'pbm/pbmmask.1'" '(1934 characters)'
if test -f 'pbm/pbmmask.1'
then
	echo shar: will not over-write existing file "'pbm/pbmmask.1'"
else
sed 's/^X//' << \SHAR_EOF > 'pbm/pbmmask.1'
X.TH pbmmask 1 "08 August 1989"
X.SH NAME
Xpbmmask - create a mask bitmap from a regular bitmap
X.SH SYNOPSIS
Xpbmmask [pbmfile]
X.SH DESCRIPTION
XReads a portable bitmap as input.
XCreates a corresponding mask bitmap and writes it out.
X.PP
XThe color to be interpreted as "background" is determined automatically.
XRegardless of which color is background, the mask will be white where
Xthe background is and black where the figure is.
X.PP
XThis lets you do a masked paste like this, for objects with a black background:
X.nf
X    pbmmask obj > objmask
X    pbmpaste < dest -and objmask <x> <y> | pbmpaste -or obj <x> <y>
X.fi
XFor objects with a white background, you can either invert them or
Xadd a step:
X.nf
X    pbmmask obj > objmask
X    pnminvert objmask | pbmpaste -and obj 0 0 > blackback
X    pbmpaste < dest -and objmask <x> <y> | pbmpaste -or blackback <x> <y>
X.fi
XNote that this three-step version works for objects with black backgrounds
Xtoo, if you don't care about the wasted time.
X.PP
XYou can also use masks with graymaps and pixmaps, using the ppmarith tool.
XFor instance:
X.nf
X    ppmtopgm obj.ppm | pgmtopbm -threshold | pbmmask > objmask.pbm
X    ppmarith -multiply dest.ppm objmask.pbm > t1.ppm
X    pnminvert objmask.pbm | ppmarith -multiply obj.ppm - > t2.ppm
X    ppmarith -add t1.ppm t2.ppm
X.fi
XAn interesting variation on this is to pipe the mask through the ppmsmooth
Xscript before using it.  This makes the boundary between the two images less
Xsharp.
X.SH "SEE ALSO"
Xpbmpaste(1), pnminvert(1), pbm(5), ppmarith(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 1934 -ne "`wc -c < 'pbm/pbmmask.1'`"
then
	echo shar: error transmitting "'pbm/pbmmask.1'" '(should have been 1934 characters)'
fi
fi # end of overwriting check
if test ! -d 'pbm'
then
	echo shar: creating directory "'pbm'"
	mkdir 'pbm'
fi
echo shar: extracting "'pbm/pbmtobbnbg.c'" '(1846 characters)'
if test -f 'pbm/pbmtobbnbg.c'
then
	echo shar: will not over-write existing file "'pbm/pbmtobbnbg.c'"
else
sed 's/^X//' << \SHAR_EOF > 'pbm/pbmtobbnbg.c'
X/* pbmtobg.c - read a portable bitmap and produce BitGraph graphics
X**
X** Copyright 1989 by Mike Parker.
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
X#include "pbm.h"
X
Xint nco;
X
Xmain(ac,av)
Xint ac;
Xchar **av;
X{
X int rows;
X int cols;
X int format;
X bit *bitrow;
X int row;
X unsigned int sixteen;
X int i;
X unsigned int mask;
X int op;
X int x;
X int y;
X
X op = 3;
X switch (ac)
X  { case 1:
X       break;
X    case 2:
X       op = atoi(av[1]);
X       break;
X    case 3:
X       x = atoi(av[1]);
X       y = atoi(av[2]);
X       printf("\33:%d;%dm",x,y);
X       break;
X    case 4:
X       op = atoi(av[1]);
X       x = atoi(av[2]);
X       y = atoi(av[3]);
X       printf("\33:%d;%dm",x,y);
X       break;
X  }
X nco = 0;
X pbm_readpbminit(stdin,&cols,&rows,&format);
X printf("\33P:%d;%d;%ds\n",op,cols,rows);
X bitrow = pbm_allocrow(cols);
X for (row=0;row<rows;row++)
X  { pbm_readpbmrow(stdin,bitrow,cols,format);
X    sixteen = 0;
X    mask = 0x8000;
X    for (i=0;i<cols;i++)
X     { if (bitrow[i]==PBM_BLACK) sixteen |= mask;
X       mask >>= 1;
X       if (mask == 0)
X	{ mask = 0x8000;
X	  write16(sixteen);
X	  sixteen = 0;
X	}
X     }
X    if (mask != 0x8000)
X     { write16(sixteen);
X     }
X  }
X putchar('\n');
X exit(0);
X}
X
Xwrite16(sixteen)
Xunsigned int sixteen;
X{
X if (nco > 75)
X  { putchar('\n');
X    nco = 0;
X  }
X if (sixteen & 0xfc00)
X  { putchar(0100+(sixteen>>10));
X    nco ++;
X  }
X if (sixteen & 0xfff0)
X  { putchar(0100+((sixteen>>4)&0x3f));
X    nco ++;
X  }
X putchar(060+(sixteen&0xf));
X nco ++;
X}
SHAR_EOF
if test 1846 -ne "`wc -c < 'pbm/pbmtobbnbg.c'`"
then
	echo shar: error transmitting "'pbm/pbmtobbnbg.c'" '(should have been 1846 characters)'
fi
fi # end of overwriting check
if test ! -d 'pbm'
then
	echo shar: creating directory "'pbm'"
	mkdir 'pbm'
fi
echo shar: extracting "'pbm/pbmtobbnbg.1'" '(1009 characters)'
if test -f 'pbm/pbmtobbnbg.1'
then
	echo shar: will not over-write existing file "'pbm/pbmtobbnbg.1'"
else
sed 's/^X//' << \SHAR_EOF > 'pbm/pbmtobbnbg.1'
X.TH pbmtobg 1 "16 May 1989"
X.SH NAME
Xpbmtobg - convert a portable bitmap into BitGraph graphics
X.SH SYNOPSIS
Xpbmtobg [rasterop] [x y] < pbmfile
X.SH DESCRIPTION
XReads a portable bitmap as input.
XProduces BBN BitGraph terminal Display Pixel Data (DPD) sequence as output.
X.LP
XThe rasterop can be specified on the command line.  If this is omitted, 3
X(replace) will be used.  A position in (x,y) coordinates can also be
Xspecified.  If both are given, the rasterop comes first.  The portable bitmap
Xis always taken from the standard input.
X.LP
XNote that there is no bgtopbm tool.
X.SH "SEE ALSO"
Xpbm(5)
X.SH AUTHOR
XCopyright 1989 by Mike Parker.
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 1009 -ne "`wc -c < 'pbm/pbmtobbnbg.1'`"
then
	echo shar: error transmitting "'pbm/pbmtobbnbg.1'" '(should have been 1009 characters)'
fi
fi # end of overwriting check
if test ! -d 'pbm'
then
	echo shar: creating directory "'pbm'"
	mkdir 'pbm'
fi
echo shar: extracting "'pbm/pbmtomgr.c'" '(2233 characters)'
if test -f 'pbm/pbmtomgr.c'
then
	echo shar: will not over-write existing file "'pbm/pbmtomgr.c'"
else
sed 's/^X//' << \SHAR_EOF > 'pbm/pbmtomgr.c'
X/* pbmtomgr.c - read a portable bitmap and produce a MGR 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    int rows, cols, format, padright, row, col;
X
X    pm_progname = argv[0];
X
X    if ( argc > 2 )
X	pm_usage( "[pbmfile]" );
X
X    if ( argc == 2 )
X	ifd = pm_openr( argv[1] );
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    padright = ( ( cols + 7 ) / 8 ) * 8 - cols;
X
X    putinit( rows, cols );
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    pm_close( ifd );
X
X    putrest( );
X
X    exit( 0 );
X    }
X
X
Xunsigned char item;
Xint bitsperitem, bitshift;
X
Xputinit( rows, cols )
Xint rows, cols;
X    {
X    struct b_header head;
X
X    head.magic[0] = 'y';
X    head.magic[1] = 'z';
X    head.h_wide = ( ( cols >> 6 ) & 0x3f ) + ' ';
X    head.l_wide = ( cols & 0x3f ) + ' ';
X    head.h_high = ( ( rows >> 6 ) & 0x3f ) + ' ';
X    head.l_high = ( rows & 0x3f ) + ' ';
X    head.depth = ( 1 & 0x3f ) + ' ';
X    head._reserved = ' ';
X    fwrite( &head, sizeof(head), 1, stdout );
X
X    item = 0;
X    bitsperitem = 0;
X    bitshift = 7;
X    }
X
Xputbit( b )
Xbit b;
X    {
X    if ( bitsperitem == 8 )
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 = 7;
X    }
SHAR_EOF
if test 2233 -ne "`wc -c < 'pbm/pbmtomgr.c'`"
then
	echo shar: error transmitting "'pbm/pbmtomgr.c'" '(should have been 2233 characters)'
fi
fi # end of overwriting check
if test ! -d 'pbm'
then
	echo shar: creating directory "'pbm'"
	mkdir 'pbm'
fi
echo shar: extracting "'pbm/pbmtomgr.1'" '(664 characters)'
if test -f 'pbm/pbmtomgr.1'
then
	echo shar: will not over-write existing file "'pbm/pbmtomgr.1'"
else
sed 's/^X//' << \SHAR_EOF > 'pbm/pbmtomgr.1'
X.TH pbmtomgr 1 "24 January 1989"
X.SH NAME
Xpbmtomgr - convert a portable bitmap into a MGR bitmap
X.SH SYNOPSIS
Xpbmtomgr [pbmfile]
X.SH DESCRIPTION
XReads a portable bitmap as input.
XProduces a MGR bitmap as output.
X.SH "SEE ALSO"
Xmgrtopbm(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/pbmtomgr.1'`"
then
	echo shar: error transmitting "'pbm/pbmtomgr.1'" '(should have been 664 characters)'
fi
fi # end of overwriting check
#	End of shell archive
exit 0



More information about the Alt.sources mailing list