Portable Bitmap Package, part 2 of 3.
Jef Poskanzer
pokey at well.UUCP
Fri Feb 12 04:22:22 AEST 1988
#! /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:
# xbmtopbm.c
# xbmtopbm.man
# pbmtocbm.c
# pbmtocbm.man
# pbmtoicon.c
# pbmtoicon.man
# pbmtops.c
# pbmtops.man
# pbmtoptx.c
# pbmtoptx.man
# pbmtoraster.c
# pbmtoraster.man
# pbmtoxbm.c
# pbmtoxbm.man
# pbmtox10bm.c
# pbmtox10bm.man
# This archive created: Wed Feb 10 03:53:54 1988
# By: Jef Poskanzer
export PATH; PATH=/bin:$PATH
echo shar: extracting "'xbmtopbm.c'" '(3506 characters)'
if test -f 'xbmtopbm.c'
then
echo shar: will not over-write existing file "'xbmtopbm.c'"
else
sed 's/^X//' << \SHAR_EOF > 'xbmtopbm.c'
X/* xbmtopbm.c - read an X bitmap file and produce a portable bitmap
X*/
X
X#include <stdio.h>
X#include <sys/types.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, charcount;
X char *data, mask;
X
X if ( argc > 2 )
X {
X fprintf( stderr, "usage: %s [bitmapfile]\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 if ( ReadBitmapFile( ifd, &cols, &rows, &data ) < 0 )
X {
X fprintf( stderr, "%s: can't load.\n", argv[1] );
X exit( 1 );
X }
X
X if ( ifd != stdin )
X fclose( ifd );
X
X bits = pbm_allocarray( cols, rows );
X
X for ( row = 0; row < rows; row++ )
X {
X charcount = 0;
X mask = 1;
X for ( col = 0; col < cols; col++ )
X {
X if ( charcount >= 8 )
X {
X data++;
X charcount = 0;
X mask = 1;
X }
X bits[row][col] = ( *data & mask ) ? 1 : 0;
X charcount++;
X mask = mask << 1;
X }
X data++;
X }
X
X pbm_writepbm( stdout, bits, cols, rows );
X
X exit( 0 );
X }
X
X
X#ifdef OS_SYSV
X#include <string.h>
X#else OS_SYSV
X#include <strings.h>
X#endif OS_SYSV
X
X#define MAX_LINE 81
X
Xint
XReadBitmapFile( stream, widthP, heightP, dataP )
XFILE *stream;
Xint *widthP, *heightP;
Xchar **dataP;
X {
X char line[MAX_LINE], name_and_type[MAX_LINE];
X char *ptr, *t;
X int bytes, bytes_per_line, value, version10p, raster_length, padding;
X
X *widthP = *heightP = -1;
X
X for ( ; ; )
X {
X if ( ! fgets( line, MAX_LINE, stream ) )
X break;
X if ( strlen( line ) == MAX_LINE - 1 )
X {
X fprintf( stderr, "Line too long.\n" );
X return ( -1 );
X }
X
X if (sscanf(line, "#define %s %d", name_and_type, &value) == 2)
X {
X if ( ! (t = rindex( name_and_type, '_' )) )
X t = name_and_type;
X else
X t++;
X if ( ! strcmp( "width", t ) )
X *widthP = value;
X if ( ! strcmp( "height", t ) )
X *heightP = value;
X continue;
X }
X
X if ( sscanf( line, "static short %s = {", name_and_type ) == 1 )
X {
X version10p = 1;
X break;
X }
X else if ( sscanf( line, "static char %s = {", name_and_type ) == 1 )
X {
X version10p = 0;
X break;
X }
X else
X continue;
X }
X
X if ( ! (t = rindex( name_and_type, '_' )) )
X t = name_and_type;
X else
X t++;
X
X if ( *widthP == -1 )
X {
X fprintf( stderr, "Invalid width.\n" );
X return ( -1 );
X }
X if ( *heightP == -1 )
X {
X fprintf( stderr, "Invalid height.\n" );
X return ( -1 );
X }
X
X padding = 0;
X if ( ((*widthP % 16) >= 1) && ((*widthP % 16) <= 8) && version10p )
X padding = 1;
X
X bytes_per_line = (*widthP+7)/8 + padding;
X
X raster_length = bytes_per_line * *heightP;
X *dataP = (char *) malloc( raster_length );
X if ( ! *dataP )
X {
X fprintf( stderr, "Not enough memory.\n" );
X return ( -1 );
X }
X
X if ( version10p )
X for ( bytes = 0, ptr = *dataP; bytes < raster_length; bytes += 2 )
X {
X if ( fscanf( stream, " 0x%x%*[,}]%*[ \n]", &value ) != 1 )
X {
X fprintf( stderr, "Error scanning bits item.\n" );
X return ( -1 );
X }
X *(ptr++) = value & 0xff;
X if ( (! padding) || ((bytes+2) % bytes_per_line) )
X *(ptr++) = value >> 8;
X }
X else
X for ( bytes = 0, ptr = *dataP; bytes < raster_length; bytes++ )
X {
X if ( fscanf( stream, " 0x%x%*[,}]%*[ \n]", &value ) != 1 )
X {
X fprintf( stderr, "Error scanning bits item.\n" );
X return ( -1 );
X }
X *(ptr++) = value;
X }
X
X return ( 0 );
X }
SHAR_EOF
if test 3506 -ne "`wc -c < 'xbmtopbm.c'`"
then
echo shar: error transmitting "'xbmtopbm.c'" '(should have been 3506 characters)'
fi
fi # end of overwriting check
echo shar: extracting "'xbmtopbm.man'" '(548 characters)'
if test -f 'xbmtopbm.man'
then
echo shar: will not over-write existing file "'xbmtopbm.man'"
else
sed 's/^X//' << \SHAR_EOF > 'xbmtopbm.man'
X.TH xbmtopbm 1 "08 February 1988" "PBM"
X.SH NAME
Xxbmtopbm \- convert X11 and X10 bitmaps into portable bitmaps
X.SH SYNOPSIS
Xxbmtopbm \%[bitmapfile]
X.SH DESCRIPTION
XReads an X11 or X10 bitmap as input.
XProduces a portable bitmap as output.
X.SH "SEE\ ALSO"
Xcbmtopbm(1), icontopbm(1), macpainttopbm(1), rastertopbm(1), xbmtopbm(1),
Xpbmtocbm(1), pbmtomacpaint(1), pbmtops(1), pbmtoptx(1), pbmtoraster(1),
Xpbmtoxbm(1), pbmtox10bm(1), pbmtoascii(1), pbminvert(1), pbmfliplr(1),
Xpbmfliptb(1), pbmcatlr(1), pbmcattb(1), pbmcrop(1)
X.SH AUTHOR
XJef Poskanzer
SHAR_EOF
if test 548 -ne "`wc -c < 'xbmtopbm.man'`"
then
echo shar: error transmitting "'xbmtopbm.man'" '(should have been 548 characters)'
fi
fi # end of overwriting check
echo shar: extracting "'pbmtocbm.c'" '(1424 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
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 putchar( (char) 42 );
X putchar( (char) 23 );
X putchar( (char) ( ( cols >> 8 ) & 0xff ) );
X putchar( (char) ( cols & 0xff ) );
X putchar( (char) ( ( rows >> 8 ) & 0xff ) );
X putchar( (char) ( rows & 0xff ) );
X
X putinit( );
X for ( row = 0; row < rows; row++ )
X for ( col = 0; col < cols; col++ )
X putbit( bits[row][col] );
X putrest( );
X
X exit( 0 );
X }
X
X
Xint item, bitsperitem, bitshift;
X
Xputinit( )
X {
X bitsperitem = 0;
X item = 0;
X bitshift = 7;
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 }
X
Xputitem( )
X {
X putchar( (char) item );
X bitsperitem = 0;
X item = 0;
X bitshift = 7;
X }
SHAR_EOF
if test 1424 -ne "`wc -c < 'pbmtocbm.c'`"
then
echo shar: error transmitting "'pbmtocbm.c'" '(should have been 1424 characters)'
fi
fi # end of overwriting check
echo shar: extracting "'pbmtocbm.man'" '(537 characters)'
if test -f 'pbmtocbm.man'
then
echo shar: will not over-write existing file "'pbmtocbm.man'"
else
sed 's/^X//' << \SHAR_EOF > 'pbmtocbm.man'
X.TH pbmtocbm 1 "08 February 1988" "PBM"
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), icontopbm(1), macpainttopbm(1), rastertopbm(1), xbmtopbm(1),
Xpbmtocbm(1), pbmtomacpaint(1), pbmtops(1), pbmtoptx(1), pbmtoraster(1),
Xpbmtoxbm(1), pbmtox10bm(1), pbmtoascii(1), pbminvert(1), pbmfliplr(1),
Xpbmfliptb(1), pbmcatlr(1), pbmcattb(1), pbmcrop(1)
X.SH AUTHOR
XJef Poskanzer
SHAR_EOF
if test 537 -ne "`wc -c < 'pbmtocbm.man'`"
then
echo shar: error transmitting "'pbmtocbm.man'" '(should have been 537 characters)'
fi
fi # end of overwriting check
echo shar: extracting "'pbmtoicon.c'" '(1963 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
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, rucols, 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 rucols = ( cols + 15 ) / 16;
X rucols = rucols * 16;
X padleft = ( rucols - cols ) / 2;
X padright = rucols - cols - padleft;
X
X printf( "/* Format_version=1, Width=%d, Height=%d", rucols, 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, itemsperline, firstitem;
X
Xputinit( )
X {
X itemsperline = 0;
X bitsperitem = 0;
X item = 0;
X firstitem = 1;
X }
X
Xputbit( b )
Xbit b;
X {
X if ( bitsperitem == 16 )
X putitem( );
X bitsperitem++;
X item = ( item * 2 ) + (int) b;
X }
X
Xputrest( )
X {
X int i;
X
X for ( i = bitsperitem; i < 16; i++ )
X item = item * 2;
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 }
SHAR_EOF
if test 1963 -ne "`wc -c < 'pbmtoicon.c'`"
then
echo shar: error transmitting "'pbmtoicon.c'" '(should have been 1963 characters)'
fi
fi # end of overwriting check
echo shar: extracting "'pbmtoicon.man'" '(527 characters)'
if test -f 'pbmtoicon.man'
then
echo shar: will not over-write existing file "'pbmtoicon.man'"
else
sed 's/^X//' << \SHAR_EOF > 'pbmtoicon.man'
X.TH pbmicon 1 "08 February 1988" "PBM"
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"
Xcbmtopbm(1), icontopbm(1), macpainttopbm(1), rastertopbm(1), xbmtopbm(1),
Xpbmtocbm(1), pbmtomacpaint(1), pbmtops(1), pbmtoptx(1), pbmtoraster(1),
Xpbmtoxbm(1), pbmtox10bm(1), pbmtoascii(1), pbminvert(1), pbmfliplr(1),
Xpbmfliptb(1), pbmcatlr(1), pbmcattb(1), pbmcrop(1)
X.SH AUTHOR
XJef Poskanzer
SHAR_EOF
if test 527 -ne "`wc -c < 'pbmtoicon.man'`"
then
echo shar: error transmitting "'pbmtoicon.man'" '(should have been 527 characters)'
fi
fi # end of overwriting check
echo shar: extracting "'pbmtops.c'" '(2996 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
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, rucols, padright, row, col;
X char ch;
X float scale;
X char *usage = "usage: %s [-s scale] [pbmfile]\n";
X
X argn = 1;
X scale = 1.0;
X
X /* Check for flags. */
X if ( argc > argn )
X {
X if ( argv[argn][0] == '-' )
X {
X if ( strcmp( argv[argn], "-s" ) == 0 )
X {
X if ( argc == argn + 1 )
X {
X fprintf( stderr, usage, argv[0] );
X exit( 1 );
X }
X if ( sscanf( argv[argn+1], "%f", &scale ) != 1 )
X {
X fprintf( stderr, usage, argv[0] );
X exit( 1 );
X }
X argn += 2;
X }
X else
X {
X fprintf( stderr, usage, argv[0] );
X exit( 1 );
X }
X }
X }
X
X if ( argc > argn + 1 )
X {
X fprintf( stderr, usage, argv[0] );
X exit( 1 );
X }
X
X if ( argc == argn + 1 )
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 }
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 8. */
X rucols = ( cols + 7 ) / 8;
X rucols = rucols * 8;
X padright = rucols - cols;
X
X putinit( 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, itemsperline, firstitem;
X
Xputinit( cols, rows, scale )
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(
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( "%d %d 1\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( "{ <\n" );
X
X itemsperline = 0;
X item = 0;
X bitsperitem = 0;
X bitshift = 7;
X firstitem = 1;
X }
X
Xputbit( b )
Xbit b;
X {
X if ( bitsperitem == 8 )
X {
X putitem( );
X item = 0;
X bitsperitem = 0;
X bitshift = 7;
X }
X if ( ! b )
X item += 1 << bitshift;
X bitsperitem++;
X bitshift--;
X }
X
Xputrest( )
X {
X if ( bitsperitem > 0 )
X putitem( );
X printf( "\n> }\nimage\nshowpage\n" );
X }
X
Xputitem( )
X {
X if ( firstitem )
X firstitem = 0;
X else
X putchar( ' ' );
X if ( itemsperline == 20 )
X {
X putchar( '\n' );
X itemsperline = 0;
X }
X if ( itemsperline == 0 )
X printf( " " );
X itemsperline++;
X printf( "%02x", item );
X }
SHAR_EOF
if test 2996 -ne "`wc -c < 'pbmtops.c'`"
then
echo shar: error transmitting "'pbmtops.c'" '(should have been 2996 characters)'
fi
fi # end of overwriting check
echo shar: extracting "'pbmtops.man'" '(592 characters)'
if test -f 'pbmtops.man'
then
echo shar: will not over-write existing file "'pbmtops.man'"
else
sed 's/^X//' << \SHAR_EOF > 'pbmtops.man'
X.TH pbmtops 1 "08 February 1988" "PBM"
X.SH NAME
Xpbmtops \- convert portable bitmaps into PostScript
X.SH SYNOPSIS
Xpbmtops \%[pbmfile]
X.SH DESCRIPTION
XReads a portable bitmap as input.
XProduces PostScript as output.
XNote that there is no
Xpstopbm
Xtool - this transformation is one-way.
X.SH "SEE\ ALSO"
Xcbmtopbm(1), icontopbm(1), macpainttopbm(1), rastertopbm(1), xbmtopbm(1),
Xpbmtocbm(1), pbmtomacpaint(1), pbmtops(1), pbmtoptx(1), pbmtoraster(1),
Xpbmtoxbm(1), pbmtox10bm(1), pbmtoascii(1), pbminvert(1), pbmfliplr(1),
Xpbmfliptb(1), pbmcatlr(1), pbmcattb(1), pbmcrop(1)
X.SH AUTHOR
XJef Poskanzer
SHAR_EOF
if test 592 -ne "`wc -c < 'pbmtops.man'`"
then
echo shar: error transmitting "'pbmtops.man'" '(should have been 592 characters)'
fi
fi # end of overwriting check
echo shar: extracting "'pbmtoptx.c'" '(1361 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
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 1361 -ne "`wc -c < 'pbmtoptx.c'`"
then
echo shar: error transmitting "'pbmtoptx.c'" '(should have been 1361 characters)'
fi
fi # end of overwriting check
echo shar: extracting "'pbmtoptx.man'" '(640 characters)'
if test -f 'pbmtoptx.man'
then
echo shar: will not over-write existing file "'pbmtoptx.man'"
else
sed 's/^X//' << \SHAR_EOF > 'pbmtoptx.man'
X.TH pbmtoptx 1 "08 February 1988" "PBM"
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.
XNote that there is no
Xptxtopbm
Xtool - this transformation is one way.
X.SH "SEE\ ALSO"
Xcbmtopbm(1), icontopbm(1), macpainttopbm(1), rastertopbm(1), xbmtopbm(1),
Xpbmtocbm(1), pbmtomacpaint(1), pbmtops(1), pbmtoptx(1), pbmtoraster(1),
Xpbmtoxbm(1), pbmtox10bm(1), pbmtoascii(1), pbminvert(1), pbmfliplr(1),
Xpbmfliptb(1), pbmcatlr(1), pbmcattb(1), pbmcrop(1)
X.SH AUTHOR
XJef Poskanzer
SHAR_EOF
if test 640 -ne "`wc -c < 'pbmtoptx.man'`"
then
echo shar: error transmitting "'pbmtoptx.man'" '(should have been 640 characters)'
fi
fi # end of overwriting check
echo shar: extracting "'pbmtoraster.c'" '(1338 characters)'
if test -f 'pbmtoraster.c'
then
echo shar: will not over-write existing file "'pbmtoraster.c'"
else
sed 's/^X//' << \SHAR_EOF > 'pbmtoraster.c'
X/* pbmtoraster.c - read a portable bitmap and produce a Sun rasterfile
X*/
X
X#include <pixrect/pixrect_hs.h>
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 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_STANDARD, 0 );
X
X exit( 0 );
X }
SHAR_EOF
if test 1338 -ne "`wc -c < 'pbmtoraster.c'`"
then
echo shar: error transmitting "'pbmtoraster.c'" '(should have been 1338 characters)'
fi
fi # end of overwriting check
echo shar: extracting "'pbmtoraster.man'" '(543 characters)'
if test -f 'pbmtoraster.man'
then
echo shar: will not over-write existing file "'pbmtoraster.man'"
else
sed 's/^X//' << \SHAR_EOF > 'pbmtoraster.man'
X.TH pbmtoraster 1 "08 February 1988" "PBM"
X.SH NAME
Xpbmtoraster \- convert portable bitmaps into Sun rasters
X.SH SYNOPSIS
Xpbmtoraster \%[pbmfile]
X.SH DESCRIPTION
XReads a portable bitmap as input.
XProduces a Sun raster file as output.
X.SH "SEE\ ALSO"
Xcbmtopbm(1), icontopbm(1), macpainttopbm(1), rastertopbm(1), xbmtopbm(1),
Xpbmtocbm(1), pbmtomacpaint(1), pbmtops(1), pbmtoptx(1), pbmtoraster(1),
Xpbmtoxbm(1), pbmtox10bm(1), pbmtoascii(1), pbminvert(1), pbmfliplr(1),
Xpbmfliptb(1), pbmcatlr(1), pbmcattb(1), pbmcrop(1)
X.SH AUTHOR
XBarry Klawans
SHAR_EOF
if test 543 -ne "`wc -c < 'pbmtoraster.man'`"
then
echo shar: error transmitting "'pbmtoraster.man'" '(should have been 543 characters)'
fi
fi # end of overwriting check
echo shar: extracting "'pbmtoxbm.c'" '(2191 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
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, rucols, 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#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 /* Round cols up to the nearest multiple of 8. */
X rucols = ( cols + 7 ) / 8;
X rucols = rucols * 8;
X padright = rucols - 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 == 12 )
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 2191 -ne "`wc -c < 'pbmtoxbm.c'`"
then
echo shar: error transmitting "'pbmtoxbm.c'" '(should have been 2191 characters)'
fi
fi # end of overwriting check
echo shar: extracting "'pbmtoxbm.man'" '(530 characters)'
if test -f 'pbmtoxbm.man'
then
echo shar: will not over-write existing file "'pbmtoxbm.man'"
else
sed 's/^X//' << \SHAR_EOF > 'pbmtoxbm.man'
X.TH pbmtoxbm 1 "08 February 1988" "PBM"
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"
Xcbmtopbm(1), icontopbm(1), macpainttopbm(1), rastertopbm(1), xbmtopbm(1),
Xpbmtocbm(1), pbmtomacpaint(1), pbmtops(1), pbmtoptx(1), pbmtoraster(1),
Xpbmtoxbm(1), pbmtox10bm(1), pbmtoascii(1), pbminvert(1), pbmfliplr(1),
Xpbmfliptb(1), pbmcatlr(1), pbmcattb(1), pbmcrop(1)
X.SH AUTHOR
XJef Poskanzer
SHAR_EOF
if test 530 -ne "`wc -c < 'pbmtoxbm.man'`"
then
echo shar: error transmitting "'pbmtoxbm.man'" '(should have been 530 characters)'
fi
fi # end of overwriting check
echo shar: extracting "'pbmtox10bm.c'" '(2198 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/* pbmtoxbm10.c - read a portable bitmap and produce an X10 bitmap file
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, rucols, 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#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 /* Round cols up to the nearest multiple of 16. */
X rucols = ( cols + 15 ) / 16;
X rucols = rucols * 16;
X padright = rucols - 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 == 8 )
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 2198 -ne "`wc -c < 'pbmtox10bm.c'`"
then
echo shar: error transmitting "'pbmtox10bm.c'" '(should have been 2198 characters)'
fi
fi # end of overwriting check
echo shar: extracting "'pbmtox10bm.man'" '(676 characters)'
if test -f 'pbmtox10bm.man'
then
echo shar: will not over-write existing file "'pbmtox10bm.man'"
else
sed 's/^X//' << \SHAR_EOF > 'pbmtox10bm.man'
X.TH pbmtox10bm 1 "08 February 1988" "PBM"
X.SH NAME
Xpbmtox10bm \- convert portable bitmaps into X10 bitmaps
X.SH SYNOPSIS
Xpbmtoxbm \%[pbmfile]
X.SH DESCRIPTION
XReads a portable bitmap as input.
XProduces an X10 bitmap as output.
XThis older format is maintained for compatibility.
XNote that there is no
Xx10bmtopbm
Xtool, because
Xxbmtopbm
Xcan read both X11 and X10 bitmaps.
X.SH "SEE\ ALSO"
Xcbmtopbm(1), icontopbm(1), macpainttopbm(1), rastertopbm(1), xbmtopbm(1),
Xpbmtocbm(1), pbmtomacpaint(1), pbmtops(1), pbmtoptx(1), pbmtoraster(1),
Xpbmtoxbm(1), pbmtox10bm(1), pbmtoascii(1), pbminvert(1), pbmfliplr(1),
Xpbmfliptb(1), pbmcatlr(1), pbmcattb(1), pbmcrop(1)
X.SH AUTHOR
XJef Poskanzer
SHAR_EOF
if test 676 -ne "`wc -c < 'pbmtox10bm.man'`"
then
echo shar: error transmitting "'pbmtox10bm.man'" '(should have been 676 characters)'
fi
fi # end of overwriting check
# End of shell archive
exit 0
More information about the Alt.sources
mailing list