[comp.sources.sun] v01i092: ALV - An Image Processing Toolkit, Part08/10

mcgrew@dartagnan.rutgers.edu (Charles Mcgrew) (12/12/89)

Submitted-by: everson@compsci.bristol.ac.uk
Posting-number: Volume 1, Issue 92
Archive-name: alv/part08



#! /bin/sh
# This is a shell archive.  Remove anything before this line, then unpack
# it by saving it into a file and typing "sh file".  To overwrite existing
# files, type "sh file -c".  You can also feed this as standard input via
# unshar, or by typing "sh <file", e.g..  If this archive is complete, you
# will see the following message at the end:
#		"End of archive 8 (of 10)."
# Contents:  images/sample_image.Z-uuac src/ras8to1.c
# Wrapped by everson@kukini on Tue Oct 17 07:45:14 1989
PATH=/bin:/usr/bin:/usr/ucb ; export PATH
if test -f 'images/sample_image.Z-uuac' -a "${1}" != "-c" ; then 
  echo shar: Will not clobber existing file \"'images/sample_image.Z-uuac'\"
else
echo shar: Extracting \"'images/sample_image.Z-uuac'\" \(18682 characters\)
sed "s/^X//" >'images/sample_image.Z-uuac' <<'END_OF_FILE'
M898'6EP=A#,G\5I]R2)'%%P%6N.3:', ]U!W_16HZ?ZRVD)E[VVN.2C(;?=-
M!#H. T1!@-H"B;!3W$U< A(!#4A\!LJ3]["X6 YJ/(AO#QY0*3;$];%874'L
MF@<!H(!6@A^ V?@B<44H3\A<R<4$'AXYJA<A -AY8!?$%]]5@*KP,1NI!09$
M:B>XCEE/K"P@E2=J%5VB BX!J@#@08V%XGN7S%128G6TR(<G<7+XQQPK^ ?Q
M)V&\!L= 25GDF)(@8&;X!@2@QC/.*(('$T#!J?4A&C4!!83');/Q[8 -&;CF
M#MY=VRJV :<#U=#=-<]9K<1U*X8]#-N2;;"'Z>LX]UY/;H ;<B9@(WD(F#,9
MNDBA<]I%HGTAN"P0$J%& @)"(@6H;^S ;?!'49VY#6(%5X:98GZLZOA;/ 28
MVKC%?L9KA9GNL1D+")+N&:%$&X&K@@MBS,PCA03  A3'<+M)+836%U#S*U?\
MZR0[N8!6P"Z@,N*8O<R0:#B6&ED.;2P@%. 2D'66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%$V4?!(LE!# ?MT
M,$^>/C1V@F%531YO>569 !D-XP6J JX(<%L;'(\P.FCT!6,=?Q1-(GP   =Z
M5GX#8FS=1Z]VJU4="BQI34?=; A\04AG0MP,\%Q? 5](8F)G0HX X%[#3$%N
M9CI7.VT'"@I[1H54; =F8J\GB #. :H"Y!0P789W&04H4H, 8D<<5J< =P!&
M/Q%ND#L]4J8 D@"]/+4#WQYZ  -AOU"+.[1-I0!L0*H %@*O:GQD/!C2>@@5
M"!5@%/<6N(&3&7A$O(%P.X)NKQ4#=()N16H$;_%TZV9M,(T 1VN@>$,!+6P[
X'<K).GDO==8&3
X 
end
END_OF_FILE
if test 18682 -ne `wc -c <'images/sample_image.Z-uuac'`; then
    echo shar: \"'images/sample_image.Z-uuac'\" unpacked with wrong size!
fi
# end of 'images/sample_image.Z-uuac'
fi
if test -f 'src/ras8to1.c' -a "${1}" != "-c" ; then 
  echo shar: Will not clobber existing file \"'src/ras8to1.c'\"
else
echo shar: Extracting \"'src/ras8to1.c'\" \(16965 characters\)
sed "s/^X//" >'src/ras8to1.c' <<'END_OF_FILE'
X/*
X * Modified by Phill Everson <everson@cs.bris.ac.uk> for inclusion into
X * the ALV toolkit.
X *
X */
X
X/**************************************************************************
X Copyright (c) 1988 by Hong Min
X
X   compile : cc -O -o 8to1 8to1.c -lpixrect
X
X   The program 8to1 converts a 8-bit depth sun raster file (both color,
X   i.e. rgb are different, and grey, i.e. rgb are the same, and both
X   standard format and byte-encoded format) to a 1-bit depth mono sun
X   raster file. If your color image has no colormap, this program would
X   provide a default grey scale color map. It implements several halftone
X   algorithms from Digital Halftones by Dot Diffusion in acm Transactions
X   on Graphics, such as error diffusion, ordered dither and dot diffusion
X   with and without edge enhancement.  Just type 8to1, it will give you
X   the usage.
X
X   This program was written by :
X
X	Hong Min
X	Computer Science Department
X   	SUNY at Stony Brook
X	e-mail address :
X		UUCP: {allegra, philabs, pyramid, research}!sbcs!rainbow
X		ARPA-Internet: rainbow@sbcs.sunysb.edu
X		CSnet: rainbow@suny-sb
X
X   Everyone is welcome to write to me if you like the program or not.
X   And welcome to optimize the code, as I haven't fooled with it to
X   make it efficient yet.
X
X		Enjoy!
X
X****************************************************************************/
X#include <stdio.h>
X#include "defs.h"
X#include <sys/types.h>
X#include <pixrect/pixrect.h>
X#include <pixrect/memvar.h>
X#include <pixrect/pr_util.h>
X#include <pixrect/pr_io.h>
X
X#define WHITE   0		/* background color */
X#define BLACK   ~0		/* foreground color */
X#define FALSE	0
X#define TRUE	1
X#define ALPHA	7
X#define BETA	3
X#define GAMMA	5
X#define DELTA	1
X
short **A, **B;
int ordered_dither[8][8] = {0, 32, 8, 40, 2, 34, 10, 42,
X	48, 16, 56, 24, 50, 18, 58, 26,
X	12, 44, 4, 36, 14, 46, 6, 38,
X	60, 28, 52, 20, 62, 30, 54, 22,
X	3, 35, 11, 43, 1, 33, 9, 41,
X	51, 19, 59, 27, 49, 17, 57, 25,
X	15, 47, 7, 39, 13, 45, 5, 37,
X63, 31, 55, 23, 61, 29, 53, 21};
int dot_diffusion[8][8] = {34, 48, 40, 32, 29, 15, 23, 31,
X	42, 58, 56, 53, 21, 5, 7, 10,
X	50, 62, 61, 45, 13, 1, 2, 18,
X	38, 46, 54, 37, 25, 17, 9, 26,
X	28, 14, 22, 30, 35, 49, 41, 33,
X	20, 4, 6, 11, 43, 59, 57, 52,
X	12, 0, 3, 19, 51, 63, 60, 44,
X24, 16, 8, 27, 39, 47, 55, 36};
int reverse_matrix[64] = {49, 21, 22, 50, 41, 13, 42, 14,
X	58, 30, 15, 43, 48, 20, 33, 5,
X	57, 29, 23, 51, 40, 12, 34, 6,
X	56, 28, 31, 59, 32, 4, 35, 7,
X	3, 39, 0, 36, 63, 27, 24, 60,
X	2, 38, 8, 44, 55, 19, 25, 61,
X	1, 37, 16, 52, 47, 11, 26, 62,
X10, 46, 9, 45, 54, 18, 17, 53};
X
char *progname;
char *filename;
Pixrect *pr = 0;
X
X#define ERROR	0
X#define ORDERED	1
X#define DOT	2
X
X#ifdef STANDALONE
main(argc, argv, envp)
X#else
ras8to1_main(argc, argv, envp)
X#endif
X	int argc;
X	char **argv;
X	char **envp;
X{
X	int diffusion, enhancement, colour, greyscale, option;
X	int default_map = FALSE;
X	register int i, j;
X	int levels;
X	colormap_t colormap;
X	register unsigned char *map;
X	register struct rasterfile rh;
X
X	colour = TRUE;
X	diffusion = ERROR;
X	enhancement = FALSE;
X	progname = strsave(argv[0]);
X	parse_profile(&argc, argv, envp);
X
X	while ((gc = getopt(argc, argv, "rodeg")) != EOF)
X		switch (gc) {
X		case 'r':
X			diffusion = ERROR;
X			break;
X		case 'o':
X			diffusion = ORDERED;
X			break;
X		case 'd':
X			diffusion = DOT;
X			break;
X		case 'e':
X			enhancement = TRUE;
X			break;
X		case 'g':
X			colour = FALSE;
X			break;
X		case '?':
X			errflag++;
X			break;
X		}
X
X	if (errflag)
X		error((char *) 0, "Usage: %s: [-r] [-o] [-d] [-e] [-g] [infile] [outfile]", progname);
X
X	for (stream = 0; optind < argc; stream++, optind++)
X		if (stream < 2 && strcmp(argv[optind], "-") != 0)
X			if (freopen(argv[optind], mode[stream], f[stream]) == NULL)
X				error("%s %s", PR_IO_ERR_INFILE, argv[optind]);
X
X	setup_greylevelmap();
X
X	/* Load the input rasterfile header */
X	if (pr_load_header(stdin, &rh) == PIX_ERR)
X		error(PR_IO_ERR_RASREAD);
X
X	if (rh.ras_depth != 8)
X		error("infile is not a 8 bits deep");
X
X	/* Load the colormap */
X	colormap.type = RMT_NONE;
X	colormap.map[0] = (unsigned char *) malloc(256);
X	colormap.map[1] = (unsigned char *) malloc(256);
X	colormap.map[2] = (unsigned char *) malloc(256);
X	if (pr_load_colormap(stdin, &rh, &colormap) == PIX_ERR)
X		error("read colormap error");
X
X	if (colormap.type != RMT_NONE &&
X	    (colormap.type != RMT_EQUAL_RGB || colormap.length < 256))
X		error("input has unsupported colormap type or length\n");
X
X	if ((colormap.type == RMT_NONE) && (colormap.length == 0)) {
X		default_map = TRUE;
X		map = greylevelmap;
X		colour = FALSE;
X	}
X	if (rh.ras_type != RT_OLD && rh.ras_type != RT_STANDARD &&
X	    !(pr = pr_load_image(stdin, &rh, &colormap))) {
X		fprintf(stderr, "error reading rasterfile\n");
X		exit(1);
X	}
X	option = diffusion;
X	if (enhancement)
X		option += 3;
X	if (colour)
X		option += 6;
X
X	/* Write new header */
X	rh.ras_type = RT_STANDARD;
X	rh.ras_depth = 1;
X	rh.ras_length = mpr_linebytes(rh.ras_width, 1) * rh.ras_height;
X	rh.ras_maptype = RMT_NONE;
X	rh.ras_maplength = 0;
X
X	if (pr_dump_header(stdout, &rh, (colormap_t *) 0) == PIX_ERR)
X		error("pr_dump_header failed");
X
X	if (rh.ras_width <= 0 || rh.ras_height <= 0)
X		exit(1);
X	else {
X		A = (short **) malloc((rh.ras_width + 3) * sizeof(short *));
X		B = (short **) malloc((rh.ras_width + 3) * sizeof(short *));
X		for (i = 0; i < rh.ras_width + 3; i++) {
X			A[i] = (short *) malloc((rh.ras_height + 3) * sizeof(short));
X			B[i] = (short *) malloc((rh.ras_height + 3) * sizeof(short));
X		}
X	}
X
X	if (!default_map)
X		map = colormap.map[0];
X
X	if (pr)
X		switch (option) {
X		case 6:
X			map = (unsigned char *) malloc(256);
X			color_map_3_to_1(colormap, map);
X		case 0:
X			error_diffusion_image(rh.ras_width, rh.ras_height,
X				map, (u_char *) mpr_d(pr)->md_image, stdout,
X				 0, mpr_d(pr)->md_linebytes - rh.ras_width);
X			break;
X		case 7:
X			map = (unsigned char *) malloc(256);
X			color_map_3_to_1(colormap, map);
X		case 1:
X			ordered_dither_image(rh.ras_width, rh.ras_height,
X				map, (u_char *) mpr_d(pr)->md_image, stdout,
X				 0, mpr_d(pr)->md_linebytes - rh.ras_width);
X			break;
X		case 8:
X			map = (unsigned char *) malloc(256);
X			color_map_3_to_1(colormap, map);
X		case 2:
X			dot_diffusion_image(rh.ras_width, rh.ras_height,
X				map, (u_char *) mpr_d(pr)->md_image, stdout,
X				 0, mpr_d(pr)->md_linebytes - rh.ras_width);
X			break;
X		case 9:
X			map = (unsigned char *) malloc(256);
X			color_map_3_to_1(colormap, map);
X		case 3:
X			error_diffusion_image(rh.ras_width, rh.ras_height,
X				map, (u_char *) mpr_d(pr)->md_image, stdout,
X				 1, mpr_d(pr)->md_linebytes - rh.ras_width);
X			break;
X		case 10:
X			map = (unsigned char *) malloc(256);
X			color_map_3_to_1(colormap, map);
X		case 4:
X			ordered_dither_image(rh.ras_width, rh.ras_height,
X				map, (u_char *) mpr_d(pr)->md_image, stdout,
X				 1, mpr_d(pr)->md_linebytes - rh.ras_width);
X			break;
X		case 11:
X			map = (unsigned char *) malloc(256);
X			color_map_3_to_1(colormap, map);
X		case 5:
X			dot_diffusion_image(rh.ras_width, rh.ras_height,
X				map, (u_char *) mpr_d(pr)->md_image, stdout,
X				 1, mpr_d(pr)->md_linebytes - rh.ras_width);
X			break;
X		}
X	else
X		switch (option) {
X		case 6:
X			map = (unsigned char *) malloc(256);
X			color_map_3_to_1(colormap, map);
X		case 0:
X			error_diffusion_file(rh.ras_width, rh.ras_height,
X					     map, stdin, stdout, 0,
X			     mpr_linebytes(rh.ras_width, 8) - rh.ras_width);
X			break;
X		case 7:
X			map = (unsigned char *) malloc(256);
X			color_map_3_to_1(colormap, map);
X		case 1:
X			ordered_dither_file(rh.ras_width, rh.ras_height,
X					    map, stdin, stdout, 0,
X			     mpr_linebytes(rh.ras_width, 8) - rh.ras_width);
X			break;
X		case 8:
X			map = (unsigned char *) malloc(256);
X			color_map_3_to_1(colormap, map);
X		case 2:
X			dot_diffusion_file(rh.ras_width, rh.ras_height,
X					   map, stdin, stdout, 0,
X			     mpr_linebytes(rh.ras_width, 8) - rh.ras_width);
X			break;
X		case 9:
X			map = (unsigned char *) malloc(256);
X			color_map_3_to_1(colormap, map);
X		case 3:
X			error_diffusion_file(rh.ras_width, rh.ras_height,
X					     map, stdin, stdout, 1,
X			     mpr_linebytes(rh.ras_width, 8) - rh.ras_width);
X			break;
X		case 10:
X			map = (unsigned char *) malloc(256);
X			color_map_3_to_1(colormap, map);
X		case 4:
X			ordered_dither_file(rh.ras_width, rh.ras_height,
X					    map, stdin, stdout, 1,
X			     mpr_linebytes(rh.ras_width, 8) - rh.ras_width);
X			break;
X		case 11:
X			map = (unsigned char *) malloc(256);
X			color_map_3_to_1(colormap, map);
X		case 5:
X			dot_diffusion_file(rh.ras_width, rh.ras_height,
X					   map, stdin, stdout, 1,
X			     mpr_linebytes(rh.ras_width, 8) - rh.ras_width);
X			break;
X		}
X}
X
color_map_3_to_1(colormap, map)
X	register colormap_t colormap;
X	register unsigned char *map;
X{
X	register unsigned long tmp, i;
X
X	for (i = 0; i < 256; i++) {
X		tmp = colormap.map[0][i] * 77 + colormap.map[1][i] * 151 + colormap.map[2][i] * 28;
X		map[i] = tmp >> 8;
X	}
X}
X
X
edge_enhancement(width, height, off)
X	register int width, height, off;
X{
X	register int i, j, x, y;
X
X	B[off][off] = A[off][off] * 6 - A[off][off + 1] - A[off + 1][off] - A[off + 1][off + 1];
X	B[off][off + height - 1] = A[off][off + height - 1] * 6 - A[off][off + height - 2] - A[off + 1][off + height - 1] - A[off + 1][off + height - 2];
X	B[off + width - 1][off] = A[off + width - 1][off] * 6 - A[off + width - 1][off + 1] - A[off + width - 2][off] - A[off + width - 2][off + 1];
X	B[off + width - 1][off + height - 1] = A[off + width - 1][off + height - 1] * 6 - A[off + width - 1][off + height - 2] - A[off + width - 2][off + height - 1] - A[off + width - 2][off + height - 2];
X
X	for (i = 1; i < width - 1; i++)
X		B[off + i][off + 0] = A[off + i][off + 0] * 6 - A[off + i - 1][off + 0] - A[off + i + 1][off + 0] - A[off + i - 1][off + 1] - A[off + i][off + 1] - A[off + i + 1][off + 1];
X	for (i = 1; i < width - 1; i++)
X		B[off + i][off + height - 1] = A[off + i][off + height - 1] * 6 - A[off + i - 1][off + height - 1] - A[off + i + 1][off + height - 2] - A[off + i - 1][off + height - 2] - A[off + i][off + 1] - A[off + i + 1][off + height - 2];
X	for (i = 1; i < height - 1; i++)
X		B[off + 0][off + i] = A[off + 0][off + i] * 6 - A[off + 0][off + i - 1] - A[off + 0][off + i + 1] - A[off + 1][off + i - 1] - A[off + 1][off + i] - A[off + 1][off + i + 1];
X	for (i = 1; i < height - 1; i++)
X		B[off + width - 1][off + i] = A[off + width - 1][off + i] * 6 - A[off + width - 1][off + i - 1] - A[off + width - 1][off + i + 1] - A[off + width - 2][off + i - 1] - A[off + width - 2][off + i] - A[off + width - 2][off + i + 1];
X
X	for (i = 1; i < width - 1; i++)
X		for (j = 1; j < height - 1; j++) {
X			B[off + i][off + j] = A[off + i][off + j] * 10;
X			for (x = i - 1; x <= i + 1; x++)
X				for (y = j - 1; y <= j + 1; y++)
X					B[off + i][off + j] -= A[off + x][off + y];
X		}
X
X	for (i = 0; i < width; i++)
X		for (j = 0; j < height; j++)
X			A[off + i][off + j] = B[off + i][off + j];
X}
X
X
int
index(x, y, w, pad)
X	register int x, y, w, pad;
X{
X	return (x + y * (w + pad));
X}
X
error_diffusion(width, height, out, edge)
X	register int width, height;
X	register FILE *out;
X	register int edge;
X{
X	register int err, mono_pad;
X	register u_short dtmp;
X	register u_long i, j;
X
X	mono_pad = mpr_linebytes(width, 1) * 8 - width;
X
X	if (edge)
X		edge_enhancement(width, height, 1);
X
X	for (j = 1; j < height + 1; j++) {
X		for (i = 1; i < width + 1; i++) {
X			dtmp <<= 1;
X			if (A[i][j] > 128)
X				err = A[i][j] - 256;
X			else {
X				err = A[i][j];
X				dtmp |= 1;
X			}
X			A[i + 1][j] += (err * ALPHA) >> 4;
X			A[i - 1][j + 1] += (err * BETA) >> 4;
X			A[i][j + 1] += (err * GAMMA) >> 4;
X			A[i + 1][j + 1] += (err * DELTA) >> 4;
X			if (((i - 1) % 16) == 15) {
X				putc(dtmp >> 8, out);
X				putc(dtmp, out);
X			}
X		}
X		for (i = width + 1; i <= width + mono_pad; i++) {
X			dtmp <<= 1;
X			if (((i - 1) % 16) == 15) {
X				putc(dtmp >> 8, out);
X				putc(dtmp, out);
X			}
X		}
X	}
X}
X
X/* Compute pixel values using error diffusion */
error_diffusion_image(width, height, map, in, out, edge_enhance, pad)
X	register int width, height;
X	register unsigned char *map;
X	register u_char *in;
X	register FILE *out;
X	register int edge_enhance, pad;
X{
X	register int i, j;
X
X	for (j = 1; j < height + 1; j++)
X		for (i = 1; i < width + 1; i++)
X			A[i][j] = map[*(in + index(i - 1, j - 1, width, pad))];
X
X	error_diffusion(width, height, out, edge_enhance);
X}
X
X
X/* Compute pixel values using error diffusion */
error_diffusion_file(width, height, map, in, out, edge_enhance, pad)
X	register int width, height;
X	register unsigned char *map;
X	register FILE *in, *out;
X	register int edge_enhance, pad;
X{
X	register int i, j, c;
X
X	for (j = 1; j < height + 1; j++) {
X		for (i = 1; i < width + 1; i++) {
X			if ((c = getc(in)) == EOF) {
X				fprintf(stderr, "error reading raster data!\n");
X				exit(1);
X			}
X			A[i][j] = map[c];
X		}
X		for (i = width; i < width + pad; i++)
X			if ((c = getc(in)) == EOF)
X				fprintf(stderr, "error reading raster data!\n");
X	}
X
X	error_diffusion(width, height, out, edge_enhance);
X}
X
ordered(width, height, out, edge)
X	register int width, height;
X	register FILE *out;
X	register int edge;
X{
X	register int mono_pad;
X	register u_short dtmp;
X	register u_long i, j;
X
X	mono_pad = mpr_linebytes(width, 1) * 8 - width;
X
X	if (edge)
X		edge_enhancement(width, height, 0);
X
X	for (j = 0; j < 8; j++)
X		for (i = 0; i < 8; i++)
X			ordered_dither[i][j] = ordered_dither[i][j] * 4 + 2;
X
X	for (j = 0; j < height; j++) {
X		for (i = 0; i < width; i++) {
X			dtmp <<= 1;
X			if (A[i][j] >= ordered_dither[i % 8][j % 8])
X				dtmp |= 1;
X			if ((i % 16) == 15) {
X				putc(dtmp >> 8, out);
X				putc(dtmp, out);
X			}
X		}
X		for (i = width; i < width + mono_pad; i++) {
X			dtmp <<= 1;
X			if ((i % 16) == 15) {
X				putc(dtmp >> 8, out);
X				putc(dtmp, out);
X			}
X		}
X	}
X}
X
ordered_dither_image(width, height, map, in, out, edge_enhance, pad)
X	register int width, height;
X	register unsigned char *map;
X	register u_char *in;
X	register FILE *out;
X	register int edge_enhance, pad;
X{
X	register int i, j;
X
X	for (j = 0; j < height; j++)
X		for (i = 0; i < width; i++)
X			A[i][j] = 256 - map[*(in + index(i, j, width, pad))];
X
X	ordered(width, height, out, edge_enhance);
X}
X
X
ordered_dither_file(width, height, map, in, out, edge_enhance, pad)
X	register int width, height;
X	register unsigned char *map;
X	register FILE *in, *out;
X	register int edge_enhance, pad;
X{
X	register int i, j, c;
X
X	for (j = 0; j < height; j++) {
X		for (i = 0; i < width; i++) {
X			if ((c = getc(in)) == EOF) {
X				fprintf(stderr, "error reading raster data!\n");
X				exit(1);
X			}
X			A[i][j] = 256 - map[c];
X		}
X		for (i = width; i < width + pad; i++)
X			if ((c = getc(in)) == EOF)
X				fprintf(stderr, "error reading raster data!\n");
X	}
X
X	ordered(width, height, out, edge_enhance);
X}
X
int
weight(x, y)
X	register int x, y;
X{
X	return (3 - x * x - y * y);
X}
X
dot(width, height, out, edge)
X	register int width, height;
X	register FILE *out;
X	register int edge;
X{
X	register int k, u, v, err, w, mono_pad;
X	register u_short dtmp;
X	register u_long i, j;
X
X	mono_pad = mpr_linebytes(width, 1) * 8 - width;
X
X	if (edge)
X		edge_enhancement(width, height, 0);
X
X	for (k = 0; k < 64; k++) {
X		for (i = reverse_matrix[k] / 8; i < width; i += 8)
X			for (j = reverse_matrix[k] % 8; j < height; j += 8) {
X				if (A[i][j] > 128)
X					B[i][j] = 0;
X				else
X					B[i][j] = 1;
X				err = A[i][j] - (1 - B[i][j]) * 256;
X				w = 0;
X				for (u = i - 1; u <= i + 1; u++)
X					for (v = j - 1; v <= j + 1; v++)
X						if ((u >= 0) && (v >= 0) && (dot_diffusion[u % 8][v % 8] > k))
X							w += weight(u - i, v - j);
X				if (w > 0) {
X					for (u = i - 1; u <= i + 1; u++)
X						for (v = j - 1; v <= j + 1; v++)
X							if ((u >= 0) && (v >= 0) && (dot_diffusion[u % 8][v % 8] > k))
X								A[u][v] += err * weight(u - i, v - j) / w;
X				}
X			}
X	}
X
X	for (j = 0; j < height; j++) {
X		for (i = 0; i < width; i++) {
X			dtmp <<= 1;
X			if (B[i][j])
X				dtmp |= 1;
X			if ((i % 16) == 15) {
X				putc(dtmp >> 8, out);
X				putc(dtmp, out);
X			}
X		}
X		for (i = width; i < width + mono_pad; i++) {
X			dtmp <<= 1;
X			if ((i % 16) == 15) {
X				putc(dtmp >> 8, out);
X				putc(dtmp, out);
X			}
X		}
X	}
X}
X
X
dot_diffusion_image(width, height, map, in, out, edge_enhance, pad)
X	register int width, height;
X	register unsigned char *map;
X	register u_char *in;
X	register FILE *out;
X	register int edge_enhance, pad;
X{
X	register int i, j;
X
X	for (j = 0; j < height; j++)
X		for (i = 0; i < width; i++)
X			A[i][j] = map[*(in + index(i, j, width, pad))];
X
X	dot(width, height, out, edge_enhance);
X}
X
dot_diffusion_file(width, height, map, in, out, edge_enhance, pad)
X	register int width, height;
X	register unsigned char *map;
X	register FILE *in, *out;
X	register int edge_enhance, pad;
X{
X	register int i, j, c;
X
X	for (j = 0; j < height; j++) {
X		for (i = 0; i < width; i++) {
X			if ((c = getc(in)) == EOF) {
X				fprintf(stderr, "error reading raster data!\n");
X				exit(1);
X			}
X			A[i][j] = map[c];
X		}
X		for (i = width; i < width + pad; i++)
X			if ((c = getc(in)) == EOF)
X				fprintf(stderr, "error reading raster data!\n");
X	}
X
X	dot(width, height, out, edge_enhance);
X}
END_OF_FILE
if test 16965 -ne `wc -c <'src/ras8to1.c'`; then
    echo shar: \"'src/ras8to1.c'\" unpacked with wrong size!
fi
# end of 'src/ras8to1.c'
fi
echo shar: End of archive 8 \(of 10\).
cp /dev/null ark8isdone
MISSING=""
for I in 1 2 3 4 5 6 7 8 9 10 ; do
    if test ! -f ark${I}isdone ; then
	MISSING="${MISSING} ${I}"
    fi
done
if test "${MISSING}" = "" ; then
    echo You have unpacked all 10 archives.
    rm -f ark[1-9]isdone ark[1-9][0-9]isdone
else
    echo You still need to unpack the following archives:
    echo "        " ${MISSING}
fi
##  End of shell archive.
exit 0