--- ray/src/px/panim.c 1989/12/28 08:18:49 1.3 +++ ray/src/px/panim.c 1990/11/07 13:10:30 1.7 @@ -11,7 +11,6 @@ static char SCCSid[] = "$SunId$ LBL"; */ #include -#include #include "random.h" #include "color.h" @@ -20,6 +19,10 @@ static char SCCSid[] = "$SunId$ LBL"; #define GAMMA 2.0 /* gamma correction factor */ +FILE *popen(); + +char *pcom = NULL; /* pipe command */ + BYTE gammamap[256]; /* gamma correction table */ @@ -35,12 +38,14 @@ char *argv[]; for (progname = *argv++; --argc; argv++) if (!strcmp(*argv, "-p") && argv[1]) { port = atoi(*++argv); argc--; + } else if (!strcmp(*argv, "-u") && argv[1]) { + pcom = *++argv; argc--; } else break; if (!argc) { fputs("Usage: ", stderr); fputs(progname, stderr); - fputs(" [-p port] hostname [-c copies][-r record] [frame] ..\n", + fputs(" [-p port] [-u uncompress] hostname [-c copies][-r record] [frame] ..\n", stderr); exit(1); } @@ -71,6 +76,7 @@ char *argv[]; sendframe(file) /* convert and send a frame */ char *file; { + char command[128]; COLR scanin[SCANLINE]; int xres, yres; int xbeg, ybeg; @@ -79,9 +85,19 @@ char *file; register int x; /* open file */ if (file == NULL) { - fp = stdin; + if (pcom != NULL) + fp = popen(pcom, "r"); + else + fp = stdin; file = ""; - } else if ((fp = fopen(file, "r")) == NULL) { + } else { + if (pcom != NULL) { + sprintf(command, "( %s ) < %s", pcom, file); + fp = popen(command, "r"); + } else + fp = fopen(file, "r"); + } + if (fp == NULL) { perror(file); exit(1); } @@ -105,7 +121,7 @@ char *file; fputs(": read error\n", stderr); exit(1); } - normcolrs(scanin, xres); /* normalize */ + normcolrs(scanin, xres, 0); /* normalize */ for (x = 0; x < xres; x++) /* convert */ sc_frame_arr[y+ybeg][x+xbeg] = ((gammamap[scanin[x][RED]]+(random()&7))&0xf8)<<7 @@ -115,7 +131,10 @@ char *file; /* send frame */ scry_send_frame(); /* close file */ - fclose(fp); + if (pcom != NULL) + pclose(fp); + else + fclose(fp); } @@ -125,7 +144,7 @@ compgamma() /* compute gamma correction map */ register int i, val; for (i = 0; i < 256; i++) { - val = pow(i/256.0, 1.0/GAMMA) * 256.0; + val = pow((i+0.5)/256.0, 1.0/GAMMA) * 256.0; if (val > 248) val = 248; gammamap[i] = val; }