PBMPLUS, part 3 of 18
Jef Poskanzer
pokey at well.UUCP
Thu Sep 14 21:24:30 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/xwdtopbm.1
# pbm/pbmtoicon.c
# pbm/pbmtoicon.1
# pbm/pbmtoptx.c
# pbm/pbmtoptx.1
# pbm/pbmtorast.c
# pbm/pbmtorast.1
# pbm/pbmtoxbm.c
# pbm/pbmtoxbm.1
# pbm/pbmtox10bm.c
# pbm/pbmtox10bm.1
# pbm/pbmtoascii.c
# pbm/pbmtoascii.1
# pbm/pbmpaste.c
# pbm/pbmpaste.1
# pbm/g3topbm.c
# pbm/g3topbm.1
# This archive created: Thu Sep 14 03:43:26 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/xwdtopbm.1'" '(1144 characters)'
if test -f 'pbm/xwdtopbm.1'
then
echo shar: will not over-write existing file "'pbm/xwdtopbm.1'"
else
sed 's/^X//' << \SHAR_EOF > 'pbm/xwdtopbm.1'
X.TH xwdtopbm 1 "31 August 1988"
X.SH NAME
Xxwdtopbm - convert an X11 or X10 window dump file into a portable bitmap
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.PP
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 pnmcut to select the part you want.
X.PP
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), pbm(5), xwdtoppm(1), ppmtoxwd(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 1144 -ne "`wc -c < 'pbm/xwdtopbm.1'`"
then
echo shar: error transmitting "'pbm/xwdtopbm.1'" '(should have been 1144 characters)'
fi
fi # end of overwriting check
if test ! -d 'pbm'
then
echo shar: creating directory "'pbm'"
mkdir 'pbm'
fi
echo shar: extracting "'pbm/pbmtoicon.c'" '(2333 characters)'
if test -f 'pbm/pbmtoicon.c'
then
echo shar: will not over-write existing file "'pbm/pbmtoicon.c'"
else
sed 's/^X//' << \SHAR_EOF > 'pbm/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 register bit *bitrow, *bP;
X int rows, cols, format, pad, padleft, 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 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 pbm_readpbmrow( ifd, bitrow, cols, format );
X for ( col = 0; col < padleft; col++ )
X putbit( 0 );
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 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 == PBM_BLACK )
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 2333 -ne "`wc -c < 'pbm/pbmtoicon.c'`"
then
echo shar: error transmitting "'pbm/pbmtoicon.c'" '(should have been 2333 characters)'
fi
fi # end of overwriting check
if test ! -d 'pbm'
then
echo shar: creating directory "'pbm'"
mkdir 'pbm'
fi
echo shar: extracting "'pbm/pbmtoicon.1'" '(663 characters)'
if test -f 'pbm/pbmtoicon.1'
then
echo shar: will not over-write existing file "'pbm/pbmtoicon.1'"
else
sed 's/^X//' << \SHAR_EOF > 'pbm/pbmtoicon.1'
X.TH pbmtoicon 1 "31 August 1988"
X.SH NAME
Xpbmtoicon - convert a portable bitmap into a Sun icon
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 663 -ne "`wc -c < 'pbm/pbmtoicon.1'`"
then
echo shar: error transmitting "'pbm/pbmtoicon.1'" '(should have been 663 characters)'
fi
fi # end of overwriting check
if test ! -d 'pbm'
then
echo shar: creating directory "'pbm'"
mkdir 'pbm'
fi
echo shar: extracting "'pbm/pbmtoptx.c'" '(1749 characters)'
if test -f 'pbm/pbmtoptx.c'
then
echo shar: will not over-write existing file "'pbm/pbmtoptx.c'"
else
sed 's/^X//' << \SHAR_EOF > 'pbm/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 SYSV
X#include <string.h>
X#else SYSV
X#include <strings.h>
X#endif SYSV
X#include "pbm.h"
X
Xmain( argc, argv )
Xint argc;
Xchar *argv[];
X {
X FILE *ifd;
X register bit *bitrow, *bP;
X int rows, cols, format, row, col;
X char *usage = "[pbmfile]";
X
X pm_progname = argv[0];
X
X if ( argc > 2 )
X pm_usage( usage );
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 putinit( );
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 putrest( );
X putchar( 5 );
X putchar( '\n' );
X }
X
X pm_close( ifd );
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 == PBM_BLACK )
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 1749 -ne "`wc -c < 'pbm/pbmtoptx.c'`"
then
echo shar: error transmitting "'pbm/pbmtoptx.c'" '(should have been 1749 characters)'
fi
fi # end of overwriting check
if test ! -d 'pbm'
then
echo shar: creating directory "'pbm'"
mkdir 'pbm'
fi
echo shar: extracting "'pbm/pbmtoptx.1'" '(764 characters)'
if test -f 'pbm/pbmtoptx.1'
then
echo shar: will not over-write existing file "'pbm/pbmtoptx.1'"
else
sed 's/^X//' << \SHAR_EOF > 'pbm/pbmtoptx.1'
X.TH pbmtoptx 1 "31 August 1988"
X.SH NAME
Xpbmtoptx - convert a portable bitmap 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.PP
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 764 -ne "`wc -c < 'pbm/pbmtoptx.1'`"
then
echo shar: error transmitting "'pbm/pbmtoptx.1'" '(should have been 764 characters)'
fi
fi # end of overwriting check
if test ! -d 'pbm'
then
echo shar: creating directory "'pbm'"
mkdir 'pbm'
fi
echo shar: extracting "'pbm/pbmtorast.c'" '(2239 characters)'
if test -f 'pbm/pbmtorast.c'
then
echo shar: will not over-write existing file "'pbm/pbmtorast.c'"
else
sed 's/^X//' << \SHAR_EOF > 'pbm/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/* 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 register bit *bitrow, *bP;
X int argn, pr_type, linesize;
X int rows, cols, format, row, col;
X struct pixrect *pr;
X short *data, *sp;
X int bitcount;
X char *usage = "[-s] [pbmfile]";
X
X pm_progname = argv[0];
X
X argn = 1;
X pr_type = RT_BYTE_ENCODED;
X
X if ( argc - argn >= 1 && argv[argn][0] == '-' )
X {
X if ( ( argv[argn][1] == 's' || argv[argn][1] == 'S' ) &&
X argv[argn][2] == '\0' )
X {
X pr_type = RT_STANDARD;
X argn++;
X }
X else
X pm_usage( usage );
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 if ( (pr = mem_create(cols, rows, 1)) == NULL )
X pm_error( "unable to create new pixrect", 0,0,0,0,0 );
X
X data = ( (struct mpr_data *) pr->pr_data )->md_image;
X linesize = ( (struct mpr_data *) pr->pr_data )->md_linebytes;
X
X for ( row = 0; row < rows; row++ )
X {
X pbm_readpbmrow( ifd, bitrow, cols, format );
X sp = data;
X bitcount = 15;
X for ( col = 0, bP = bitrow; col < cols; col++, bP++ )
X {
X if ( *bP == PBM_BLACK )
X *sp |= 1 << bitcount;
X bitcount--;
X if ( bitcount < 0 )
X {
X sp++;
X bitcount = 15;
X }
X }
X data += linesize / sizeof(short);
X }
X
X pm_close( ifd );
X
X#ifdef sun386
X /* Force a flip to 80386 format. */
X ( (struct mpr_data *) pr->pr_data )->md_flags &= ! MP_I386;
X pr_flip( pr );
X#endif sun386
X
X pr_dump( pr, stdout, NULL, pr_type, 0 );
X
X exit( 0 );
X }
SHAR_EOF
if test 2239 -ne "`wc -c < 'pbm/pbmtorast.c'`"
then
echo shar: error transmitting "'pbm/pbmtorast.c'" '(should have been 2239 characters)'
fi
fi # end of overwriting check
if test ! -d 'pbm'
then
echo shar: creating directory "'pbm'"
mkdir 'pbm'
fi
echo shar: extracting "'pbm/pbmtorast.1'" '(1146 characters)'
if test -f 'pbm/pbmtorast.1'
then
echo shar: will not over-write existing file "'pbm/pbmtorast.1'"
else
sed 's/^X//' << \SHAR_EOF > 'pbm/pbmtorast.1'
X.TH pbmtorast 1 "19 November 1988"
X.SH NAME
Xpbmtorast - convert a portable bitmap into a Sun rasterfile
X.SH SYNOPSIS
Xpbmtorast [-s] [pbmfile]
X.SH DESCRIPTION
XReads a portable bitmap as input.
XProduces a Sun rasterfile as output.
XNOTE: since it uses Sun-specific include files and libraries, pbmtorast
Xwill compile only on Suns.
X.PP
XThe -s flag forces the result to be in RT_STANDARD form; otherwise,
Xit defaults to RT_BYTE_ENCODED, which is smaller but, well, less standard.
X.PP
XThe ppmtorast filter provides the same functionality as pbmtorast, in
Xaddition to handling color images; but pbmtorast is worth keeping, since
Xit is significantly faster.
X.SH "SEE ALSO"
Xrasttopbm(1), pbm(5), ppmtorast(1), rasttoppm(1)
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 1146 -ne "`wc -c < 'pbm/pbmtorast.1'`"
then
echo shar: error transmitting "'pbm/pbmtorast.1'" '(should have been 1146 characters)'
fi
fi # end of overwriting check
if test ! -d 'pbm'
then
echo shar: creating directory "'pbm'"
mkdir 'pbm'
fi
echo shar: extracting "'pbm/pbmtoxbm.c'" '(2576 characters)'
if test -f 'pbm/pbmtoxbm.c'
then
echo shar: will not over-write existing file "'pbm/pbmtoxbm.c'"
else
sed 's/^X//' << \SHAR_EOF > 'pbm/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 SYSV
X#include <string.h>
X#define index strchr
X#else SYSV
X#include <strings.h>
X#endif SYSV
X#include "pbm.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 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 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 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
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 == PBM_BLACK )
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 2576 -ne "`wc -c < 'pbm/pbmtoxbm.c'`"
then
echo shar: error transmitting "'pbm/pbmtoxbm.c'" '(should have been 2576 characters)'
fi
fi # end of overwriting check
if test ! -d 'pbm'
then
echo shar: creating directory "'pbm'"
mkdir 'pbm'
fi
echo shar: extracting "'pbm/pbmtoxbm.1'" '(680 characters)'
if test -f 'pbm/pbmtoxbm.1'
then
echo shar: will not over-write existing file "'pbm/pbmtoxbm.1'"
else
sed 's/^X//' << \SHAR_EOF > 'pbm/pbmtoxbm.1'
X.TH pbmtoxbm 1 "31 August 1988"
X.SH NAME
Xpbmtoxbm - convert a portable bitmap into an X11 bitmap
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 680 -ne "`wc -c < 'pbm/pbmtoxbm.1'`"
then
echo shar: error transmitting "'pbm/pbmtoxbm.1'" '(should have been 680 characters)'
fi
fi # end of overwriting check
if test ! -d 'pbm'
then
echo shar: creating directory "'pbm'"
mkdir 'pbm'
fi
echo shar: extracting "'pbm/pbmtox10bm.c'" '(2565 characters)'
if test -f 'pbm/pbmtox10bm.c'
then
echo shar: will not over-write existing file "'pbm/pbmtox10bm.c'"
else
sed 's/^X//' << \SHAR_EOF > 'pbm/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 SYSV
X#include <string.h>
X#define index strchr
X#else SYSV
X#include <strings.h>
X#endif SYSV
X#include "pbm.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 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 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 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
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 == PBM_BLACK )
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 2565 -ne "`wc -c < 'pbm/pbmtox10bm.c'`"
then
echo shar: error transmitting "'pbm/pbmtox10bm.c'" '(should have been 2565 characters)'
fi
fi # end of overwriting check
if test ! -d 'pbm'
then
echo shar: creating directory "'pbm'"
mkdir 'pbm'
fi
echo shar: extracting "'pbm/pbmtox10bm.1'" '(830 characters)'
if test -f 'pbm/pbmtox10bm.1'
then
echo shar: will not over-write existing file "'pbm/pbmtox10bm.1'"
else
sed 's/^X//' << \SHAR_EOF > 'pbm/pbmtox10bm.1'
X.TH pbmtox10bm 1 "31 August 1988"
X.SH NAME
Xpbmtox10bm - convert a portable bitmap into an X10 bitmap
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.PP
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 830 -ne "`wc -c < 'pbm/pbmtox10bm.1'`"
then
echo shar: error transmitting "'pbm/pbmtox10bm.1'" '(should have been 830 characters)'
fi
fi # end of overwriting check
if test ! -d 'pbm'
then
echo shar: creating directory "'pbm'"
mkdir 'pbm'
fi
echo shar: extracting "'pbm/pbmtoascii.c'" '(1598 characters)'
if test -f 'pbm/pbmtoascii.c'
then
echo shar: will not over-write existing file "'pbm/pbmtoascii.c'"
else
sed 's/^X//' << \SHAR_EOF > 'pbm/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 register bit **bits, *bP, *b1P;
X int rows, cols, row, col, lastcol;
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
X pm_close( 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] == PBM_BLACK )
X break;
X if ( row+1 < rows && bits[row+1][lastcol] == PBM_BLACK )
X break;
X }
X for ( col = 0, bP = bits[row], b1P = bits[row+1]; col <= lastcol; col++, bP++, b1P++ )
X {
X if ( *bP == PBM_WHITE )
X {
X if ( row+1 >= rows || *b1P == PBM_WHITE )
X putchar( ' ' );
X else
X putchar( 'o' );
X }
X else
X {
X if ( row+1 >= rows || *b1P == PBM_WHITE )
X putchar( '"' );
X else
X putchar( '$' );
X }
X }
X putchar( '\n' );
X }
X
X exit( 0 );
X }
SHAR_EOF
if test 1598 -ne "`wc -c < 'pbm/pbmtoascii.c'`"
then
echo shar: error transmitting "'pbm/pbmtoascii.c'" '(should have been 1598 characters)'
fi
fi # end of overwriting check
if test ! -d 'pbm'
then
echo shar: creating directory "'pbm'"
mkdir 'pbm'
fi
echo shar: extracting "'pbm/pbmtoascii.1'" '(752 characters)'
if test -f 'pbm/pbmtoascii.1'
then
echo shar: will not over-write existing file "'pbm/pbmtoascii.1'"
else
sed 's/^X//' << \SHAR_EOF > 'pbm/pbmtoascii.1'
X.TH pbmtoascii 1 "31 August 1988"
X.SH NAME
Xpbmtoascii - convert a portable bitmap 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.PP
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 752 -ne "`wc -c < 'pbm/pbmtoascii.1'`"
then
echo shar: error transmitting "'pbm/pbmtoascii.1'" '(should have been 752 characters)'
fi
fi # end of overwriting check
if test ! -d 'pbm'
then
echo shar: creating directory "'pbm'"
mkdir 'pbm'
fi
echo shar: extracting "'pbm/pbmpaste.c'" '(3670 characters)'
if test -f 'pbm/pbmpaste.c'
then
echo shar: will not over-write existing file "'pbm/pbmpaste.c'"
else
sed 's/^X//' << \SHAR_EOF > 'pbm/pbmpaste.c'
X/* pbmpaste.c - paste a rectangle into 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#ifdef SYSV
X#include <string.h>
X#else SYSV
X#include <strings.h>
X#endif SYSV
X#include "pbm.h"
X
X#define max(a,b) ((a) > (b) ? (a) : (b))
X
Xmain( argc, argv )
Xint argc;
Xchar *argv[];
X {
X FILE *ifd1, *ifd2;
X register bit *bitrow1, **bits2, *b1P, *b2P;
X int argn, rows1, cols1, format1, x, y, rows2, cols2, row, col;
X char function;
X char *usage = "[-replace|-or|-and|-xor] frompbmfile x y [intopbmfile]";
X
X pm_progname = argv[0];
X
X argn = 1;
X function = 'r';
X
X /* Check for flags. */
X if ( argn < argc && argv[argn][0] == '-' )
X {
X if ( strncmp(argv[argn],"-replace",max(strlen(argv[argn]),2)) == 0 )
X function = 'r';
X else if ( strncmp(argv[argn],"-or",max(strlen(argv[argn]),2)) == 0 )
X function = 'o';
X else if ( strncmp(argv[argn],"-and",max(strlen(argv[argn]),2)) == 0 )
X function = 'a';
X else if ( strncmp(argv[argn],"-xor",max(strlen(argv[argn]),2)) == 0 )
X function = 'x';
X else
X pm_usage( usage );
X argn++;
X }
X
X if ( argn == argc )
X pm_usage( usage );
X ifd1 = pm_openr( argv[argn] );
X pbm_readpbminit( ifd1, &cols1, &rows1, &format1 );
X bitrow1 = pbm_allocrow( cols1 );
X argn++;
X
X if ( argn == argc )
X pm_usage( usage );
X if ( sscanf( argv[argn], "%d", &x ) != 1 )
X pm_usage( usage );
X argn++;
X if ( argn == argc )
X pm_usage( usage );
X if ( sscanf( argv[argn], "%d", &y ) != 1 )
X pm_usage( usage );
X argn++;
X
X if ( argn == argc )
X ifd2 = stdin;
X else
X {
X ifd2 = pm_openr( argv[argn] );
X argn++;
X }
X bits2 = pbm_readpbm( ifd2, &cols2, &rows2 );
X pm_close( ifd2 );
X
X if ( x <= -cols2 )
X pm_error(
X "x is too negative -- the second bitmap has only %d cols",
X cols2, 0,0,0,0 );
X if ( y <= -rows2 )
X pm_error(
X "y is too negative -- the second bitmap has only %d rows",
X rows2, 0,0,0,0 );
X if ( x < 0 )
X x = cols2 - x;
X if ( y < 0 )
X y = rows2 - y;
X
X if ( x >= cols2 )
X pm_error(
X "x is too large -- the second bitmap has only %d cols",
X cols2, 0,0,0,0 );
X if ( y >= rows2 )
X pm_error(
X "y is too large -- the second bitmap has only %d rows",
X rows2, 0,0,0,0 );
X if ( x + cols1 > cols2 )
X pm_error(
X "x + width is too large by %d pixels", x + cols1 - cols2, 0,0,0,0 );
X if ( y + rows1 > rows2 )
X pm_error(
X "y + height is too large by %d pixels", y + rows1 - rows2, 0,0,0,0);
X
X if ( argn != argc )
X pm_usage( usage );
X
X for ( row = 0; row < rows1; row++ )
X {
X pbm_readpbmrow( ifd1, bitrow1, cols1, format1 );
X for ( col = 0, b1P = bitrow1, b2P = &(bits2[row+y][x]); col < cols1; col++, b1P++, b2P++ )
X switch ( function )
X {
X case 'r':
X *b2P = *b1P;
X break;
X
X case 'o':
X *b2P = ( *b1P == PBM_WHITE || *b2P == PBM_WHITE ?
X PBM_WHITE : PBM_BLACK );
X break;
X
X case 'a':
X *b2P = ( *b1P == PBM_WHITE && *b2P == PBM_WHITE ?
X PBM_WHITE : PBM_BLACK );
X break;
X
X case 'x':
X *b2P = ( ( *b1P == PBM_WHITE && *b2P != PBM_WHITE ) ||
X ( *b1P != PBM_WHITE && *b2P == PBM_WHITE ) ?
X PBM_WHITE : PBM_BLACK );
X break;
X
X default:
X pm_error( "can't happen", 0,0,0,0,0 );
X }
X }
X
X pm_close( ifd1 );
X
X pbm_writepbm( stdout, bits2, cols2, rows2 );
X
X exit( 0 );
X }
SHAR_EOF
if test 3670 -ne "`wc -c < 'pbm/pbmpaste.c'`"
then
echo shar: error transmitting "'pbm/pbmpaste.c'" '(should have been 3670 characters)'
fi
fi # end of overwriting check
if test ! -d 'pbm'
then
echo shar: creating directory "'pbm'"
mkdir 'pbm'
fi
echo shar: extracting "'pbm/pbmpaste.1'" '(1767 characters)'
if test -f 'pbm/pbmpaste.1'
then
echo shar: will not over-write existing file "'pbm/pbmpaste.1'"
else
sed 's/^X//' << \SHAR_EOF > 'pbm/pbmpaste.1'
X.TH pbmpaste 1 "08 August 1989"
X.SH NAME
Xpbmpaste - paste a rectangle into a portable bitmap
X.SH SYNOPSIS
Xpbmpaste [-replace|-or|-and|-xor] frompbmfile x y [intopbmfile]
X.SH DESCRIPTION
XReads two portable bitmaps as input.
XInserts the first bitmap into the second at the specified location,
Xand produces a portable bitmap the same size as the second as output.
XIf the second bitmap is not specified, it is read from stdin.
XThe x and y can be negative, in which case they are interpreted
Xrelative to the right and bottom of the bitmap, respectively.
X.PP
XThe flags specify the operation to use when doing the paste.
XThe default is replace.
XThe other operations act as if white is 1 and black is 0.
X.PP
XAll flags can be abbreviated to their shortest unique prefix.
X.PP
XThis tool is useful in combination with pnmcut(1).
XFor instance, if you want to edit a small segment of a large
Xbitmap, and your bitmap editor is TOO STUPID to edit the
Xlarge bitmap, you can cut out the segment you are interested in,
Xedit it, and then paste it back in.
X.PP
XAnother useful companion tool is pbmmask(1).
X.PP
XThe pnmpaste(1) tool is like this one, except that it doesn't implement
Xthe logical operation flags -- since they don't have any useful meaning
Xfor grayscale and color images.
X.SH "SEE ALSO"
Xpnmcut(1), pbmmask(1), pnminvert(1), ppmarith(1), pnmpaste(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 1767 -ne "`wc -c < 'pbm/pbmpaste.1'`"
then
echo shar: error transmitting "'pbm/pbmpaste.1'" '(should have been 1767 characters)'
fi
fi # end of overwriting check
if test ! -d 'pbm'
then
echo shar: creating directory "'pbm'"
mkdir 'pbm'
fi
echo shar: extracting "'pbm/g3topbm.c'" '(8332 characters)'
if test -f 'pbm/g3topbm.c'
then
echo shar: will not over-write existing file "'pbm/g3topbm.c'"
else
sed 's/^X//' << \SHAR_EOF > 'pbm/g3topbm.c'
X/* g3topbm.c - read a Group 3 FAX file and write 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
Xint eof;
X
Xmain( argc, argv )
Xint argc;
Xchar *argv[];
X {
X FILE *ifd;
X /* register bit **bits, *bP; */
X register bit *bitrow, *bP;
X bit getbit();
X int argn, rows, cols, row, col;
X
X pm_progname = argv[0];
X
X argn = 1;
X
X if ( argn < argc )
X {
X ifd = pm_openr( argv[argn] );
X argn++;
X }
X else
X ifd = stdin;
X
X if ( argn != argc )
X pm_usage( "[g3file]" );
X
X getinit( ifd, &cols, &rows );
X
X /* bits = pbm_allocarray( cols, rows ); */
X pbm_writepbminit( stdout, cols, rows );
X bitrow = pbm_allocrow( cols );
X
X for ( row = 0; row < rows; row++ )
X {
X getlineinit( );
X /* for ( col = 0, bP = bits[row]; col < cols; col++, bP++ ) */
X for ( col = 0, bP = bitrow; col < cols; col++, bP++ )
X *bP = getbit( ifd );
X pbm_writepbmrow( stdout, bitrow, cols );
X }
X
X pm_close( ifd );
X
X /* pbm_writepbm( stdout, bits, cols, rows ); */
X
X exit( 0 );
X }
X
X
Xbit data;
Xint eol, eols, count, item, bitsinitem;
Xint rawitem, rawbitsinitem, rawbitshift, rawzeros;
X
Xgetinit( file, colsP, rowsP )
XFILE *file;
Xint *colsP, *rowsP;
X {
X *colsP = 1728;
X *rowsP = 2236;
X eof = 0;
X eols = 0;
X }
X
Xgetlineinit( )
X {
X rawbitsinitem = 8;
X rawzeros = 0;
X eol = 0;
X data = 1;
X count = 0;
X }
X
Xbit
Xgetbit( file )
XFILE *file;
X {
X int i;
X bit b, rawgetbit( );
X struct tableentry {
X int code;
X int length;
X int count;
X };
X static struct tableentry twtable[] = {
X { 0x35, 8, 0 },
X { 0x7, 6, 1 },
X { 0x7, 4, 2 },
X { 0x8, 4, 3 },
X { 0xb, 4, 4 },
X { 0xc, 4, 5 },
X { 0xe, 4, 6 },
X { 0xf, 4, 7 },
X { 0x13, 5, 8 },
X { 0x14, 5, 9 },
X { 0x7, 5, 10 },
X { 0x8, 5, 11 },
X { 0x8, 6, 12 },
X { 0x3, 6, 13 },
X { 0x34, 6, 14 },
X { 0x35, 6, 15 },
X { 0x2a, 6, 16 },
X { 0x2b, 6, 17 },
X { 0x27, 7, 18 },
X { 0xc, 7, 19 },
X { 0x8, 7, 20 },
X { 0x17, 7, 21 },
X { 0x3, 7, 22 },
X { 0x4, 7, 23 },
X { 0x28, 7, 24 },
X { 0x2b, 7, 25 },
X { 0x13, 7, 26 },
X { 0x24, 7, 27 },
X { 0x18, 7, 28 },
X { 0x2, 8, 29 },
X { 0x3, 8, 30 },
X { 0x1a, 8, 31 },
X { 0x1b, 8, 32 },
X { 0x12, 8, 33 },
X { 0x13, 8, 34 },
X { 0x14, 8, 35 },
X { 0x15, 8, 36 },
X { 0x16, 8, 37 },
X { 0x17, 8, 38 },
X { 0x28, 8, 39 },
X { 0x29, 8, 40 },
X { 0x2a, 8, 41 },
X { 0x2b, 8, 42 },
X { 0x2c, 8, 43 },
X { 0x2d, 8, 44 },
X { 0x4, 8, 45 },
X { 0x5, 8, 46 },
X { 0xa, 8, 47 },
X { 0xb, 8, 48 },
X { 0x52, 8, 49 },
X { 0x53, 8, 50 },
X { 0x54, 8, 51 },
X { 0x55, 8, 52 },
X { 0x24, 8, 53 },
X { 0x25, 8, 54 },
X { 0x58, 8, 55 },
X { 0x59, 8, 56 },
X { 0x5a, 8, 57 },
X { 0x5b, 8, 58 },
X { 0x4a, 8, 59 },
X { 0x4b, 8, 60 },
X { 0x32, 8, 61 },
X { 0x33, 8, 62 },
X { 0x34, 8, 63 },
X };
X static struct tableentry mwtable[] = {
X { 0x1b, 5, 64 },
X { 0x12, 5, 128 },
X { 0x17, 6, 192 },
X { 0x37, 7, 256 },
X { 0x36, 8, 320 },
X { 0x37, 8, 384 },
X { 0x64, 8, 448 },
X { 0x65, 8, 512 },
X { 0x68, 8, 576 },
X { 0x67, 8, 640 },
X { 0xcc, 9, 704 },
X { 0xcd, 9, 768 },
X { 0xd2, 9, 832 },
X { 0xd3, 9, 896 },
X { 0xd4, 9, 960 },
X { 0xd5, 9, 1024 },
X { 0xd6, 9, 1088 },
X { 0xd7, 9, 1152 },
X { 0xd8, 9, 1216 },
X { 0xd9, 9, 1280 },
X { 0xda, 9, 1344 },
X { 0xdb, 9, 1408 },
X { 0x98, 9, 1472 },
X { 0x99, 9, 1536 },
X { 0x9a, 9, 1600 },
X { 0x18, 6, 1664 },
X { 0x9b, 9, 1728 },
X };
X static struct tableentry tbtable[] = {
X { 0x37, 10, 0 },
X { 0x2, 3, 1 },
X { 0x3, 2, 2 },
X { 0x2, 2, 3 },
X { 0x3, 3, 4 },
X { 0x3, 4, 5 },
X { 0x2, 4, 6 },
X { 0x3, 5, 7 },
X { 0x5, 6, 8 },
X { 0x4, 6, 9 },
X { 0x4, 7, 10 },
X { 0x5, 7, 11 },
X { 0x7, 7, 12 },
X { 0x4, 8, 13 },
X { 0x7, 8, 14 },
X { 0x18, 9, 15 },
X { 0x17, 10, 16 },
X { 0x18, 10, 17 },
X { 0x8, 10, 18 },
X { 0x67, 11, 19 },
X { 0x68, 11, 20 },
X { 0x6c, 11, 21 },
X { 0x37, 11, 22 },
X { 0x28, 11, 23 },
X { 0x17, 11, 24 },
X { 0x18, 11, 25 },
X { 0xca, 12, 26 },
X { 0xcb, 12, 27 },
X { 0xcc, 12, 28 },
X { 0xcd, 12, 29 },
X { 0x68, 12, 30 },
X { 0x69, 12, 31 },
X { 0x6a, 12, 32 },
X { 0x6b, 12, 33 },
X { 0xd2, 12, 34 },
X { 0xd3, 12, 35 },
X { 0xd4, 12, 36 },
X { 0xd5, 12, 37 },
X { 0xd6, 12, 38 },
X { 0xd7, 12, 39 },
X { 0x6c, 12, 40 },
X { 0x6d, 12, 41 },
X { 0xda, 12, 42 },
X { 0xdb, 12, 43 },
X { 0x54, 12, 44 },
X { 0x55, 12, 45 },
X { 0x56, 12, 46 },
X { 0x57, 12, 47 },
X { 0x64, 12, 48 },
X { 0x65, 12, 49 },
X { 0x52, 12, 50 },
X { 0x53, 12, 51 },
X { 0x24, 12, 52 },
X { 0x37, 12, 53 },
X { 0x38, 12, 54 },
X { 0x27, 12, 55 },
X { 0x28, 12, 56 },
X { 0x58, 12, 57 },
X { 0x59, 12, 58 },
X { 0x2b, 12, 59 },
X { 0x2c, 12, 60 },
X { 0x5a, 12, 61 },
X { 0x66, 12, 62 },
X { 0x67, 12, 63 },
X };
X static struct tableentry mbtable[] = {
X { 0xf, 10, 64 },
X { 0xc8, 12, 128 },
X { 0xc9, 12, 192 },
X { 0x5b, 12, 256 },
X { 0x33, 12, 320 },
X { 0x34, 12, 384 },
X { 0x35, 12, 448 },
X { 0x6c, 13, 512 },
X { 0x6d, 13, 576 },
X { 0x4a, 13, 640 },
X { 0x4b, 13, 704 },
X { 0x4c, 13, 768 },
X { 0x4d, 13, 832 },
X { 0x72, 13, 896 },
X { 0x73, 13, 960 },
X { 0x74, 13, 1024 },
X { 0x75, 13, 1088 },
X { 0x76, 13, 1152 },
X { 0x77, 13, 1216 },
X { 0x52, 13, 1280 },
X { 0x53, 13, 1344 },
X { 0x54, 13, 1408 },
X { 0x55, 13, 1472 },
X { 0x5a, 13, 1536 },
X { 0x5b, 13, 1600 },
X { 0x64, 13, 1664 },
X { 0x65, 13, 1728 },
X };
X static struct tableentry embtable[] = {
X { 0x8, 11, 1792 },
X { 0xc, 11, 1856 },
X { 0xd, 11, 1920 },
X { 0x12, 12, 1984 },
X { 0x13, 12, 2048 },
X { 0x14, 12, 2112 },
X { 0x15, 12, 2176 },
X { 0x16, 12, 2240 },
X { 0x17, 12, 2304 },
X { 0x1c, 12, 2368 },
X { 0x1d, 12, 2432 },
X { 0x1e, 12, 2496 },
X { 0x1f, 12, 2560 },
X };
X
X while ( count == 0 && ! eol && ! eof )
X {
X data = 1 - data;
Xmakeup:
X item = 0;
X for ( bitsinitem = 1; bitsinitem <= ( data ? 13 : 9 ); bitsinitem++ )
X {
X /* Get bit and check for EOL. */
X if ( rawzeros >= 11 && ( b = rawgetbit( file ) ) )
X {
X eol = 1;
X eols++;
X if ( eols >= 6 )
X eof = 1;
X goto continuewhile;
X }
X else
X b = rawgetbit( file );
X item = item * 2 + rawgetbit( file );
X /* Check tables. */
X if ( data )
X { /* Black. */
X for ( i = 0;
X i < sizeof( tbtable ) / sizeof( struct tableentry );
X i++ )
X if ( bitsinitem == tbtable[i].length &&
X item == tbtable[i].code )
X {
X count += tbtable[i].count;
X eols = 0;
X goto continuewhile;
X }
X for ( i = 0;
X i < sizeof( mbtable ) / sizeof( struct tableentry );
X i++ )
X if ( bitsinitem == mbtable[i].length &&
X item == mbtable[i].code )
X {
X count += mbtable[i].count;
X eols = 0;
X goto makeup;
X }
X for ( i = 0;
X i < sizeof( embtable ) / sizeof( struct tableentry );
X i++ )
X if ( bitsinitem == embtable[i].length &&
X item == embtable[i].code )
X {
X count += embtable[i].count;
X eols = 0;
X goto makeup;
X }
X }
X else
X { /* White. */
X for ( i = 0;
X i < sizeof( twtable ) / sizeof( struct tableentry );
X i++ )
X if ( bitsinitem == twtable[i].length &&
X item == twtable[i].code )
X {
X count += twtable[i].count;
X eols = 0;
X goto continuewhile;
X }
X for ( i = 0;
X i < sizeof( mwtable ) / sizeof( struct tableentry );
X i++ )
X if ( bitsinitem == mwtable[i].length &&
X item == mwtable[i].code )
X {
X count += mwtable[i].count;
X eols = 0;
X goto makeup;
X }
X }
X }
X /* Unrecognized code. Skip to EOL. */
X fprintf( stderr, "g3topbm: unrecognized code - skipping to EOL\n" );
X while ( rawzeros < 11 )
X b = rawgetbit( file );
X do
X {
X b = rawgetbit( file );
X }
X while ( ! b );
X eol = 1;
X eols++;
X if ( eols >= 6 )
X eof = 1;
X
Xcontinuewhile:
X ;
X }
X
X /* And return result. */
X if ( eol || eof )
X return 0;
X else
X {
X count--;
X return data;
X }
X }
X
Xbit
Xrawgetbit( file )
XFILE *file;
X {
X bit b;
X
X if ( rawbitsinitem == 8 )
X {
X rawitem = getc( file );
X if ( rawitem == EOF )
X pm_error( "premature EOF", 0,0,0,0,0 );
X rawbitsinitem = 0;
X rawbitshift = 7;
X }
X rawbitsinitem++;
X b = ( ( rawitem >> rawbitshift) & 1 ) ? PBM_BLACK : PBM_WHITE;
X rawbitshift--;
X if ( b )
X rawzeros = 0;
X else
X rawzeros++;
X return b;
X }
SHAR_EOF
if test 8332 -ne "`wc -c < 'pbm/g3topbm.c'`"
then
echo shar: error transmitting "'pbm/g3topbm.c'" '(should have been 8332 characters)'
fi
fi # end of overwriting check
if test ! -d 'pbm'
then
echo shar: creating directory "'pbm'"
mkdir 'pbm'
fi
echo shar: extracting "'pbm/g3topbm.1'" '(811 characters)'
if test -f 'pbm/g3topbm.1'
then
echo shar: will not over-write existing file "'pbm/g3topbm.1'"
else
sed 's/^X//' << \SHAR_EOF > 'pbm/g3topbm.1'
X.TH g3topbm 1 "06 September 1989"
X.SH NAME
Xg3topbm - convert a Group 3 FAX file into a portable bitmap
X.SH SYNOPSIS
Xg3topbm [g3file]
X.SH DESCRIPTION
XReads a Group 3 FAX file as input.
XProduces a portable bitmap as output.
X.PP
XThe standard for Group 3 FAX is defined in CCITT Recommendation T.4.
X.PP
XNote that there is currently no pbmtog3 tool.
X.SH BUGS
XDoesn't work yet.
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 811 -ne "`wc -c < 'pbm/g3topbm.1'`"
then
echo shar: error transmitting "'pbm/g3topbm.1'" '(should have been 811 characters)'
fi
fi # end of overwriting check
# End of shell archive
exit 0
More information about the Alt.sources
mailing list