ViewVC Help
View File | Revision Log | Show Annotations | Download File | Root Listing
root/radiance/ray/src/common/resolu.h
Revision: 2.5
Committed: Fri Jun 6 16:38:47 2003 UTC (20 years, 11 months ago) by schorsch
Content type: text/plain
Branch: MAIN
Changes since 2.4: +7 -28 lines
Log Message:
*** empty log message ***

File Contents

# User Rev Content
1 schorsch 2.5 /* RCSid $Id: resolu.h,v 2.4 2003/02/25 02:47:22 greg Exp $ */
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 schorsch 2.5 #ifndef _RAD_RESOLU_H_
17     #define _RAD_RESOLU_H_
18 greg 2.3 #ifdef __cplusplus
19     extern "C" {
20     #endif
21    
22 schorsch 2.5 #include "copyright.h"
23    
24 greg 1.1 /* flags for scanline ordering */
25     #define XDECR 1
26     #define YDECR 2
27     #define YMAJOR 4
28    
29     /* standard scanline ordering */
30     #define PIXSTANDARD (YMAJOR|YDECR)
31     #define PIXSTDFMT "-Y %d +X %d\n"
32    
33     /* structure for image dimensions */
34     typedef struct {
35 greg 2.3 int rt; /* orientation (from flags above) */
36 greg 1.1 int xr, yr; /* x and y resolution */
37     } RESOLU;
38    
39     /* macros to get scanline length and number */
40 greg 2.3 #define scanlen(rs) ((rs)->rt & YMAJOR ? (rs)->xr : (rs)->yr)
41     #define numscans(rs) ((rs)->rt & YMAJOR ? (rs)->yr : (rs)->xr)
42 greg 1.1
43     /* resolution string buffer and its size */
44     #define RESOLU_BUFLEN 32
45     extern char resolu_buf[RESOLU_BUFLEN];
46    
47     /* macros for reading/writing resolution struct */
48     #define fputsresolu(rs,fp) fputs(resolu2str(resolu_buf,rs),fp)
49     #define fgetsresolu(rs,fp) str2resolu(rs, \
50     fgets(resolu_buf,RESOLU_BUFLEN,fp))
51    
52     /* reading/writing of standard ordering */
53     #define fprtresolu(sl,ns,fp) fprintf(fp,PIXSTDFMT,ns,sl)
54     #define fscnresolu(sl,ns,fp) (fscanf(fp,PIXSTDFMT,ns,sl)==2)
55    
56 greg 2.3 /* defined in resolu.c */
57     extern void fputresolu(int ord, int sl, int ns, FILE *fp);
58     extern int fgetresolu(int *sl, int *ns, FILE *fp);
59     extern char * resolu2str(char *buf, RESOLU *rp);
60     extern int str2resolu(RESOLU *rp, char *buf);
61     /* defined in header.c */
62     extern void newheader(char *t, FILE *fp);
63     extern int isheadid(char *s);
64     extern int headidval(char *r, char *s);
65     extern int dateval(time_t *t, char *s);
66     extern int isdate(char *s);
67     extern void fputdate(time_t t, FILE *fp);
68     extern void fputnow(FILE *fp);
69     extern void printargs(int ac, char **av, FILE *fp);
70     extern int isformat(char *s);
71     extern int formatval(char *r, char *s);
72     extern void fputformat(char *s, FILE *fp);
73     extern int getheader(FILE *fp, int (*f)(), char *p);
74     extern int globmatch(char *pat, char *str);
75     extern int checkheader(FILE *fin, char *fmt, FILE *fout);
76    
77    
78     #ifdef __cplusplus
79     }
80     #endif
81 schorsch 2.5 #endif /* _RAD_RESOLU_H_ */
82