ViewVC Help
View File | Revision Log | Show Annotations | Download File | Root Listing
root/radiance/ray/src/common/resolu.c
(Generate patch)

Comparing ray/src/common/resolu.c (file contents):
Revision 2.2 by greg, Thu Nov 28 10:31:04 1991 UTC vs.
Revision 2.9 by greg, Tue Nov 21 18:47:03 2023 UTC

# Line 1 | Line 1
1 /* Copyright (c) 1991 Regents of the University of California */
2
1   #ifndef lint
2 < static char SCCSid[] = "$SunId$ LBL";
2 > static const char       RCSid[] = "$Id$";
3   #endif
6
4   /*
5   * Read and write image resolutions.
6 + *
7 + * Externals declared in resolu.h
8   */
9  
10 + #include "copyright.h"
11 +
12 + #include <stdlib.h>
13   #include <stdio.h>
14  
15   #include "resolu.h"
# Line 16 | Line 18 | static char SCCSid[] = "$SunId$ LBL";
18   char  resolu_buf[RESOLU_BUFLEN];        /* resolution line buffer */
19  
20  
21 < fputresolu(ord, sl, ns, fp)             /* put out picture dimensions */
22 < int  ord;                       /* scanline ordering */
23 < int  sl, ns;                    /* scanline length and number */
24 < FILE  *fp;
21 > void
22 > fputresolu(                             /* put out picture dimensions */
23 >        int  ord,               /* scanline ordering */
24 >        int  sl, int ns,        /* scanline length and number */
25 >        FILE  *fp
26 > )
27   {
28          RESOLU  rs;
29  
30 <        if ((rs.or = ord) & YMAJOR) {
30 >        if ((rs.rt = ord) & YMAJOR) {
31                  rs.xr = sl;
32                  rs.yr = ns;
33          } else {
# Line 35 | Line 39 | FILE  *fp;
39  
40  
41   int
42 < fgetresolu(sl, ns, fp)                  /* get picture dimensions */
43 < int  *sl, *ns;                  /* scanline length and number */
44 < FILE  *fp;
42 > fgetresolu(                             /* get picture dimensions */
43 >        int  *sl, int *ns,              /* scanline length and number */
44 >        FILE  *fp
45 > )
46   {
47          RESOLU  rs;
48  
49          if (!fgetsresolu(&rs, fp))
50                  return(-1);
51 <        if (rs.or & YMAJOR) {
51 >        if (rs.rt & YMAJOR) {
52                  *sl = rs.xr;
53                  *ns = rs.yr;
54          } else {
55                  *sl = rs.yr;
56                  *ns = rs.xr;
57          }
58 <        return(rs.or);
58 >        return(rs.rt);
59   }
60  
61  
62   char *
63 < resolu2str(buf, rp)             /* convert resolution struct to line */
64 < char  *buf;
65 < register RESOLU  *rp;
63 > resolu2str(                     /* convert resolution struct to line */
64 >        char  *buf,
65 >        RESOLU  *rp
66 > )
67   {
68 <        if (rp->or&YMAJOR)
69 <                sprintf(buf, "%cY %d %cX %d\n",
70 <                                rp->or&YDECR ? '-' : '+', rp->yr,
71 <                                rp->or&XDECR ? '-' : '+', rp->xr);
68 >        if (rp->rt&YMAJOR)
69 >                sprintf(buf, "%cY %8d %cX %8d\n",
70 >                                rp->rt&YDECR ? '-' : '+', rp->yr,
71 >                                rp->rt&XDECR ? '-' : '+', rp->xr);
72          else
73 <                sprintf(buf, "%cX %d %cY %d\n",
74 <                                rp->or&XDECR ? '-' : '+', rp->xr,
75 <                                rp->or&YDECR ? '-' : '+', rp->yr);
73 >                sprintf(buf, "%cX %8d %cY %8d\n",
74 >                                rp->rt&XDECR ? '-' : '+', rp->xr,
75 >                                rp->rt&YDECR ? '-' : '+', rp->yr);
76          return(buf);
77   }
78  
79  
80 < str2resolu(rp, buf)             /* convert resolution line to struct */
81 < register RESOLU  *rp;
82 < char  *buf;
80 > int
81 > str2resolu(                     /* convert resolution line to struct */
82 >        RESOLU  *rp,
83 >        char  *buf
84 > )
85   {
86 <        register char  *xndx, *yndx;
87 <        register char  *cp;
86 >        char  *xndx, *yndx;
87 >        char  *cp;
88  
89          if (buf == NULL)
90                  return(0);
# Line 88 | Line 96 | char  *buf;
96                          yndx = cp;
97          if (xndx == NULL || yndx == NULL)
98                  return(0);
99 <        rp->or = 0;
100 <        if (xndx > yndx) rp->or |= YMAJOR;
101 <        if (xndx[-1] == '-') rp->or |= XDECR;
102 <        if (yndx[-1] == '-') rp->or |= YDECR;
99 >        rp->rt = 0;
100 >        if (xndx > yndx) rp->rt |= YMAJOR;
101 >        if (xndx[-1] == '-') rp->rt |= XDECR;
102 >        if (yndx[-1] == '-') rp->rt |= YDECR;
103          if ((rp->xr = atoi(xndx+1)) <= 0)
104                  return(0);
105          if ((rp->yr = atoi(yndx+1)) <= 0)

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines