From raju@gwusun.gwu.edu Thu Apr 13 15:01:18 1989 Received: from GWUSUN.GWU.EDU by uunet.UU.NET (5.61/1.14) with SMTP id AA16635; Thu, 13 Apr 89 15:01:04 -0400 Received: by gwusun (4.1/25-eef) id AA11888; Thu, 13 Apr 89 15:00:52 EDT From: raju@gwusun.gwu.edu (D. Murali Raju) Message-Id: <8904131900.AA11888@gwusun> Subject: Programs for viewing UUNET FaceSaver faces on Sun Workstations. To: rick@uunet.UU.NET Date: Thu, 13 Apr 89 15:00:50 EDT X-Mailer: Elm [version 2.1 PL1] Status: RO Greetings! Rick, Here are a couple of Sun programs for seeing FaceSaver faces, (your's isn't too bad!) adapted from Jeff Michaud's xface program already on uunet. I was hoping you can throw this shar file into the FaceSaver directory for anonymous ftp access. Call it something like sunface.shar, or whatever fits the usual convention for such stuff. 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, except for single-plane B/W Sun Workstations. Uses dithering to simulate intensities. Thanks! - Murali D. Murali Raju (UUCP Mail: ...!uunet!gwusun!raju) The George Washington University, Washington, DC. -------------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 '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 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 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 xface program on uunet. X */ X X#include 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 = ""; 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 X#include 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=0;j--) { X pw_lock (pw, crect); X for (i=0;i (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 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 xface program on uunet. X */ X X#include 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 = ""; 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< 2) { X for (n=2; n < dmSize; n = 2*n) { X for (i=0; i 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 X#include 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=0;j--) { X js = j*MulFac; je = js + MulFac; X pw_lock (pw, crect); X for (i=0;i 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