ViewVC Help
View File | Revision Log | Show Annotations | Download File | Root Listing
root/radiance/ray/src/px/glimage.c
Revision: 1.1
Committed: Thu Jan 25 11:46:39 1990 UTC (34 years, 3 months ago) by greg
Content type: text/plain
Branch: MAIN
Log Message:
Initial revision

File Contents

# User Rev Content
1 greg 1.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     getheader(input, NULL);
43     /* get picture dimensions */
44     if (fgetresolu(&xres, &yres, input) != (YMAJOR|YDECR)) {
45     fprintf(stderr, "%s: bad picture size\n", fname);
46     exit(1);
47     }
48     prefsize(xres, yres);
49     winopen("newsimage");
50     RGBmode();
51     gconfig();
52     RGBcolor(0,0,0);
53     clear();
54     getorigin(&winorgx,&winorgy);
55     winout = (long *)malloc(xres*sizeof(long));
56     scanline = (COLR *)malloc(xres*sizeof(COLR));
57     if (winout == NULL || scanline == NULL) {
58     perror(argv[0]);
59     exit(1);
60     }
61     for (i = yres-1; i >= 0; i--) {
62     if (freadcolrs(scanline, xres, input) < 0) {
63     fprintf(stderr, "%s: read error (y=%d)\n", fname, i);
64     exit(1);
65     }
66     normcolrs(scanline, xres);
67     for (j = 0; j < xres; j++) {
68     winout[j] = 255L<<24;
69     winout[j] |= (long)scanline[j][BLU]<<16;
70     winout[j] |= (long)scanline[j][GRN]<<8;
71     winout[j] |= (long)scanline[j][RED];
72     }
73     lrectwrite(0,i,xres-1,i,winout);
74     }
75     pause();
76     exit(0);
77     }