ViewVC Help
View File | Revision Log | Show Annotations | Download File | Root Listing
root/radiance/ray/src/px/glimage.c
Revision: 2.2
Committed: Sat Feb 22 02:07:27 2003 UTC (21 years, 2 months ago) by greg
Content type: text/plain
Branch: MAIN
CVS Tags: rad3R6P1, rad3R5, rad3R6
Changes since 2.1: +3 -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 * glimage.c - program to dump pixel file NeWS window
6 *
7 * 1/24/89
8 */
9
10 #include <stdio.h>
11
12 #include <gl.h>
13
14 #include <time.h>
15
16 #include "color.h"
17
18 #include "resolu.h"
19
20
21 main(argc, argv) /* print a picture */
22 int argc;
23 char *argv[];
24 {
25 char *fname;
26 FILE *input;
27 int xres, yres;
28 int winorgx, winorgy;
29 COLR *scanline;
30 long *winout;
31 int i;
32 register int j;
33
34 fname = argv[1];
35 if (fname == NULL) {
36 input = stdin;
37 fname = "<stdin>";
38 } else if ((input = fopen(fname, "r")) == NULL) {
39 perror(fname);
40 exit(1);
41 }
42 /* discard header */
43 if (checkheader(input, COLRFMT, NULL) < 0) {
44 fprintf(stderr, "%s: not a Radiance picture\n", fname);
45 exit(1);
46 }
47 /* get picture dimensions */
48 if (fgetresolu(&xres, &yres, input) < 0) {
49 fprintf(stderr, "%s: bad picture size\n", fname);
50 exit(1);
51 }
52 prefsize(xres, yres);
53 winopen("newsimage");
54 RGBmode();
55 gconfig();
56 RGBcolor(0,0,0);
57 clear();
58 getorigin(&winorgx,&winorgy);
59 winout = (long *)malloc(xres*sizeof(long));
60 scanline = (COLR *)malloc(xres*sizeof(COLR));
61 if (winout == NULL || scanline == NULL) {
62 perror(argv[0]);
63 exit(1);
64 }
65 for (i = yres-1; i >= 0; i--) {
66 if (freadcolrs(scanline, xres, input) < 0) {
67 fprintf(stderr, "%s: read error (y=%d)\n", fname, i);
68 exit(1);
69 }
70 normcolrs(scanline, xres, 0);
71 for (j = 0; j < xres; j++) {
72 winout[j] = 255L<<24;
73 winout[j] |= (long)scanline[j][BLU]<<16;
74 winout[j] |= (long)scanline[j][GRN]<<8;
75 winout[j] |= (long)scanline[j][RED];
76 }
77 lrectwrite(0,i,xres-1,i,winout);
78 }
79 pause();
80 exit(0);
81 }