ViewVC Help
View File | Revision Log | Show Annotations | Download File | Root Listing
root/radiance/ray/src/common/resolu.h
Revision: 2.4
Committed: Tue Feb 25 02:47:22 2003 UTC (21 years, 2 months ago) by greg
Content type: text/plain
Branch: MAIN
CVS Tags: rad3R5
Changes since 2.3: +2 -57 lines
Log Message:
Replaced inline copyright notice with #include "copyright.h"

File Contents

# User Rev Content
1 greg 2.4 /* RCSid $Id$ */
2 greg 1.1 /*
3     * Definitions for resolution line in image file.
4     *
5 greg 2.3 * Include after <stdio.h>, <string.h>, and <time.h>
6     *
7 greg 1.1 * True image orientation is defined by an xy coordinate system
8     * whose origin is at the lower left corner of the image, with
9     * x increasing to the right and y increasing in the upward direction.
10     * This true orientation is independent of how the pixels are actually
11     * ordered in the file, which is indicated by the resolution line.
12     * This line is of the form "{+-}{XY} xyres {+-}{YX} yxres\n".
13     * A typical line for a 1024x600 image might be "-Y 600 +X 1024\n",
14     * indicating that the scanlines are in English text order (PIXSTANDARD).
15     */
16    
17 greg 2.4 #include "copyright.h"
18 greg 2.3
19     #ifdef __cplusplus
20     extern "C" {
21     #endif
22    
23 greg 1.1 /* flags for scanline ordering */
24     #define XDECR 1
25     #define YDECR 2
26     #define YMAJOR 4
27    
28     /* standard scanline ordering */
29     #define PIXSTANDARD (YMAJOR|YDECR)
30     #define PIXSTDFMT "-Y %d +X %d\n"
31    
32     /* structure for image dimensions */
33     typedef struct {
34 greg 2.3 int rt; /* orientation (from flags above) */
35 greg 1.1 int xr, yr; /* x and y resolution */
36     } RESOLU;
37    
38     /* macros to get scanline length and number */
39 greg 2.3 #define scanlen(rs) ((rs)->rt & YMAJOR ? (rs)->xr : (rs)->yr)
40     #define numscans(rs) ((rs)->rt & YMAJOR ? (rs)->yr : (rs)->xr)
41 greg 1.1
42     /* resolution string buffer and its size */
43     #define RESOLU_BUFLEN 32
44     extern char resolu_buf[RESOLU_BUFLEN];
45    
46     /* macros for reading/writing resolution struct */
47     #define fputsresolu(rs,fp) fputs(resolu2str(resolu_buf,rs),fp)
48     #define fgetsresolu(rs,fp) str2resolu(rs, \
49     fgets(resolu_buf,RESOLU_BUFLEN,fp))
50    
51     /* reading/writing of standard ordering */
52     #define fprtresolu(sl,ns,fp) fprintf(fp,PIXSTDFMT,ns,sl)
53     #define fscnresolu(sl,ns,fp) (fscanf(fp,PIXSTDFMT,ns,sl)==2)
54    
55 greg 2.3 #ifdef NOPROTO
56     /* defined in resolu.c */
57     extern void fputresolu();
58     extern int fgetresolu();
59     extern char *resolu2str();
60     extern int str2resolu();
61     /* defined in header.c */
62     extern void newheader();
63     extern int isheadid();
64     extern int headidval();
65     extern int dateval();
66     extern int isdate();
67     extern void fputdate();
68     extern void fputnow();
69     extern void printargs();
70     extern int isformat();
71     extern int formatval();
72     extern void fputformat();
73     extern int getheader();
74     extern int globmatch();
75     extern int checkheader();
76    
77     #else
78     /* defined in resolu.c */
79     extern void fputresolu(int ord, int sl, int ns, FILE *fp);
80     extern int fgetresolu(int *sl, int *ns, FILE *fp);
81     extern char * resolu2str(char *buf, RESOLU *rp);
82     extern int str2resolu(RESOLU *rp, char *buf);
83     /* defined in header.c */
84     extern void newheader(char *t, FILE *fp);
85     extern int isheadid(char *s);
86     extern int headidval(char *r, char *s);
87     extern int dateval(time_t *t, char *s);
88     extern int isdate(char *s);
89     extern void fputdate(time_t t, FILE *fp);
90     extern void fputnow(FILE *fp);
91     extern void printargs(int ac, char **av, FILE *fp);
92     extern int isformat(char *s);
93     extern int formatval(char *r, char *s);
94     extern void fputformat(char *s, FILE *fp);
95     extern int getheader(FILE *fp, int (*f)(), char *p);
96     extern int globmatch(char *pat, char *str);
97     extern int checkheader(FILE *fin, char *fmt, FILE *fout);
98    
99     #endif
100    
101     #ifdef __cplusplus
102     }
103     #endif