ViewVC Help
View File | Revision Log | Show Annotations | Download File | Root Listing
root/radiance/ray/src/px/ttyimage.c
(Generate patch)

Comparing ray/src/px/ttyimage.c (file contents):
Revision 1.1 by greg, Thu Feb 2 10:49:42 1989 UTC vs.
Revision 1.4 by greg, Fri Oct 20 20:36:08 1989 UTC

# Line 17 | Line 17 | static char SCCSid[] = "$SunId$ LBL";
17  
18   #define  NCOLS          133
19  
20 char  shadech[] = " .,:;+?%&*$@#";
20  
22 #define  NSHADES        (sizeof(shadech)-1)
23
24 #define  shade(col)     ( bright(col)>=1.0 ? NSHADES-1 : \
25                                (int)(bright(col)*NSHADES) )
26
27 char  *progname;
28
29
21   main(argc, argv)
22   int  argc;
23   char  **argv;
24   {
25          FILE  *input;
26          int  xres, yres;
27 <        COLOR  scanline[NCOLS];
27 >        COLR  scanline[NCOLS];
28          char  sbuf[256];
29          register int  i, j;
30          
40        progname = argv[0];
41
31          if (argc < 2)
32                  input = stdin;
33          else if ((input = fopen(argv[1], "r")) == NULL) {
34 <                fprintf(stderr, "%s: can't open file \"%s\"\n", progname, argv[1]);
34 >                fprintf(stderr, "%s: can't open file \"%s\"\n", argv[0], argv[1]);
35                  exit(1);
36          }
37          
# Line 50 | Line 39 | char  **argv;
39          while (fgets(sbuf, sizeof(sbuf), input) != NULL && sbuf[0] != '\n')
40                  ;
41                                  /* get picture dimensions */
42 <        if (fgets(sbuf, sizeof(sbuf), input) == NULL ||
43 <                        sscanf(sbuf, "-Y %d +X %d\n", &yres, &xres) != 2) {
55 <                fprintf(stderr, "%s: bad picture size\n", progname);
42 >        if (fgetresolu(&xres, &yres, input) != (YMAJOR|YDECR)) {
43 >                fprintf(stderr, "%s: bad picture size\n", argv[0]);
44                  exit(1);
45          }
46          if (xres > NCOLS) {
47 <                fprintf(stderr, "%s: resolution mismatch\n", progname);
47 >                fprintf(stderr, "%s: resolution mismatch\n", argv[0]);
48                  exit(1);
49          }
50          
51          for (i = 0; i < yres; i++) {
52 <                if (freadscan(scanline, xres, input) < 0) {
53 <                        fprintf(stderr, "%s: read error\n", progname);
52 >                if (freadcolrs(scanline, xres, input) < 0) {
53 >                        fprintf(stderr, "%s: read error\n", argv[0]);
54                          exit(1);
55                  }
56 +                normcolrs(scanline, xres);
57                  for (j = 0; j < xres; j++)
58 <                        putchar(shadech[shade(scanline[j])]);
58 >                        putchar(shade(scanline[j]));
59                  putchar('\n');
60          }
61  
62          exit(0);
63 + }
64 +
65 +
66 + int
67 + shade(clr)                      /* return character for color */
68 + COLR  clr;
69 + {
70 + #define NSHADES  13
71 +
72 +        static char  shadech[NSHADES+1] = " .,:;+?%&*$@#";
73 +
74 +        return(shadech[normbright(clr)*NSHADES/256]);
75 +
76 + #undef NSHADES
77   }

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines