PBMPLUS, part 6 of 18
Jef Poskanzer
pokey at well.UUCP
Thu Sep 14 21:24:54 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/pcxtopbm.1
# pbm/pbmupc.c
# pbm/pbmupc.1
# pbm/tifftopbm.c
# pbm/tifftopbm.1
# pbm/mgr.h
# pbm/mgrtopbm.c
# pbm/mgrtopbm.1
# This archive created: Thu Sep 14 03:43:32 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/pcxtopbm.1'" '(889 characters)'
if test -f 'pbm/pcxtopbm.1'
then
echo shar: will not over-write existing file "'pbm/pcxtopbm.1'"
else
sed 's/^X//' << \SHAR_EOF > 'pbm/pcxtopbm.1'
X.TH pcxtopbm 1 "11 December 1988"
X.SH NAME
Xpcxtopbm - convert a PC paintbrush (.pcx) file into a portable bitmap
X.SH SYNOPSIS
Xpcxtopbm [pcxfile]
X.SH DESCRIPTION
XReads a PC paintbrush (.pcx) file as input.
XProduces a portable bitmap as output.
X.PP
XNote that there is currently no pbmtopcx tool.
X.SH "SEE ALSO"
Xpbm(5)
X.SH AUTHOR
XCopyright (C) 1988 by Jef Poskanzer.
X
XPermission to use, copy, modify, and distribute this software and its
Xdocumentation for any purpose and without fee is hereby granted, provided
Xthat the above copyright notice appear in all copies and that both that
Xcopyright notice and this permission notice appear in supporting
Xdocumentation. This software is provided "as is" without express or
Ximplied warranty.
X
XThis program is based on the pcx2rf program by:
XMike Macgirvin, Stanford Relativity Gyro Program GP-B,
XStanford, CA 94503; ARPA: mike at relgyro.stanford.edu
SHAR_EOF
if test 889 -ne "`wc -c < 'pbm/pcxtopbm.1'`"
then
echo shar: error transmitting "'pbm/pcxtopbm.1'" '(should have been 889 characters)'
fi
fi # end of overwriting check
if test ! -d 'pbm'
then
echo shar: creating directory "'pbm'"
mkdir 'pbm'
fi
echo shar: extracting "'pbm/pbmupc.c'" '(16085 characters)'
if test -f 'pbm/pbmupc.c'
then
echo shar: will not over-write existing file "'pbm/pbmupc.c'"
else
sed 's/^X//' << \SHAR_EOF > 'pbm/pbmupc.c'
X/* pbmupc.c - create a Universal Product Code 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#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
X#define MARGIN 20
X#define DIGIT_WIDTH 14
X#define DIGIT_HEIGHT 23
X#define LINE1_WIDTH 2
X
X#define LINE2_WIDTH ( 2 * LINE1_WIDTH )
X#define LINE3_WIDTH ( 3 * LINE1_WIDTH )
X#define LINE4_WIDTH ( 4 * LINE1_WIDTH )
X#define LINES_WIDTH ( 7 * LINE1_WIDTH )
X#define SHORT_HEIGHT ( 8 * LINES_WIDTH )
X#define TALL_HEIGHT ( SHORT_HEIGHT + DIGIT_HEIGHT / 2 )
X
X
Xmain( argc, argv )
Xint argc;
Xchar *argv[];
X {
X register bit **bits;
X int argn, style, rows, cols, row, digrow, col, digcolofs;
X char *prod, *leftcode, *rightcode;
X int sum, p, lc0, lc1, lc2, lc3, lc4, rc0, rc1, rc2, rc3, rc4;
X int rect( ), alldig( ), addlines( );
X void putdigit( );
X char *usage = "[-s1|-s2] <type> <manufac> <product>";
X
X pm_progname = argv[0];
X
X argn = 1;
X style = 1;
X
X /* Check for flags. */
X while ( argn < argc && argv[argn][0] == '-' )
X {
X if ( strncmp(argv[argn],"-s1",max(strlen(argv[argn]),3)) == 0 )
X style = 1;
X else if ( strncmp(argv[argn],"-s2",max(strlen(argv[argn]),3)) == 0 )
X style = 2;
X else
X pm_usage( usage );
X argn++;
X }
X
X if ( argn + 3 < argc )
X pm_usage( usage );
X prod = argv[argn];
X leftcode = argv[argn + 1];
X rightcode = argv[argn + 2];
X argn += 3;
X
X if ( argn != argc )
X pm_usage( usage );
X
X if ( strlen( prod ) != 1 || ( ! alldig( prod ) ) ||
X strlen( leftcode ) != 5 || ( ! alldig ( leftcode ) ) ||
X strlen( rightcode ) != 5 || ( ! alldig ( rightcode ) ) )
X pm_error(
X "product code must be one digit, and\n left and right codes must be five digits",
X 0,0,0,0,0 );
X p = prod[0] - '0';
X lc0 = leftcode[0] - '0';
X lc1 = leftcode[1] - '0';
X lc2 = leftcode[2] - '0';
X lc3 = leftcode[3] - '0';
X lc4 = leftcode[4] - '0';
X rc0 = rightcode[0] - '0';
X rc1 = rightcode[1] - '0';
X rc2 = rightcode[2] - '0';
X rc3 = rightcode[3] - '0';
X rc4 = rightcode[4] - '0';
X sum = ( 10 - ( ( ( p + lc1 + lc3 + rc0 + rc2 + rc4 ) * 3 + lc0 + lc2 + lc4 + rc1 + rc3 ) % 10 ) ) % 10;
X
X rows = 2 * MARGIN + SHORT_HEIGHT + DIGIT_HEIGHT;
X cols = 2 * MARGIN + 12 * LINES_WIDTH + 11 * LINE1_WIDTH;
X bits = pbm_allocarray( cols, rows );
X
X (void) rect( bits, 0, 0, rows, cols, PBM_WHITE );
X
X row = MARGIN;
X digrow = row + SHORT_HEIGHT;
X col = MARGIN;
X digcolofs = ( LINES_WIDTH - DIGIT_WIDTH ) / 2;
X
X if ( style == 1 )
X putdigit( p, bits, digrow, col - DIGIT_WIDTH - LINE1_WIDTH );
X else if ( style == 2 )
X putdigit(
X p, bits, row + SHORT_HEIGHT / 2, col - DIGIT_WIDTH - LINE1_WIDTH );
X col = rect( bits, row, col, TALL_HEIGHT, LINE1_WIDTH, PBM_BLACK );
X col = rect( bits, row, col, TALL_HEIGHT, LINE1_WIDTH, PBM_WHITE );
X col = rect( bits, row, col, TALL_HEIGHT, LINE1_WIDTH, PBM_BLACK );
X col = addlines( p, bits, row, col, TALL_HEIGHT, PBM_WHITE );
X putdigit( lc0, bits, digrow, col + digcolofs );
X col = addlines( lc0, bits, row, col, SHORT_HEIGHT, PBM_WHITE );
X putdigit( lc1, bits, digrow, col + digcolofs );
X col = addlines( lc1, bits, row, col, SHORT_HEIGHT, PBM_WHITE );
X putdigit( lc2, bits, digrow, col + digcolofs );
X col = addlines( lc2, bits, row, col, SHORT_HEIGHT, PBM_WHITE );
X putdigit( lc3, bits, digrow, col + digcolofs );
X col = addlines( lc3, bits, row, col, SHORT_HEIGHT, PBM_WHITE );
X putdigit( lc4, bits, digrow, col + digcolofs );
X col = addlines( lc4, bits, row, col, SHORT_HEIGHT, PBM_WHITE );
X col = rect( bits, row, col, TALL_HEIGHT, LINE1_WIDTH, PBM_WHITE );
X col = rect( bits, row, col, TALL_HEIGHT, LINE1_WIDTH, PBM_BLACK );
X col = rect( bits, row, col, TALL_HEIGHT, LINE1_WIDTH, PBM_WHITE );
X col = rect( bits, row, col, TALL_HEIGHT, LINE1_WIDTH, PBM_BLACK );
X col = rect( bits, row, col, TALL_HEIGHT, LINE1_WIDTH, PBM_WHITE );
X putdigit( rc0, bits, digrow, col + digcolofs );
X col = addlines( rc0, bits, row, col, SHORT_HEIGHT, PBM_BLACK );
X putdigit( rc1, bits, digrow, col + digcolofs );
X col = addlines( rc1, bits, row, col, SHORT_HEIGHT, PBM_BLACK );
X putdigit( rc2, bits, digrow, col + digcolofs );
X col = addlines( rc2, bits, row, col, SHORT_HEIGHT, PBM_BLACK );
X putdigit( rc3, bits, digrow, col + digcolofs );
X col = addlines( rc3, bits, row, col, SHORT_HEIGHT, PBM_BLACK );
X putdigit( rc4, bits, digrow, col + digcolofs );
X col = addlines( rc4, bits, row, col, SHORT_HEIGHT, PBM_BLACK );
X col = addlines( sum, bits, row, col, TALL_HEIGHT, PBM_BLACK );
X col = rect( bits, row, col, TALL_HEIGHT, LINE1_WIDTH, PBM_BLACK );
X col = rect( bits, row, col, TALL_HEIGHT, LINE1_WIDTH, PBM_WHITE );
X col = rect( bits, row, col, TALL_HEIGHT, LINE1_WIDTH, PBM_BLACK );
X if ( style == 1 )
X putdigit( sum, bits, digrow, col + LINE1_WIDTH );
X
X pbm_writepbm( stdout, bits, cols, rows );
X
X exit( 0 );
X }
X
Xint
Xalldig( cp )
Xchar *cp;
X {
X for ( ; *cp != '\0'; cp++ )
X if ( *cp < '0' || *cp > '9' )
X return 0;
X return 1;
X }
X
Xvoid
Xputdigit( d, bits, row0, col0 )
Xint d, row0, col0;
Xbit **bits;
X {
X int row, col;
X static bit digits[10][DIGIT_HEIGHT][DIGIT_WIDTH] = {
X /* 0 */
X 0,0,0,0,0,0,0,0,0,0,0,0,0,0,
X 0,0,0,0,0,0,0,0,0,0,0,0,0,0,
X 0,0,0,0,1,1,1,1,1,1,0,0,0,0,
X 0,0,0,1,1,1,1,1,1,1,1,0,0,0,
X 0,0,1,1,1,0,0,0,0,1,1,1,0,0,
X 0,0,1,1,0,0,0,0,0,0,1,1,0,0,
X 0,1,1,1,0,0,0,0,0,0,1,1,1,0,
X 0,1,1,0,0,0,0,0,0,0,0,1,1,0,
X 0,1,1,0,0,0,0,0,0,0,0,1,1,0,
X 0,1,1,0,0,0,0,0,0,0,0,1,1,0,
X 0,1,1,0,0,0,0,0,0,0,0,1,1,0,
X 0,1,1,0,0,0,0,0,0,0,0,1,1,0,
X 0,1,1,0,0,0,0,0,0,0,0,1,1,0,
X 0,1,1,0,0,0,0,0,0,0,0,1,1,0,
X 0,1,1,0,0,0,0,0,0,0,0,1,1,0,
X 0,1,1,0,0,0,0,0,0,0,0,1,1,0,
X 0,1,1,1,0,0,0,0,0,0,1,1,1,0,
X 0,0,1,1,0,0,0,0,0,0,1,1,0,0,
X 0,0,1,1,1,0,0,0,0,1,1,1,0,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1,0,0,0,0,0,0,0,0,1,1,0,
X 0,1,1,0,0,0,0,0,0,0,0,1,1,0,
X 0,1,1,1,0,0,0,0,0,0,1,1,1,0,
X 0,0,1,1,0,0,0,0,0,0,1,1,1,0,
X 0,0,1,1,1,1,0,0,1,1,1,1,1,0,
X 0,0,0,1,1,1,1,1,1,1,1,1,0,0,
X 0,0,0,0,0,1,1,1,1,0,1,1,0,0,
X 0,0,0,0,0,0,0,0,0,1,1,1,0,0,
X 0,0,0,0,0,0,0,0,0,1,1,0,0,0,
X 0,0,0,0,0,0,0,0,1,1,1,0,0,0,
X 0,0,0,0,0,0,0,1,1,1,0,0,0,0,
X 0,0,0,0,0,0,1,1,1,0,0,0,0,0,
X 0,0,0,0,0,1,1,1,0,0,0,0,0,0,
X 0,0,0,0,0,1,1,0,0,0,0,0,0,0,
X 0,0,0,0,0,0,0,0,0,0,0,0,0,0,
X 0,0,0,0,0,0,0,0,0,0,0,0,0,0,
X };
X
X for ( row = 0; row < DIGIT_HEIGHT; row++ )
X for ( col = 0; col < DIGIT_WIDTH; col++ )
X bits[row0 + row][col0 + col] = digits[d][row][col];
X }
X
Xint
Xaddlines( d, bits, row0, col0, height, color )
Xint d, row0, col0, height;
Xbit **bits, color;
X {
X int rect( );
X
X switch ( d )
X {
X case 0:
X col0 = rect( bits, row0, col0, height, LINE3_WIDTH, color );
X col0 = rect( bits, row0, col0, height, LINE2_WIDTH, 1 - color );
X col0 = rect( bits, row0, col0, height, LINE1_WIDTH, color );
X col0 = rect( bits, row0, col0, height, LINE1_WIDTH, 1 - color );
X break;
X
X case 1:
X col0 = rect( bits, row0, col0, height, LINE2_WIDTH, color );
X col0 = rect( bits, row0, col0, height, LINE2_WIDTH, 1 - color );
X col0 = rect( bits, row0, col0, height, LINE2_WIDTH, color );
X col0 = rect( bits, row0, col0, height, LINE1_WIDTH, 1 - color );
X break;
X
X case 2:
X col0 = rect( bits, row0, col0, height, LINE2_WIDTH, color );
X col0 = rect( bits, row0, col0, height, LINE1_WIDTH, 1 - color );
X col0 = rect( bits, row0, col0, height, LINE2_WIDTH, color );
X col0 = rect( bits, row0, col0, height, LINE2_WIDTH, 1 - color );
X break;
X
X case 3:
X col0 = rect( bits, row0, col0, height, LINE1_WIDTH, color );
X col0 = rect( bits, row0, col0, height, LINE4_WIDTH, 1 - color );
X col0 = rect( bits, row0, col0, height, LINE1_WIDTH, color );
X col0 = rect( bits, row0, col0, height, LINE1_WIDTH, 1 - color );
X break;
X
X case 4:
X col0 = rect( bits, row0, col0, height, LINE1_WIDTH, color );
X col0 = rect( bits, row0, col0, height, LINE1_WIDTH, 1 - color );
X col0 = rect( bits, row0, col0, height, LINE3_WIDTH, color );
X col0 = rect( bits, row0, col0, height, LINE2_WIDTH, 1 - color );
X break;
X
X case 5:
X col0 = rect( bits, row0, col0, height, LINE1_WIDTH, color );
X col0 = rect( bits, row0, col0, height, LINE2_WIDTH, 1 - color );
X col0 = rect( bits, row0, col0, height, LINE3_WIDTH, color );
X col0 = rect( bits, row0, col0, height, LINE1_WIDTH, 1 - color );
X break;
X
X case 6:
X col0 = rect( bits, row0, col0, height, LINE1_WIDTH, color );
X col0 = rect( bits, row0, col0, height, LINE1_WIDTH, 1 - color );
X col0 = rect( bits, row0, col0, height, LINE1_WIDTH, color );
X col0 = rect( bits, row0, col0, height, LINE4_WIDTH, 1 - color );
X break;
X
X case 7:
X col0 = rect( bits, row0, col0, height, LINE1_WIDTH, color );
X col0 = rect( bits, row0, col0, height, LINE3_WIDTH, 1 - color );
X col0 = rect( bits, row0, col0, height, LINE1_WIDTH, color );
X col0 = rect( bits, row0, col0, height, LINE2_WIDTH, 1 - color );
X break;
X
X case 8:
X col0 = rect( bits, row0, col0, height, LINE1_WIDTH, color );
X col0 = rect( bits, row0, col0, height, LINE2_WIDTH, 1 - color );
X col0 = rect( bits, row0, col0, height, LINE1_WIDTH, color );
X col0 = rect( bits, row0, col0, height, LINE3_WIDTH, 1 - color );
X break;
X
X case 9:
X col0 = rect( bits, row0, col0, height, LINE3_WIDTH, color );
X col0 = rect( bits, row0, col0, height, LINE1_WIDTH, 1 - color );
X col0 = rect( bits, row0, col0, height, LINE1_WIDTH, color );
X col0 = rect( bits, row0, col0, height, LINE2_WIDTH, 1 - color );
X break;
X
X default:
X pm_error( "can't happen", 0,0,0,0,0 );
X }
X
X return col0;
X }
X
Xint
Xrect( bits, row0, col0, height, width, color )
Xbit **bits, color;
Xint row0, col0, height, width;
X {
X int row, col;
X
X for ( row = row0; row < row0 + height; row++ )
X for ( col = col0; col < col0 + width; col++ )
X bits[row][col] = color;
X return col0 + width;
X }
SHAR_EOF
if test 16085 -ne "`wc -c < 'pbm/pbmupc.c'`"
then
echo shar: error transmitting "'pbm/pbmupc.c'" '(should have been 16085 characters)'
fi
fi # end of overwriting check
if test ! -d 'pbm'
then
echo shar: creating directory "'pbm'"
mkdir 'pbm'
fi
echo shar: extracting "'pbm/pbmupc.1'" '(1444 characters)'
if test -f 'pbm/pbmupc.1'
then
echo shar: will not over-write existing file "'pbm/pbmupc.1'"
else
sed 's/^X//' << \SHAR_EOF > 'pbm/pbmupc.1'
X.TH pbmupc 1 "14 March 1989"
X.SH NAME
Xpbmupc - create a Universal Product Code bitmap
X.SH SYNOPSIS
Xpbmupc [-s1|-s2] <type> <manufac> <product>
X.SH DESCRIPTION
XGenerates a Universal Product Code symbol.
XThe three arguments are: a one digit product type, a five digit
Xmanufacturer code, and a five digit product code.
XFor example, "0 72890 00011" is the code for Heineken.
X.PP
XThe -s1 and -s2 flags select the style of UPC to generate.
XThe default, -s1, looks more or less like this:
X.nf
X ||||||||||||||||
X ||||||||||||||||
X ||||||||||||||||
X ||||||||||||||||
X0||12345||67890||5
X.fi
XThe other style, -s2, puts the product type digit higher up, and
Xdoesn't display the checksum digit:
X.nf
X ||||||||||||||||
X ||||||||||||||||
X0||||||||||||||||
X ||||||||||||||||
X ||12345||67890||
X.fi
X.PP
XAs presently configured, pbmupc produces a bitmap 230 bits wide and
X175 bits high.
XThe size can be altered by changing the defines at the beginning of
Xthe program, or by running the output through pnmenlarge or ppmscale.
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 1444 -ne "`wc -c < 'pbm/pbmupc.1'`"
then
echo shar: error transmitting "'pbm/pbmupc.1'" '(should have been 1444 characters)'
fi
fi # end of overwriting check
if test ! -d 'pbm'
then
echo shar: creating directory "'pbm'"
mkdir 'pbm'
fi
echo shar: extracting "'pbm/tifftopbm.c'" '(14362 characters)'
if test -f 'pbm/tifftopbm.c'
then
echo shar: will not over-write existing file "'pbm/tifftopbm.c'"
else
sed 's/^X//' << \SHAR_EOF > 'pbm/tifftopbm.c'
X/*
X**---------------------------------------------------------------------
X** tifftopbm.c
X**---------------------------------------------------------------------
X**
X** Copyright 1988 by Paul J. Emerson
X**
X** Permission to use, copy, modify, and distribute this software
X** and its documentation for any purpose and without fee is
X** hereby granted, provided that the above copyright notice
X** appear in all copies and that both that copyright notice and
X** this permission notice appear in supporting documentation, and
X** that the name of Paul J. Emerson not be used in advertising or
X** publicity pertaining to distribution of the software without
X** specific, written prior permission. Paul J. Emerson makes no
X** representations about the suitability of this software for
X** any purpose. It is provided "as is" without express or implied
X** warranty.
X**
X** Version 1.4
X** Jef Poskanzer (jef at helios.ee.lbl.gov)
X** April 1989
X**
X** Comments
X** - Now uses new PBM error handling routine.
X**
X** Version 1.3
X** Lindsay F. Marshall (Lindsay.Marshall at newcastle.ac.uk)
X** January 1989
X**
X** Comments
X** - Removed include of malloc.h and added extern for malloc.
X**
X** Version 1.2
X** Jef Poskanzer (jef at rtsg.ee.lbl.gov)
X** January 1989
X**
X** Comments
X** - Patch from Mike K. Peterson (mkp at hac2arpa.hac.com) to handle
X** MicroTek VersaScan variant.
X**
X** Version 1.1
X** Jef Poskanzer (jef at rtsg.ee.lbl.gov)
X** December 1988
X**
X** Comments
X** - Changed name from tiff2pbm to tifftopbm.
X** - Changed to use libpbm routines.
X**
X** Version 1.0
X** Paul J. Emerson (ucf-cs!sdgsun!paul)
X** December 1988
X**
X** Comments
X** - TIFF Support:
X** - Single Bit Plane
X** - Black & White (No grey scale or color)
X** - Uncompressed TIFF
X** - Supports PBM magic number
X** - Usage: tifftopbm [-h] tifffile
X** -h Dump TIFF file header info to stderr
X** This may be helpful in detecting unsuported aspects
X** of the TIFF file format.
X**
X** Notes:
X** Compile: cc -O tifftopbm.c -o tifftopbm
X**
X**---------------------------------------------------------------------
X*/
X
X#include <stdio.h>
X#include <fcntl.h>
X#include <errno.h>
X#include "tiff.h"
X#include "pbm.h"
X
X#define TRUE 1
X#define FALSE 0
X
Xmain(argc,argv)
Xint argc;
Xchar *argv[];
X{
Xint fd,
X Dump=FALSE;
Xstruct Tiffstruct Tiff;
Xstruct TiffHeader Header;
Xchar fname[255];
Xchar *usage = "[-h] tifffile";
X
X pm_progname = argv[0];
X
X if (argc >= 2)
X {
X if (!strcmp("-h",argv[1]))
X {
X Dump = TRUE;
X if (argc == 3)
X strcpy(fname,argv[2]);
X else
X {
X printf(usage,argv[0]);
X exit(1);
X }
X }
X else
X strcpy(fname,argv[1]);
X
X if ((fd = open(fname,O_RDONLY)) < 0 )
X {
X perror(fname);
X exit(1);
X }
X }
X else
X {
X printf(usage,argv[0]);
X exit(1);
X }
X
X if (readTiff(&Tiff,&Header,fd))
X {
X if (Dump)
X dumpHeader(&Tiff,&Header);
X PbmOut(fd,&Tiff);
X }
X else
X pm_error( "readTiff failure", 0,0,0,0,0 );
X close(fd);
X
X}
X
X/*
X**------------------------------------------------------------------------
X** Send image to stdout in PBM format
X**------------------------------------------------------------------------
X*/
XPbmOut(fd,t)
Xint fd;
Xstruct Tiffstruct *t;
X{
Xregister int i, row;
Xchar *bptr;
XLONG *cntptr;
XLONG *dataptr;
Xregister bit **bits;
X
Xextern char *malloc();
X
X bits = pbm_allocarray(t->ImageWidth,t->ImageLength);
X
X dataptr = t->StripOffset;
X cntptr = t->SBytesCntOffset;
X
X for (i=0, row=0; i < t->StOffsetCnt; i++, row += t->RowsStrip)
X {
X
X lseek(fd,(long) *dataptr,0);
X bptr = malloc(*cntptr);
X if ( bptr == 0 )
X pm_error( "out of memory", 0,0,0,0,0 );
X if (read(fd,bptr,*cntptr) != *cntptr)
X {
X perror("StripOffset read ");
X return;
X }
X
X PbmDoRow(bptr,*cntptr,bits,row,t->ImageWidth);
X
X free(bptr);
X cntptr++;
X dataptr++;
X }
X
X pbm_writepbm(stdout,bits,t->ImageWidth,t->ImageLength);
X}
X/*
X**------------------------------------------------------------------------
X** Output a row in PBM format
X**------------------------------------------------------------------------
X*/
XPbmDoRow(buffer,count,bits,row,cols)
Xchar *buffer;
Xint count;
Xbit **bits;
Xint row, cols;
X{
Xregister int i, col;
X
X col = 0;
X while (count--)
X {
X for (i = 0 ; i < 8; i++)
X {
X bits[row][col++] =
X ( ( *buffer << i ) & 0x80 ) ? PBM_BLACK : PBM_WHITE;
X if ( col >= cols )
X {
X col = 0;
X row++;
X }
X }
X buffer++;
X }
X}
X
X/*
X**------------------------------------------------------------------------
X** Read and decode a Tiff header.
X** Not all TIFF capabilities are supported. Only single plane bit maps.
X**------------------------------------------------------------------------
X*/
Xint
XreadTiff(T,H,fd)
Xstruct Tiffstruct *T;
Xstruct TiffHeader *H;
Xint fd;
X{
Xstruct IDF idf;
Xstruct IDF_Entry *ptr;
XLONG TempRational[2];
X
X#ifdef SYSV
X memset((char *)T,0,sizeof(struct Tiffstruct));
X#else SYSV
X bzero((char *)T,sizeof(struct Tiffstruct));
X#endif SYSV
X
X if (read(fd,H,sizeof(struct TiffHeader)) != sizeof(struct TiffHeader))
X {
X perror("Header ");
X return(FALSE);
X }
X
X lseek(fd,(long)H->IdfOffset,0);
X
X if (read(fd,&idf.NumEntries,sizeof(SHORT)) != sizeof(SHORT))
X {
X perror("Idf count ");
X return(FALSE);
X }
X
X if ((idf.idfptr = (struct IDF_Entry *)
X calloc(idf.NumEntries,sizeof(struct IDF_Entry))) == NULL)
X {
X perror("calloc ");
X return(FALSE);
X }
X
X if (read(fd,idf.idfptr,idf.NumEntries*sizeof(struct IDF_Entry))
X != idf.NumEntries*sizeof(struct IDF_Entry))
X {
X perror("Idf count ");
X return(FALSE);
X }
X
X ptr = idf.idfptr;
X
X while (idf.NumEntries--)
X {
X switch (ptr->Tag)
X {
X case 0x00FF:
X T->SubFileType = (ptr->ValueOffset >> 16);
X break;
X
X case 0x0100:
X T->ImageWidth = (ptr->ValueOffset >> 16);
X break;
X
X case 0x0101:
X T->ImageLength = (ptr->ValueOffset >> 16);
X break;
X
X case 0x0102:
X T->BitsPerSample = (ptr->ValueOffset >> 16);
X break;
X
X case 0x0103:
X T->Compression = (ptr->ValueOffset >> 16);
X break;
X
X case 0x0106:
X T->PhotoInterp = (ptr->ValueOffset >> 16);
X break;
X
X case 0x0107:
X T->Threshold = (ptr->ValueOffset >> 16);
X break;
X
X case 0x0108:
X T->CellWidth = (ptr->ValueOffset >> 16);
X break;
X
X case 0x0109:
X T->CellLength = (ptr->ValueOffset >> 16);
X break;
X
X case 0x010A:
X T->FillOrder = (ptr->ValueOffset >> 16);
X break;
X
X case 0x010D:
X fprintf(stderr,"Unsupported feature\n");
X /*
X lseek(fd,(long)ptr->ValueOffset,0);
X */
X break;
X
X case 0x010E:
X fprintf(stderr,"Unsupported feature\n");
X /*
X lseek(fd,(long)ptr->ValueOffset,0);
X */
X break;
X
X case 0x010F:
X /*
X lseek(fd,(long)ptr->ValueOffset,0);
X */
X fprintf(stderr,"Make: %s\n", T->Make);
X break;
X
X case 0x0110:
X fprintf(stderr,"Unsupported feature\n");
X /*
X lseek(fd,(long)ptr->ValueOffset,0);
X */
X break;
X
X case 0x0111:
X T->StOffsetCnt = ptr->Length;
X if ((T->StripOffset = (LONG *) calloc(T->StOffsetCnt,
X sizeof (LONG)))== NULL)
X {
X perror("calloc Soffset ");
X return(FALSE);
X }
X if(T->StOffsetCnt == 1)
X *(T->StripOffset) = ptr->ValueOffset;
X else
X {
X lseek(fd, (long) ptr->ValueOffset, 0);
X read(fd, T->StripOffset, T->StOffsetCnt * sizeof(LONG));
X }
X break;
X
X case 0x0112:
X T->Orientation= (ptr->ValueOffset >> 16);
X break;
X
X case 0x0115:
X T->SamplesPixel= (ptr->ValueOffset >> 16);
X break;
X
X case 0x0116:
X T->RowsStrip= (ptr->ValueOffset);
X break;
X
X case 0x0117:
X T->StripByteCnt = (ptr->Length);
X if ((T->SBytesCntOffset = (LONG *) calloc(T->StripByteCnt,
X sizeof (LONG)))== NULL)
X {
X perror("calloc StripByteCnt ");
X return(FALSE);
X }
X if(T->StripByteCnt == 1)
X *(T->SBytesCntOffset) = ptr->ValueOffset;
X else
X {
X lseek(fd,(long)ptr->ValueOffset,0);
X read(fd,T->SBytesCntOffset,T->StripByteCnt*sizeof(LONG));
X }
X break;
X
X case 0x0118:
X T->MinSampleValue= (ptr->ValueOffset >> 16);
X break;
X
X case 0x0119:
X T->MaxSampleValue= (ptr->ValueOffset >> 16);
X break;
X
X case 0x011A:
X lseek(fd,(long)ptr->ValueOffset,0);
X read(fd,TempRational,sizeof(TempRational));
X T->Xres = TempRational[0]/TempRational[1];
X break;
X
X case 0x011B:
X lseek(fd,(long)ptr->ValueOffset,0);
X read(fd,TempRational,sizeof(TempRational));
X T->Yres = TempRational[0]/TempRational[1];
X break;
X
X case 0x011C:
X T->PlanarConfig= (ptr->ValueOffset >> 16);
X break;
X
X case 0x011D:
X fprintf(stderr,"Unsupported feature: PageName\n");
X /* T->PageName */
X break;
X
X case 0x011E:
X fprintf(stderr,"Unsupported feature: Xpos\n");
X /* T->XPos */
X break;
X
X case 0x011F:
X fprintf(stderr,"Unsupported feature: Ypos\n");
X /* T->YPos */
X break;
X
X case 0x0120:
X fprintf(stderr,"Unsupported feature: FreeOffsets\n");
X /* T->FreeOffsets */
X break;
X
X case 0x0121:
X fprintf(stderr,"Unsupported feature: FreeByteCount \n");
X /* T->FreeByteCount */
X break;
X
X case 0x0122:
X fprintf(stderr,"Unsupported feature: GrayResUnit\n");
X /* T->GrayResUnit */
X break;
X
X case 0x0123:
X fprintf(stderr,"Unsupported feature: GrayResCurve\n");
X /* T->GrayResCurve */
X break;
X
X case 0x0124:
X fprintf(stderr,"Unsupported feature: Group3Option\n");
X /* T->Group3Option */
X break;
X
X case 0x0125:
X fprintf(stderr,"Unsupported feature: Group4Option\n");
X /* T->Group4Option */
X break;
X
X case 0x0128:
X fprintf(stderr,"Unsupported feature: ResolutionUnit\n");
X /* T->ResolutionUnit */
X break;
X
X case 0x0129:
X fprintf(stderr,"Unsupported feature: PageNumber\n");
X /* T->PageNumber */
X break;
X
X case 0x012C:
X fprintf(stderr,"Unsupported feature: ColorResUnit\n");
X /* T->ColorResUnit */
X break;
X
X case 0x012D:
X fprintf(stderr,"Unsupported feature: ColorResCurv\n");
X /* T->ColorResCurv */
X break;
X
X default:
X fprintf(stderr,"Unsupported feature: Unknown Tag\n");
X fprintf(stderr,"Default\n");
X break;
X }
X ptr++;
X }
X return(TRUE);
X}
X/*
X** Dump header information
X*/
XdumpHeader(T,H)
Xstruct Tiffstruct *T;
Xstruct TiffHeader *H;
X{
Xint i;
XLONG *offptr;
X
X fprintf(stderr,"Version: %d\n",H->Version);
X fprintf(stderr,"ByteOrder: %c%c\n",
X H->ByteOrder[0],
X H->ByteOrder[1]);
X fprintf(stderr,"Subfile Type: %d\n", T->SubFileType);
X fprintf(stderr,"ImageWidth: %d\n", T->ImageWidth);
X fprintf(stderr,"ImageLength: %d\n", T->ImageLength);
X fprintf(stderr,"BitsPerSample: %d\n", T->BitsPerSample);
X fprintf(stderr,"Compression: %d\n", T->Compression);
X fprintf(stderr,"PhotoInterp: %d\n", T->PhotoInterp);
X fprintf(stderr,"Threshold: %d\n", T->Threshold);
X fprintf(stderr,"CellWidth: %d\n", T->CellWidth);
X fprintf(stderr,"CellLength: %d\n", T->CellLength);
X fprintf(stderr,"FillOrder: %d\n", T->FillOrder);
X fprintf(stderr,"DocName: %s\n", T->DocName);
X fprintf(stderr,"ImageDescript: %s\n", T->ImageDescript);
X fprintf(stderr,"Model: %s\n", T->Model);
X fprintf(stderr,"StripOffsetCnt: %d\n", T->StOffsetCnt);
X offptr = T->StripOffset;
X for(i=0; i < T->StOffsetCnt; i++)
X {
X fprintf(stderr,"Strip [%02d] starts at: %d \n", i,*offptr);
X offptr++;
X }
X fprintf(stderr,"Orientation: %d\n", T->Orientation);
X fprintf(stderr,"SamplesPixel: %d\n", T->SamplesPixel);
X fprintf(stderr,"RowsStrip: %d\n", T->RowsStrip);
X fprintf(stderr,"StripByteCnt: %d\n", T->StripByteCnt);
X offptr = T->SBytesCntOffset;
X for(i=0; i < T->StripByteCnt; i++)
X {
X fprintf(stderr,"Strip [%02d]: %d bytes\n", i,*offptr);
X offptr++;
X }
X fprintf(stderr,"MinSampleValue: %d\n", T->MinSampleValue);
X fprintf(stderr,"MaxSampleValue: %d\n", T->MaxSampleValue);
X fprintf(stderr,"Xres: %d\n", T->Xres);
X fprintf(stderr,"Yres: %d\n", T->Yres);
X fprintf(stderr,"PlanarConfig: %d\n", T->PlanarConfig);
X}
SHAR_EOF
if test 14362 -ne "`wc -c < 'pbm/tifftopbm.c'`"
then
echo shar: error transmitting "'pbm/tifftopbm.c'" '(should have been 14362 characters)'
fi
fi # end of overwriting check
if test ! -d 'pbm'
then
echo shar: creating directory "'pbm'"
mkdir 'pbm'
fi
echo shar: extracting "'pbm/tifftopbm.1'" '(906 characters)'
if test -f 'pbm/tifftopbm.1'
then
echo shar: will not over-write existing file "'pbm/tifftopbm.1'"
else
sed 's/^X//' << \SHAR_EOF > 'pbm/tifftopbm.1'
X.TH tifftopbm 1 "05 December 1988"
X.SH NAME
Xtifftopbm - convert a TIFF file into a portable bitmap
X.SH SYNOPSIS
Xtifftopbm [-h] tifffile
X.SH DESCRIPTION
XReads a TIFF file as input.
XProduces a portable bitmap as output. Tifftopbm supports: single plane bitmaps,
Xnon-compressed bitmaps and black and white bitmaps. There is no support for
Xcolor or grey scale.
X.TP 5
X.B \-h
XDump TIFF file information to stderr. This information may be useful
Xin debugging TIFF file conversion problems.
X.SH AUTHOR
XCopyright (C) 1988 by Paul Emerson.
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 906 -ne "`wc -c < 'pbm/tifftopbm.1'`"
then
echo shar: error transmitting "'pbm/tifftopbm.1'" '(should have been 906 characters)'
fi
fi # end of overwriting check
if test ! -d 'pbm'
then
echo shar: creating directory "'pbm'"
mkdir 'pbm'
fi
echo shar: extracting "'pbm/mgr.h'" '(331 characters)'
if test -f 'pbm/mgr.h'
then
echo shar: will not over-write existing file "'pbm/mgr.h'"
else
sed 's/^X//' << \SHAR_EOF > 'pbm/mgr.h'
X/* mgr.h - the following defs are taken from the MGR header file lib/dump.h
X*/
X
Xstruct old_b_header {
X char magic[2];
X char h_wide;
X char l_wide;
X char h_high;
X char l_high;
X };
X
Xstruct b_header {
X char magic[2];
X char h_wide;
X char l_wide;
X char h_high;
X char l_high;
X char depth;
X char _reserved;
X };
SHAR_EOF
if test 331 -ne "`wc -c < 'pbm/mgr.h'`"
then
echo shar: error transmitting "'pbm/mgr.h'" '(should have been 331 characters)'
fi
fi # end of overwriting check
if test ! -d 'pbm'
then
echo shar: creating directory "'pbm'"
mkdir 'pbm'
fi
echo shar: extracting "'pbm/mgrtopbm.c'" '(3087 characters)'
if test -f 'pbm/mgrtopbm.c'
then
echo shar: will not over-write existing file "'pbm/mgrtopbm.c'"
else
sed 's/^X//' << \SHAR_EOF > 'pbm/mgrtopbm.c'
X/* mgrtopbm.c - read a MGR bitmap and produce a portable bitmap
X**
X** Copyright (C) 1989 by Jef Poskanzer.
X**
X** Permission to use, copy, modify, and distribute this software and its
X** documentation for any purpose and without fee is hereby granted, provided
X** that the above copyright notice appear in all copies and that both that
X** copyright notice and this permission notice appear in supporting
X** documentation. This software is provided "as is" without express or
X** implied warranty.
X*/
X
X#include <stdio.h>
X#include "pbm.h"
X#include "mgr.h"
X
Xmain( argc, argv )
Xint argc;
Xchar *argv[];
X {
X FILE *ifd;
X register bit *bitrow, *bP;
X bit getbit();
X int rows, cols, depth, padright, row, col;
X
X pm_progname = argv[0];
X
X if ( argc > 2 )
X pm_usage( "[mgrfile]" );
X
X if ( argc == 2 )
X ifd = pm_openr( argv[1] );
X else
X ifd = stdin;
X
X getinit( ifd, &cols, &rows, &depth, &padright );
X if ( depth != 1 )
X pm_error( "MGR file has depth of %d, must be 1", depth, 0,0,0,0 );
X
X pbm_writepbminit( stdout, cols, rows );
X bitrow = pbm_allocrow( cols );
X
X for ( row = 0; row < rows; row++ )
X {
X /* Get data, bit-reversed within each byte. */
X for ( col = 0, bP = bitrow; col < cols; col++, bP++ )
X *bP = getbit( ifd );
X /* Discard line padding */
X for ( col = 0; col < padright; col ++ )
X (void) getbit( ifd );
X pbm_writepbmrow( stdout, bitrow, cols );
X }
X
X pm_close( ifd );
X
X exit( 0 );
X }
X
X
Xunsigned char item;
Xint bitsperitem, bitshift;
X
Xgetinit( file, colsP, rowsP, depthP, padrightP )
XFILE *file;
Xint *colsP, *rowsP, *depthP, *padrightP;
X {
X struct b_header head;
X int pad;
X
X if ( fread( &head, sizeof(struct old_b_header), 1, file ) != 1 )
X {
X perror( "reading header" );
X exit( 1 );
X }
X if ( head.magic[0] == 'y' && head.magic[1] == 'z' )
X { /* new style bitmap */
X if ( fread( &head.depth, sizeof(head) - sizeof(struct old_b_header), 1, file ) != 1 )
X {
X perror( "reading rest of header" );
X exit( 1 );
X }
X *depthP = (int) head.depth - ' ';
X pad = 8;
X }
X else if ( head.magic[0] == 'x' && head.magic[1] == 'z' )
X { /* old style bitmap with 32-bit padding */
X *depthP = 1;
X pad = 32;
X }
X else if ( head.magic[0] == 'z' && head.magic[1] == 'z' )
X { /* old style bitmap with 16-bit padding */
X *depthP = 1;
X pad = 16;
X }
X else if ( head.magic[0] == 'z' && head.magic[1] == 'y' )
X { /* old style 8-bit pixmap with 16-bit padding */
X *depthP = 8;
X pad = 16;
X }
X else
X pm_error(
X "bad magic chars in MGR file: '%c%c'",
X head.magic[0], head.magic[1], 0,0,0 );
X *colsP = ( ( (int) head.h_wide - ' ' ) << 6 ) + ( (int) head.l_wide - ' ' );
X *rowsP = ( ( (int) head.h_high - ' ' ) << 6 ) + ( (int) head.l_high - ' ' );
X *padrightP = ( ( *colsP + pad - 1 ) / pad ) * pad - *colsP;
X
X bitsperitem = 8;
X }
X
Xbit
Xgetbit( file )
XFILE *file;
X {
X bit b;
X
X if ( bitsperitem == 8 )
X {
X item = getc( file );
X bitsperitem = 0;
X bitshift = 7;
X }
X bitsperitem++;
X b = ( ( item >> bitshift) & 1 ) ? PBM_BLACK : PBM_WHITE;
X bitshift--;
X return b;
X }
SHAR_EOF
if test 3087 -ne "`wc -c < 'pbm/mgrtopbm.c'`"
then
echo shar: error transmitting "'pbm/mgrtopbm.c'" '(should have been 3087 characters)'
fi
fi # end of overwriting check
if test ! -d 'pbm'
then
echo shar: creating directory "'pbm'"
mkdir 'pbm'
fi
echo shar: extracting "'pbm/mgrtopbm.1'" '(664 characters)'
if test -f 'pbm/mgrtopbm.1'
then
echo shar: will not over-write existing file "'pbm/mgrtopbm.1'"
else
sed 's/^X//' << \SHAR_EOF > 'pbm/mgrtopbm.1'
X.TH mgrtopbm 1 "24 January 1989"
X.SH NAME
Xmgrtopbm - convert a MGR bitmap into a portable bitmap
X.SH SYNOPSIS
Xmgrtopbm [mgrfile]
X.SH DESCRIPTION
XReads a MGR bitmap as input.
XProduces a portable bitmap as output.
X.SH "SEE ALSO"
Xpbmtomgr(1), pbm(5)
X.SH AUTHOR
XCopyright (C) 1989 by Jef Poskanzer.
X
XPermission to use, copy, modify, and distribute this software and its
Xdocumentation for any purpose and without fee is hereby granted, provided
Xthat the above copyright notice appear in all copies and that both that
Xcopyright notice and this permission notice appear in supporting
Xdocumentation. This software is provided "as is" without express or
Ximplied warranty.
SHAR_EOF
if test 664 -ne "`wc -c < 'pbm/mgrtopbm.1'`"
then
echo shar: error transmitting "'pbm/mgrtopbm.1'" '(should have been 664 characters)'
fi
fi # end of overwriting check
# End of shell archive
exit 0
More information about the Alt.sources
mailing list