ViewVC Help
View File | Revision Log | Show Annotations | Download File | Root Listing
root/radiance/ray/src/px/ttyimage.c
Revision: 2.3
Committed: Sat Feb 22 02:07:28 2003 UTC (21 years, 2 months ago) by greg
Content type: text/plain
Branch: MAIN
CVS Tags: rad3R5
Changes since 2.2: +2 -4 lines
Log Message:
Changes and check-in for 3.5 release
Includes new source files and modifications not recorded for many years
See ray/doc/notes/ReleaseNotes for notes between 3.1 and 3.5 release

File Contents

# Content
1 #ifndef lint
2 static const char RCSid[] = "$Id$";
3 #endif
4 /*
5 * ttyimage.c - program to dump pixel file to dumb terminal.
6 *
7 * 8/15/85
8 */
9
10 #include <stdio.h>
11 #ifdef MSDOS
12 #include <fcntl.h>
13 #endif
14 #include <time.h>
15
16 #include "color.h"
17 #include "resolu.h"
18
19
20 #define NCOLS 133
21
22
23 main(argc, argv)
24 int argc;
25 char **argv;
26 {
27 FILE *input;
28 int xres, yres;
29 COLR scanline[NCOLS];
30 register int i, j;
31
32 if (argc < 2)
33 input = stdin;
34 else if ((input = fopen(argv[1], "r")) == NULL) {
35 fprintf(stderr, "%s: can't open file \"%s\"\n", argv[0], argv[1]);
36 exit(1);
37 }
38 #ifdef MSDOS
39 setmode(fileno(input), O_BINARY);
40 #endif
41 /* get picture dimensions */
42 if (checkheader(input, COLRFMT, NULL) < 0 ||
43 fgetresolu(&xres, &yres, input) < 0) {
44 fprintf(stderr, "%s: bad picture format\n", argv[0]);
45 exit(1);
46 }
47 if (xres > NCOLS) {
48 fprintf(stderr, "%s: resolution mismatch\n", argv[0]);
49 exit(1);
50 }
51
52 for (i = 0; i < yres; i++) {
53 if (freadcolrs(scanline, xres, input) < 0) {
54 fprintf(stderr, "%s: read error\n", argv[0]);
55 exit(1);
56 }
57 normcolrs(scanline, xres, 0);
58 for (j = 0; j < xres; j++)
59 putchar(shade(scanline[j]));
60 putchar('\n');
61 }
62
63 exit(0);
64 }
65
66
67 int
68 shade(clr) /* return character for color */
69 COLR clr;
70 {
71 #define NSHADES 13
72
73 static char shadech[NSHADES+1] = " .,:;+?%&*$@#";
74
75 return(shadech[normbright(clr)*NSHADES/256]);
76
77 #undef NSHADES
78 }