ViewVC Help
View File | Revision Log | Show Annotations | Download File | Root Listing
root/radiance/ray/src/common/resolu.c
Revision: 1.1
Committed: Sat Sep 22 10:44:55 1990 UTC (33 years, 7 months ago) by greg
Content type: text/plain
Branch: MAIN
Log Message:
Initial revision

File Contents

# Content
1 #ifndef lint
2 static char SCCSid[] = "$SunId$ LBL";
3 #endif
4
5 /*
6 * Read and write image resolutions.
7 */
8
9 #include <stdio.h>
10
11 #include "color.h"
12
13
14 fputresolu(ord, xres, yres, fp) /* put x and y resolution */
15 register int ord;
16 int xres, yres;
17 FILE *fp;
18 {
19 if (ord&YMAJOR)
20 fprintf(fp, "%cY %d %cX %d\n",
21 ord&YDECR ? '-' : '+', yres,
22 ord&XDECR ? '-' : '+', xres);
23 else
24 fprintf(fp, "%cX %d %cY %d\n",
25 ord&XDECR ? '-' : '+', xres,
26 ord&YDECR ? '-' : '+', yres);
27 }
28
29
30 fgetresolu(xrp, yrp, fp) /* get x and y resolution */
31 int *xrp, *yrp;
32 FILE *fp;
33 {
34 char buf[64], *xndx, *yndx;
35 register char *cp;
36 register int ord;
37
38 if (fgets(buf, sizeof(buf), fp) == NULL)
39 return(-1);
40 xndx = yndx = NULL;
41 for (cp = buf+1; *cp; cp++)
42 if (*cp == 'X')
43 xndx = cp;
44 else if (*cp == 'Y')
45 yndx = cp;
46 if (xndx == NULL || yndx == NULL)
47 return(-1);
48 ord = 0;
49 if (xndx > yndx) ord |= YMAJOR;
50 if (xndx[-1] == '-') ord |= XDECR;
51 if (yndx[-1] == '-') ord |= YDECR;
52 if ((*xrp = atoi(xndx+1)) <= 0)
53 return(-1);
54 if ((*yrp = atoi(yndx+1)) <= 0)
55 return(-1);
56 return(ord);
57 }