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" |
18 |
|
char resolu_buf[RESOLU_BUFLEN]; /* resolution line buffer */ |
19 |
|
|
20 |
|
|
21 |
+ |
void |
22 |
|
fputresolu(ord, sl, ns, fp) /* put out picture dimensions */ |
23 |
|
int ord; /* scanline ordering */ |
24 |
|
int sl, ns; /* scanline length and number */ |
26 |
|
{ |
27 |
|
RESOLU rs; |
28 |
|
|
29 |
< |
if ((rs.or = ord) & YMAJOR) { |
29 |
> |
if ((rs.rt = ord) & YMAJOR) { |
30 |
|
rs.xr = sl; |
31 |
|
rs.yr = ns; |
32 |
|
} else { |
46 |
|
|
47 |
|
if (!fgetsresolu(&rs, fp)) |
48 |
|
return(-1); |
49 |
< |
if (rs.or & YMAJOR) { |
49 |
> |
if (rs.rt & YMAJOR) { |
50 |
|
*sl = rs.xr; |
51 |
|
*ns = rs.yr; |
52 |
|
} else { |
53 |
|
*sl = rs.yr; |
54 |
|
*ns = rs.xr; |
55 |
|
} |
56 |
< |
return(rs.or); |
56 |
> |
return(rs.rt); |
57 |
|
} |
58 |
|
|
59 |
|
|
62 |
|
char *buf; |
63 |
|
register RESOLU *rp; |
64 |
|
{ |
65 |
< |
if (rp->or&YMAJOR) |
66 |
< |
sprintf(buf, "%cY %d %cX %d\n", |
67 |
< |
rp->or&YDECR ? '-' : '+', rp->yr, |
68 |
< |
rp->or&XDECR ? '-' : '+', rp->xr); |
65 |
> |
if (rp->rt&YMAJOR) |
66 |
> |
sprintf(buf, "%cY %8d %cX %8d\n", |
67 |
> |
rp->rt&YDECR ? '-' : '+', rp->yr, |
68 |
> |
rp->rt&XDECR ? '-' : '+', rp->xr); |
69 |
|
else |
70 |
< |
sprintf(buf, "%cX %d %cY %d\n", |
71 |
< |
rp->or&XDECR ? '-' : '+', rp->xr, |
72 |
< |
rp->or&YDECR ? '-' : '+', rp->yr); |
70 |
> |
sprintf(buf, "%cX %8d %cY %8d\n", |
71 |
> |
rp->rt&XDECR ? '-' : '+', rp->xr, |
72 |
> |
rp->rt&YDECR ? '-' : '+', rp->yr); |
73 |
|
return(buf); |
74 |
|
} |
75 |
|
|
76 |
|
|
77 |
+ |
int |
78 |
|
str2resolu(rp, buf) /* convert resolution line to struct */ |
79 |
|
register RESOLU *rp; |
80 |
|
char *buf; |
92 |
|
yndx = cp; |
93 |
|
if (xndx == NULL || yndx == NULL) |
94 |
|
return(0); |
95 |
< |
rp->or = 0; |
96 |
< |
if (xndx > yndx) rp->or |= YMAJOR; |
97 |
< |
if (xndx[-1] == '-') rp->or |= XDECR; |
98 |
< |
if (yndx[-1] == '-') rp->or |= YDECR; |
95 |
> |
rp->rt = 0; |
96 |
> |
if (xndx > yndx) rp->rt |= YMAJOR; |
97 |
> |
if (xndx[-1] == '-') rp->rt |= XDECR; |
98 |
> |
if (yndx[-1] == '-') rp->rt |= YDECR; |
99 |
|
if ((rp->xr = atoi(xndx+1)) <= 0) |
100 |
|
return(0); |
101 |
|
if ((rp->yr = atoi(yndx+1)) <= 0) |