ViewVC Help
View File | Revision Log | Show Annotations | Download File | Root Listing
root/radiance/ray/src/common/resolu.h
Revision: 2.6
Committed: Fri Jun 27 06:53:21 2003 UTC (20 years, 10 months ago) by greg
Content type: text/plain
Branch: MAIN
Changes since 2.5: +2 -4 lines
Log Message:
Broke standard.h into rtio.h, rterror.h, rtmath.h, and rtmisc.h

File Contents

# Content
1 /* RCSid $Id: resolu.h,v 2.5 2003/06/06 16:38:47 schorsch Exp $ */
2 /*
3 * Definitions for resolution line in image file.
4 *
5 * Include after <stdio.h>, <string.h>, and <time.h>
6 *
7 * 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 #ifndef _RAD_RESOLU_H_
17 #define _RAD_RESOLU_H_
18 #ifdef __cplusplus
19 extern "C" {
20 #endif
21
22 #include <stdio.h>
23 /* 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 int rt; /* orientation (from flags above) */
35 int xr, yr; /* x and y resolution */
36 } RESOLU;
37
38 /* macros to get scanline length and number */
39 #define scanlen(rs) ((rs)->rt & YMAJOR ? (rs)->xr : (rs)->yr)
40 #define numscans(rs) ((rs)->rt & YMAJOR ? (rs)->yr : (rs)->xr)
41
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 /* defined in resolu.c */
56 extern void fputresolu(int ord, int sl, int ns, FILE *fp);
57 extern int fgetresolu(int *sl, int *ns, FILE *fp);
58 extern char * resolu2str(char *buf, RESOLU *rp);
59 extern int str2resolu(RESOLU *rp, char *buf);
60 /* defined in header.c */
61 extern void newheader(char *t, FILE *fp);
62 extern int isheadid(char *s);
63 extern int headidval(char *r, char *s);
64 extern int dateval(time_t *t, char *s);
65 extern int isdate(char *s);
66 extern void fputdate(time_t t, FILE *fp);
67 extern void fputnow(FILE *fp);
68 extern void printargs(int ac, char **av, FILE *fp);
69 extern int isformat(char *s);
70 extern int formatval(char *r, char *s);
71 extern void fputformat(char *s, FILE *fp);
72 extern int getheader(FILE *fp, int (*f)(), char *p);
73 extern int globmatch(char *pat, char *str);
74 extern int checkheader(FILE *fin, char *fmt, FILE *fout);
75
76 #ifdef __cplusplus
77 }
78 #endif
79 #endif /* _RAD_RESOLU_H_ */
80