raju@gwusun.gwu.edu (D. Murali Raju) (04/14/89)
Greetings! Net, I threw together a bunch of SunView programs to view FaceSaver pictures from uunet. They are adapted from Jeff Michaud's xface program that runs under X-Windows. Thought somebody in netland might be interested. sunface - displays a FaceSaver picture on a Sun Workstation using SunView. Needs an 8-plane (at least) display for the 256 gray levels. sunfaced - same as sunface above, except for single-plane B/W Sun Workstations. Uses dithering to simulate intensities. Enjoy! Send bugs/fixes/gripes/comments to me via e-mail (I don't get to read this newsgroup very often). P.S. I'm mailing a copy to uunet.uu.net to be made available for anonymous ftp, and hopefully it will be found somewhere in the directory with the FaceSaver pictures. ---------------------------------------------------------------------------- D. Murali Raju (raju@gwusun.gwu.edu || ..!uunet!gwusun!raju || 202-994-6853) System Programmer, SEAS/CF, GWU, 725 23rd Street, N.W., Washington, DC 20052 #include <usual/stinkin/disclaimer.h> ... keeping my fingers in the pies ... -------------Cut here------------------------------------------------------- #! /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 shell archive." # Contents: Makefile README sunface.1 sunface.c sunfaced.1 sunfaced.c # Wrapped by raju@gwusun on Thu Apr 13 11:38:09 1989 PATH=/bin:/usr/bin:/usr/ucb ; export PATH if test -f 'Makefile' -a "${1}" != "-c" ; then echo shar: Will not clobber existing file \"'Makefile'\" else echo shar: Extracting \"'Makefile'\" \(180 characters\) sed "s/^X//" >'Makefile' <<'END_OF_FILE' Xall: sunface sunfaced X Xsunface: sunface.c X cc -o sunface sunface.c -lsuntool -lsunwindow -lpixrect X Xsunfaced: sunfaced.c X cc -o sunfaced sunfaced.c -lsuntool -lsunwindow -lpixrect END_OF_FILE if test 180 -ne `wc -c <'Makefile'`; then echo shar: \"'Makefile'\" unpacked with wrong size! fi # end of 'Makefile' fi if test -f 'README' -a "${1}" != "-c" ; then echo shar: Will not clobber existing file \"'README'\" else echo shar: Extracting \"'README'\" \(673 characters\) sed "s/^X//" >'README' <<'END_OF_FILE' XSuntools versions of Jeff Michaud's (michaud@decvax.dec.com) xface Xprogram on uunet. X X sunface - displays a FaceSaver picture on a Sun Workstation using SunView. X Needs an 8-plane (at least) display for the 256 gray levels. X X sunfaced - same as sunface, except for single-plane B/W Sun Workstations. X Uses dithering to simulate intensities. X XNOTE: You must be running Suntools to execute these programs. X XCheck out the simple makefile, and the man pages. X X Enjoy! X X XPlease mail bugs/fixes to the author: X X D. Murali Raju <raju@gwusun.gwu.edu> X (UUCP Mail: ...!uunet!gwusun!raju) X The George Washington University, Washington, DC. END_OF_FILE if test 673 -ne `wc -c <'README'`; then echo shar: \"'README'\" unpacked with wrong size! fi # end of 'README' fi if test -f 'sunface.1' -a "${1}" != "-c" ; then echo shar: Will not clobber existing file \"'sunface.1'\" else echo shar: Extracting \"'sunface.1'\" \(1493 characters\) sed "s/^X//" >'sunface.1' <<'END_OF_FILE' X.TH sunface 1U X.SH NAME Xsunface \- displays a FaceSaver picture on a Sun Workstation using SunView. X.SH SYNTAX X\fBsunface\fP [-e \fIexpansion\fP] [-x] [\fIfilename\fP] X.SH DESCRIPTION X\fBsunface\fP is a SunView program that displays FaceSaver pictures on an 8-plane Sun workstation. X.SH OPTIONS XThe '-e' option allows you to expand the picture by an integer amount. XFor example, viewing a 320x200 picture with an expansion factor of '2' Xwill result in a 640x400 picture, each pixel of which is a 2x2 block. XThe default expansion factor is 2 to get a decent sized picture, since Xmost FaceSaver pictures look pretty tiny on the big Sun display. X.PP XThe '-x' option turns on some debugging output showing progress of the Xprogram. X.PP XAlso, it should be noted that if the optional \fIfilename\fP is not supplied, Xthe program will read the picture from stdin. X.SH LIMITATIONS XYou need (at least) an 8-plane Sun Workstation display, and must be Xrunning \fBsuntools\fP. X.PP XFor display on a visually impaired single bit-plane workstation, Xsee \fBsunfaced\fP, a related program that displays a dithered image. X.PP X.SH AUTHOR XD. Murali Raju <raju@gwusun.gwu.edu> X.PP XThis program (and man page) was adapted from Jeff Michaud's X(michaud@decvax.dec.com) xface program on uunet, which in turn was Xadapted from xgif, by John Bradley (bradley@cis.upenn.edu), which was Xbased (heavily) on gif2ras.c, by Patrick J. Naughton X(naughton@wind.sun.com), a program that converts GIF pictures to Sun XRasterfiles. END_OF_FILE if test 1493 -ne `wc -c <'sunface.1'`; then echo shar: \"'sunface.1'\" unpacked with wrong size! fi # end of 'sunface.1' fi if test -f 'sunface.c' -a "${1}" != "-c" ; then echo shar: Will not clobber existing file \"'sunface.c'\" else echo shar: Extracting \"'sunface.c'\" \(6302 characters\) sed "s/^X//" >'sunface.c' <<'END_OF_FILE' X/* X * Display a face from the uunet FaceSaver picture library. X * X * Uses SunView - Needs at least an 8-plane display for 256 gray levels. X * (for a single-plane version see sunfaced.c, a dithered version) X * X * Date: Sun Apr 9 14:50:02 1989 X * X * Author: D. Murali Raju X * Computing Facility, School of Engineering and Applied Science, X * The George Washington University, Washington, DC 20052. X * Internet: raju@gwusun.gwu.edu UUCP: ...!uunet!gwusun!raju X * X * Hacked from Jeff Michaud's <michaud@decvax.dec.com> xface program on uunet. X */ X X#include <stdio.h> X Xtypedef unsigned char byte; X X#define True 1 X#define False 0 X X#define BUFSIZE 1024 X#define PIXSIZE 2 X#define MAXBPL 15 /* Max bytes per output line in resultant XBM */ X Xchar line[BUFSIZE]; X Xchar firstname[BUFSIZE]; Xchar lastname [BUFSIZE]; Xchar email [BUFSIZE]; X Xint depth; Xint iwidth, iheight, idepth; X Xint totalpixels; X Xbyte *Image; /* The final image array */ X Xint XC = 0, YC = 0, /* Output X and Y coords of current pixel */ X Width, Height, /* image dimensions */ X BytesPerScanline; /* bytes per scanline in output raster */ X XFILE *fp; X Xchar *cmd; X XSyntax() X{ X printf("Usage: %s [-e expansion] [-x] filename\n",cmd); X exit(1); X} X XFatalError (identifier) X char *identifier; X{ X fprintf(stderr, "%s: %s\n",cmd, identifier); X exit(-1); X} X XReadFace(fname) X char *fname; X{ X if (strcmp(fname,"-")==0) { X fp = stdin; X fname = "<stdin>"; X } else X fp = fopen(fname,"r"); X X if (!fp) FatalError("file not found"); X X InitImage(); X X /* Allocate the Image */ X Image = (byte *) malloc(Width*Height); X if (!Image) FatalError("not enough memory for Image"); X X BytesPerScanline = Width; X X YC = Height - 1; X XC = 0; X X ReadItIn(); X} X XInitImage() X{ X fgets(line, BUFSIZE, fp); X sscanf(line, "%*s %s", firstname); X X fgets(line, BUFSIZE, fp); X sscanf(line, "%*s %s", lastname); X X fgets(line, BUFSIZE, fp); X sscanf(line, "%*s %s", email); X X fgets(line, BUFSIZE, fp); X sscanf(line, "%*s %d %d %d", &Width, &Height, &depth); X X fgets(line, BUFSIZE, fp); X sscanf(line, "%*s %d %d %d", &iwidth, &iheight, &idepth); X X fgets(line, BUFSIZE, fp); X X totalpixels = Width * Height; X} X X/* Scan line Enum junk */ X char *enum_ptr; /* local to enum routines */ Xvoid Xinit_enum(buf) X char *buf; X{ X enum_ptr = buf; X} X Xint Xnext_enum(out) X char *out; X{ X if( enum_ptr[0] == '\n' || enum_ptr[0] == '\0' ) X return False; X X strncpy(out, enum_ptr, PIXSIZE); X out[PIXSIZE] = '\0'; X enum_ptr += PIXSIZE; X X return True; X} X XReadItIn() X{ X while( fgets(line, BUFSIZE, fp) != NULL ) { X char pixel[PIXSIZE+1]; X X init_enum(line); X X while( next_enum(pixel) ) { X unsigned int value; X X sscanf(pixel, "%x", &value); X AddToPixel((byte)value); X } X } X} X XAddToPixel(Index) Xbyte Index; X{ X if (YC >= 0) X *(Image + YC * BytesPerScanline + XC) = Index; X X/* Update the X-coordinate, and if it overflows, update the Y-coordinate */ X X if (++XC == Width) { X XC = 0; X YC--; X } X} X X/* --- SunView Stuff from here on --------------*/ X X#include <suntool/sunview.h> X#include <suntool/canvas.h> X X#define CMS_SIZE 256 /* Color Map size (Lookup Table) */ X XFrame frame; /* Type defined by sunview */ XCanvas canvas; /* Type defined by sunview */ XRect CanvRect; XRect *crect; XPixwin *pw; Xint MulFac, CanH, CanW; Xint ResX, ResY; /* Image size */ Xint debugFlag = 0; X XLoad256Gray() X{ X /* Set Gray Scale color map */ X register int i; X u_char r[CMS_SIZE], g[CMS_SIZE], b[CMS_SIZE]; X X for (i = 0 ; i < 256 ; ++i ) X r[i] = g[i] = b[i] = i; X X pw_setcmsname(pw, "GRAY"); X pw_putcolormap(pw, 0, CMS_SIZE, r, g, b); X} X XLoadImage() X{ X register int i, j; X X if (MulFac==1) { X pw_lock (pw, crect); X for (j=ResY-1;j>=0;j--) X for (i=0;i<ResX;i++) X pw_put(pw, i, j, (int) *(Image + j*BytesPerScanline+i)); X pw_unlock (pw); X } else { X for (j=ResY-1;j>=0;j--) { X pw_lock (pw, crect); X for (i=0;i<ResX;i++) X pw_writebackground (pw, i*MulFac, j*MulFac, MulFac, MulFac, X PIX_SRC | PIX_COLOR((int) *(Image + j*BytesPerScanline+i))); X pw_unlock (pw); X } X } X} X Xmain(argc, argv) X int argc; X char *argv[]; X{ X int i; X char *fname; X char Wname[100]; X X cmd = argv[0]; X MulFac = 2; /* Default Magnification 2 for now */ X X /*********************Options*********************/ X X for (i = 1; i < argc; i++) { X X if (!strncmp(argv[i],"-e",2)) { /* Expansion */ X i++; X sscanf(argv[i], "%d", &MulFac); X continue; X } X X if (!strncmp(argv[i],"-x",2)) { /* Debug messages */ X debugFlag++; X continue; X } X X if (argv[i][0] != '-') { /* the file name */ X fname = argv[i]; X continue; X } X X Syntax(); X } X X if (fname==NULL) fname="-"; X X if (debugFlag) X printf ("Reading image data from file \"%s\" ...\n", fname); X X ReadFace(fname); X X if (debugFlag) X printf ("Image expansion factor is %d.\n", MulFac); X X if (debugFlag) X printf ("Creating Frame and Canvas ...\n"); X X ResY = Height; X ResX = Width; X X /* Create frame & canvas */ X sprintf (Wname, "%s %s <%s> (Size: %dx%dx%d)", firstname, lastname, email, X Width, Height, depth); X frame = window_create (0, FRAME, FRAME_LABEL, Wname, 0); X X CanH = MulFac * ResY; X CanW = MulFac * ResX; X X canvas = window_create (frame, CANVAS, X WIN_HEIGHT, CanH, X WIN_WIDTH, CanW, 0); X CanvRect.r_left = 0; X CanvRect.r_top = 0; X CanvRect.r_width = CanW; X CanvRect.r_height = CanH; X X crect = (&CanvRect); X X window_fit(frame); X pw = canvas_pixwin(canvas); X X if (debugFlag) X printf ("Creating 256 Level Gray Scale Lookup Table ... \n"); X Load256Gray(); X X if (debugFlag) X printf ("Painting Image ...\n"); X LoadImage(); X X if (debugFlag) X printf ("Done. Waiting for a ^C or Quit from the Image Window.\n"); X else X fprintf (stderr, X "Done. Waiting for a ^C or Quit from the Image Window.\n"); X X window_main_loop(frame); X exit(0); X} END_OF_FILE if test 6302 -ne `wc -c <'sunface.c'`; then echo shar: \"'sunface.c'\" unpacked with wrong size! fi # end of 'sunface.c' fi if test -f 'sunfaced.1' -a "${1}" != "-c" ; then echo shar: Will not clobber existing file \"'sunfaced.1'\" else echo shar: Extracting \"'sunfaced.1'\" \(1887 characters\) sed "s/^X//" >'sunfaced.1' <<'END_OF_FILE' X.TH sunfaced 1U X.SH NAME Xsunfaced \- displays a FaceSaver picture on a B/W Sun Workstation using SunView. X.SH SYNTAX X\fBsunfaced\fP [-d <1 | 2 | 4 | 8 | 16>] [-e \fIexpansion\fP] [-x] [\fIfilename\fP] X.SH DESCRIPTION X\fBsunfaced\fP is a SunView program that displays FaceSaver pictures on Xan single bitplane black and white Sun workstation, using dithering Xto simulate intensities. X.SH OPTIONS XThe '-d' option specifies the size of the dither matrix and must have Xone of the following integer values: 1, 2, 4, 8, 16. If the value Xselected is 1 then no dithering is done and the image displayed is Xsimply thresholded at the value 127. For a choice of n as the Xdither matrix size, n*n is the number of intensities simulated. XThe default value of n is 16. X.PP XThe '-e' option allows you to expand the picture by an integer amount. XFor example, viewing a 320x200 picture with an expansion factor of '2' Xwill result in a 640x400 picture, each pixel of which is a 2x2 block. XThe default value is 6, because some magnification is needed to get Xa decent simulation of intensities. X.PP XThe '-x' option turns on some debugging output showing progress of the Xprogram. X.PP XAlso, it should be noted that if the optional \fIfilename\fP is not supplied, Xthe program will read the picture from stdin. X.SH LIMITATIONS XYou need a Sun Workstation, and must be running \fBsuntools\fP. X.PP XIf you have a display that has 8 bit-planes or more, try \fBsunface\fP, a Xrelated program that displays a real gray scale image. X.PP X.SH AUTHOR XD. Murali Raju <raju@gwusun.gwu.edu> X.PP XThis program (and man page) was adapted from Jeff Michaud's X(michaud@decvax.dec.com) xface program on uunet, which in turn was Xadapted from xgif, by John Bradley (bradley@cis.upenn.edu), which was Xbased (heavily) on gif2ras.c, by Patrick J. Naughton X(naughton@wind.sun.com), a program that converts GIF pictures to Sun XRasterfiles. END_OF_FILE if test 1887 -ne `wc -c <'sunfaced.1'`; then echo shar: \"'sunfaced.1'\" unpacked with wrong size! fi # end of 'sunfaced.1' fi if test -f 'sunfaced.c' -a "${1}" != "-c" ; then echo shar: Will not clobber existing file \"'sunfaced.c'\" else echo shar: Extracting \"'sunfaced.c'\" \(9008 characters\) sed "s/^X//" >'sunfaced.c' <<'END_OF_FILE' X/* X * Display a face from the uunet FaceSaver picture library X * X * Uses SunView - Dithered version for visually impaired single bit-plane X * Sun Workstations. X * X * Date: Sun Apr 9 14:50:02 1989 X * X * Author: D. Murali Raju X * Computing Facility, School of Engineering and Applied Science, X * The George Washington University, Washington, DC 20052. X * Internet: raju@gwusun.gwu.edu UUCP: ...!uunet!gwusun!raju X * X * Hacked from Jeff Michaud's <michaud@decvax.dec.com> xface program on uunet. X */ X X#include <stdio.h> X Xtypedef unsigned char byte; X X#define True 1 X#define False 0 X X#define BUFSIZE 1024 X#define PIXSIZE 2 X#define MAXBPL 15 /* Max bytes per output line in resultant XBM */ X Xchar line[BUFSIZE]; X Xchar firstname[BUFSIZE]; Xchar lastname [BUFSIZE]; Xchar email [BUFSIZE]; X Xint depth; Xint iwidth, iheight, idepth; X Xint totalpixels; X Xbyte *Image; /* The final image array */ X Xint XC = 0, YC = 0, /* Output X and Y coords of current pixel */ X Width, Height, /* image dimensions */ X BytesPerScanline; /* bytes per scanline in output raster */ X XFILE *fp; X Xchar *cmd; X X XSyntax() X{ X printf("Usage: %s [-d <1|2|4|8|16>] [-e expansion] [-x] filename\n", cmd); X exit(1); X} X XFatalError (identifier) X char *identifier; X{ X fprintf(stderr, "%s: %s\n",cmd, identifier); X exit(-1); X} X XReadFace(fname) X char *fname; X{ X if (strcmp(fname,"-")==0) { X fp = stdin; X fname = "<stdin>"; X } else X fp = fopen(fname,"r"); X X if (!fp) FatalError("file not found"); X X InitImage(); X X /* Allocate the Image */ X Image = (byte *) malloc(Width*Height); X if (!Image) FatalError("not enough memory for Image"); X X BytesPerScanline = Width; X X YC = Height - 1; X XC = 0; X X ReadItIn(); X} X XInitImage() X{ X fgets(line, BUFSIZE, fp); X sscanf(line, "%*s %s", firstname); X X fgets(line, BUFSIZE, fp); X sscanf(line, "%*s %s", lastname); X X fgets(line, BUFSIZE, fp); X sscanf(line, "%*s %s", email); X X fgets(line, BUFSIZE, fp); X sscanf(line, "%*s %d %d %d", &Width, &Height, &depth); X X fgets(line, BUFSIZE, fp); X sscanf(line, "%*s %d %d %d", &iwidth, &iheight, &idepth); X X fgets(line, BUFSIZE, fp); X X totalpixels = Width * Height; X} X X/* Scan line Enum junk */ X char *enum_ptr; /* local to enum routines */ Xvoid Xinit_enum(buf) X char *buf; X{ X enum_ptr = buf; X} X Xint Xnext_enum(out) X char *out; X{ X if( enum_ptr[0] == '\n' || enum_ptr[0] == '\0' ) X return False; X X strncpy(out, enum_ptr, PIXSIZE); X out[PIXSIZE] = '\0'; X enum_ptr += PIXSIZE; X X return True; X} X XReadItIn() X{ X while( fgets(line, BUFSIZE, fp) != NULL ) { X char pixel[PIXSIZE+1]; X X init_enum(line); X X while( next_enum(pixel) ) { X unsigned int value; X X sscanf(pixel, "%x", &value); X AddToPixel((byte)value); X } X } X} X XAddToPixel(Index) Xbyte Index; X{ X if (YC >= 0) X *(Image + YC * BytesPerScanline + XC) = Index; X X/* Update the X-coordinate, and if it overflows, update the Y-coordinate */ X X if (++XC == Width) { X XC = 0; X YC--; X } X} X Xint d_mat[16][16]; /* Dither Matrix (Max size = 16) */ Xint d2_mat[2][2] = { 0, 2, 3, 1 }; /* The base dither matrix */ Xint dmSize; /* Current Dither Matrix size */ X XGetDitherMatrix (mat_size) Xint mat_size; X{ X register int i, j, n; X int SizeOk, m, i1, i2, j1, j2; X float scale; X X /* X * Check for legal Matrix Size: 2, 4, 8, 16 are the only allowed values X */ X SizeOk = False; X for (i=1; i<5; i++) { X if (mat_size == 1<<i) X SizeOk = True; X } X X if (!SizeOk) { X fprintf (stderr, "GetDitherMatrix: Bad size! (%d)\n", mat_size); X exit (-1); X } X dmSize = mat_size; X X /* X * Generate the NxN Dither Matrix. (Using Equation 6 of reference X * article by Jarvis, Judice and Ninke in Computer Graphics and Image X * Processing 5, 13-40, (MAR '76) X */ X X /* First start with base matrix */ X for (i=0; i<2; i++) { X for (j=0; j<2; j++) { X d_mat[i][j] = d2_mat[i][j]; X } X } X X /* Replicate Matrix as needed */ X if (dmSize > 2) { X for (n=2; n < dmSize; n = 2*n) { X for (i=0; i<n; i++) { X for (j=0; j<n; j++) { X d_mat[i][j] = 4 * d_mat[i][j]; X } X } X m = 2*n; X for (i=0; i<m; i++) { X for (j=0; j<m; j++) { X i1 = i % n; i2 = i / n; X j1 = j % n; j2 = j / n; X d_mat[i][j] = d_mat[i1][j1] + d2_mat[i2][j2]; X } X } X } X } X X /* Scale all elements to max intensity of 255 */ X if (mat_size < 16) { X scale = 255.0 / (float) (dmSize*dmSize - 1); X for (i=0; i<dmSize; i++) { X for (j=0; j<dmSize; j++) { X if (d_mat[i][j] != 0) X d_mat[i][j] = (int) (0.5 + scale*(float) d_mat[i][j]); X } X } X } X} X Xint PxVal (val, i, j) Xint val, i, j; X{ X if (dmSize < 2) X return((val > 127) ? 0 : 1); X else X return((val > d_mat[i%dmSize][j%dmSize]) ? 0 : 1); X} X XPrintDitherMatrix() X{ X register int i, j; X X for (i=0; i<dmSize; i++) { X for (j=0; j<dmSize; j++) X printf ("%3.3d ", d_mat[i][j]); X printf ("\n"); X } X} X X/* --- SunView Stuff from here on --------------*/ X X#include <suntool/sunview.h> X#include <suntool/canvas.h> X XFrame frame; /* Type defined by sunview */ XCanvas canvas; /* Type defined by sunview */ XRect CanvRect; XRect *crect; XPixwin *pw; Xint MulFac, CanH, CanW; Xint ResX, ResY; /* Image size */ Xint debugFlag = 0; X XLoadDitheredImage() X{ X register int i, j, ival, ip, jp; X int PxVal(); X int js, je, is, ie; X X if (MulFac==1) { X pw_lock (pw, crect); X for (j=ResY-1;j>=0;j--) { X for (i=0;i<ResX;i++) { X ival = PxVal((int) *(Image + j*BytesPerScanline+i), i, j); X pw_put(pw, i, j, ival); X } X } X pw_unlock (pw); X } else { X for (j=ResY-1;j>=0;j--) { X js = j*MulFac; je = js + MulFac; X pw_lock (pw, crect); X for (i=0;i<ResX;i++) { X is = i*MulFac; ie = is + MulFac; X ival = (int) *(Image + j*BytesPerScanline+i); X for (jp=js; jp<je; jp++) { X for (ip=is; ip<ie; ip++) X pw_put(pw, ip, jp, PxVal(ival, ip, jp)); X } X } X pw_unlock (pw); X } X } X} X X X Xmain(argc, argv) X int argc; X char *argv[]; X{ X int i; X char *fname; X char Wname[100]; X X cmd = argv[0]; X MulFac = 6; /* Magnification 6 for now as default */ X dmSize = 16; /* 16x16 Dither Matrix for now as default */ X X /*********************Options*********************/ X X for (i = 1; i < argc; i++) { X X X if (!strncmp(argv[i],"-e",2)) { /* Magnification */ X i++; X sscanf(argv[i], "%d", &MulFac); X continue; X } X X if (!strncmp(argv[i],"-d",2)) { /* Dither Factor */ X i++; X sscanf(argv[i], "%d", &dmSize); X continue; X } X X if (!strncmp(argv[i],"-x",2)) { /* Debug messages */ X debugFlag++; X continue; X } X X if (argv[i][0] != '-') { /* the file name */ X fname = argv[i]; X continue; X } X X Syntax(); X } X X if (fname==NULL) fname="-"; X X /* First, crank out dither matrix */ X if (dmSize > 1) { X if (debugFlag) X printf ("Creating %dx%d Dither Matrix ...\n", dmSize, dmSize); X GetDitherMatrix (dmSize); X if (debugFlag) X PrintDitherMatrix(); X } else X printf ("No dithering! Thresholding at value=127 ...\n"); X X if (debugFlag) X printf ("Reading image data from file \"%s\" ...\n", fname); X X ReadFace(fname); X X if (debugFlag) X printf ("Image expansion factor is %d.\n", MulFac); X X if (debugFlag) X printf ("Creating Frame and Canvas ...\n"); X X ResY = Height; X ResX = Width; X X /* Create frame & canvas */ X if (dmSize > 1) X sprintf (Wname, "%s %s <%s> (Size: %dx%dx%d) Dithered %dx%d", X firstname, lastname, email, Width, Height, depth, X dmSize, dmSize); X else X sprintf (Wname, "%s %s <%s> (Size: %dx%dx%d) Undithered.", X firstname, lastname, email, Width, Height, depth); X frame = window_create (0, FRAME, FRAME_LABEL, Wname, 0); X X CanH = MulFac * ResY; X CanW = MulFac * ResX; X X canvas = window_create (frame, CANVAS, X WIN_HEIGHT, CanH, X WIN_WIDTH, CanW, 0); X CanvRect.r_left = 0; X CanvRect.r_top = 0; X CanvRect.r_width = CanW; X CanvRect.r_height = CanH; X X crect = (&CanvRect); X X window_fit(frame); X pw = canvas_pixwin(canvas); X X if (debugFlag) X printf ("Painting Image ...\n"); X LoadDitheredImage(); X X if (debugFlag) X printf ("Done. Waiting for a ^C or Quit from the Image Window.\n"); X else X fprintf (stderr, X "Done. Waiting for a ^C or Quit from the Image Window.\n"); X X window_main_loop(frame); X exit(0); X} END_OF_FILE if test 9008 -ne `wc -c <'sunfaced.c'`; then echo shar: \"'sunfaced.c'\" unpacked with wrong size! fi # end of 'sunfaced.c' fi echo shar: End of shell archive. echo "Remember! Needs suntools. Go ahead and make!" exit 0
rick@uunet.UU.NET (Rick Adams) (04/14/89)
This program (and all the programs I have seen that read facesaver data) is going to break this summer. The face saver data consists of a header and the face data separated by a blank line. The header consists of lines beginning with keywords. THERE IS NO GUARANTEE OF THE ORDER OR NUMBER OF LINES IN THE HEADER. You MUST parse the keywords and look for the blank line separator if you want to be able to use any new data we add. When/if more faces are collected at the Baltimore conference, the WILL NOT be in the exact same format. They WILL be consistant with the format which is keyword identified headers separated by a blank line from the data. I'm not picking on this program, but so far all of the 3 programs I have seen presume fixed format headers. This is not the case. --rick
jef@surf.ee.lbl.gov (Jef Poskanzer) (04/14/89)
Once again, I have to point out that the non-square pixels in some FaceSaver files are not being handled. If your face happens to be one of the 50% or so that use square pixels, then fine. If your face was done with non-square pixels but you don't mind looking FAT, then that's fine too. Otherwise, you might want to wait for a better program, such as my fstopgm, which by the way parses the headers correctly too (thanks Rick for mentioning that). --- Jef Jef Poskanzer jef@helios.ee.lbl.gov ...well!pokey "Text processing has made it possible to right-justify any idea, even one which cannot be justified on any other grounds." -- J. Finnegan, USC
raju@gwusun.gwu.edu (D. Murali Raju) (04/15/89)
Rick Adams writes: > > This program (and all the programs I have seen that read facesaver data) > is going to break this summer. > ... > You MUST parse the keywords and look for the blank line separator if you want > to be able to use any new data we add. > ... > What a bummer! Oh, well! Back to the drawing board ... Will fix it up and repost. Thanks to Rick for pointing it out! -Murali -- D. Murali Raju (raju@gwusun.gwu.edu || ..!uunet!gwusun!raju || 202-994-6853) System Programmer (SEAS-CF), GWU, 725 23rd Street N.W., Washington, DC 20052 #include <usual/stinkin/disclaimer.h> ... keeping my fingers in the pies ...