ViewVC Help
View File | Revision Log | Show Annotations | Download File | Root Listing
root/radiance/ray/src/px/glimage.c
Revision: 1.3
Committed: Thu Apr 18 14:35:08 1991 UTC (33 years ago) by greg
Content type: text/plain
Branch: MAIN
Changes since 1.2: +4 -1 lines
Log Message:
added format information to headers

File Contents

# Content
1 #ifndef lint
2 static char SCCSid[] = "$SunId$ LBL";
3 #endif
4
5 /* Copyright (c) 1986 Regents of the University of California */
6
7 /*
8 * glimage.c - program to dump pixel file NeWS window
9 *
10 * 1/24/89
11 */
12
13 #include <stdio.h>
14
15 #include <gl.h>
16
17 #include "color.h"
18
19
20 main(argc, argv) /* print a picture */
21 int argc;
22 char *argv[];
23 {
24 char *fname;
25 FILE *input;
26 int xres, yres;
27 int winorgx, winorgy;
28 COLR *scanline;
29 long *winout;
30 int i;
31 register int j;
32
33 fname = argv[1];
34 if (fname == NULL) {
35 input = stdin;
36 fname = "<stdin>";
37 } else if ((input = fopen(fname, "r")) == NULL) {
38 perror(fname);
39 exit(1);
40 }
41 /* discard header */
42 if (checkheader(input, COLRFMT, NULL) < 0) {
43 fprintf(stderr, "%s: not a Radiance picture\n", fname);
44 exit(1);
45 }
46 /* get picture dimensions */
47 if (fgetresolu(&xres, &yres, input) != (YMAJOR|YDECR)) {
48 fprintf(stderr, "%s: bad picture size\n", fname);
49 exit(1);
50 }
51 prefsize(xres, yres);
52 winopen("newsimage");
53 RGBmode();
54 gconfig();
55 RGBcolor(0,0,0);
56 clear();
57 getorigin(&winorgx,&winorgy);
58 winout = (long *)malloc(xres*sizeof(long));
59 scanline = (COLR *)malloc(xres*sizeof(COLR));
60 if (winout == NULL || scanline == NULL) {
61 perror(argv[0]);
62 exit(1);
63 }
64 for (i = yres-1; i >= 0; i--) {
65 if (freadcolrs(scanline, xres, input) < 0) {
66 fprintf(stderr, "%s: read error (y=%d)\n", fname, i);
67 exit(1);
68 }
69 normcolrs(scanline, xres, 0);
70 for (j = 0; j < xres; j++) {
71 winout[j] = 255L<<24;
72 winout[j] |= (long)scanline[j][BLU]<<16;
73 winout[j] |= (long)scanline[j][GRN]<<8;
74 winout[j] |= (long)scanline[j][RED];
75 }
76 lrectwrite(0,i,xres-1,i,winout);
77 }
78 pause();
79 exit(0);
80 }