ViewVC Help
View File | Revision Log | Show Annotations | Download File | Root Listing
root/radiance/ray/src/common/resolu.h
Revision: 2.11
Committed: Thu May 21 18:08:43 2009 UTC (14 years, 11 months ago) by greg
Content type: text/plain
Branch: MAIN
CVS Tags: rad4R2P2, rad5R0, rad4R2, rad4R1, rad4R0, rad4R2P1
Changes since 2.10: +15 -4 lines
Log Message:
Added GPS header information (GMT and Latitude/Longitude)

File Contents

# User Rev Content
1 greg 2.11 /* RCSid $Id: resolu.h,v 2.10 2005/02/01 01:28:16 greg Exp $ */
2 greg 1.1 /*
3     * Definitions for resolution line in image file.
4     *
5 greg 2.10 * Include after <stdio.h>
6 greg 2.3 *
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 schorsch 2.8
19     #include <time.h>
20    
21    
22 greg 2.3 #ifdef __cplusplus
23     extern "C" {
24     #endif
25    
26 greg 1.1 /* flags for scanline ordering */
27     #define XDECR 1
28     #define YDECR 2
29     #define YMAJOR 4
30    
31     /* standard scanline ordering */
32     #define PIXSTANDARD (YMAJOR|YDECR)
33     #define PIXSTDFMT "-Y %d +X %d\n"
34    
35     /* structure for image dimensions */
36     typedef struct {
37 greg 2.3 int rt; /* orientation (from flags above) */
38 greg 1.1 int xr, yr; /* x and y resolution */
39     } RESOLU;
40    
41     /* macros to get scanline length and number */
42 greg 2.3 #define scanlen(rs) ((rs)->rt & YMAJOR ? (rs)->xr : (rs)->yr)
43     #define numscans(rs) ((rs)->rt & YMAJOR ? (rs)->yr : (rs)->xr)
44 greg 1.1
45     /* resolution string buffer and its size */
46     #define RESOLU_BUFLEN 32
47     extern char resolu_buf[RESOLU_BUFLEN];
48    
49     /* macros for reading/writing resolution struct */
50     #define fputsresolu(rs,fp) fputs(resolu2str(resolu_buf,rs),fp)
51     #define fgetsresolu(rs,fp) str2resolu(rs, \
52     fgets(resolu_buf,RESOLU_BUFLEN,fp))
53    
54     /* reading/writing of standard ordering */
55     #define fprtresolu(sl,ns,fp) fprintf(fp,PIXSTDFMT,ns,sl)
56     #define fscnresolu(sl,ns,fp) (fscanf(fp,PIXSTDFMT,ns,sl)==2)
57    
58 greg 2.11 /* identify header lines */
59     #define isheadid(s) headidval(NULL,s)
60     #define isformat(s) formatval(NULL,s)
61     #define isdate(s) dateval(NULL,s)
62     #define isgmt(s) gmtval(NULL,s)
63    
64     #define LATLONSTR "LATLONG="
65     #define LLATLONSTR 8
66     #define islatlon(hl) (!strncmp(hl,LATLONSTR,LLATLONSTR))
67     #define latlonval(ll,hl) sscanf((hl)+LLATLONSTR, "%f %f", \
68     &(ll)[0],&(ll)[1])
69     #define fputlatlon(lat,lon,fp) fprintf(fp,"%s %.6f %.6f\n",LATLONSTR,lat,lon)
70    
71 greg 2.3 /* defined in resolu.c */
72     extern void fputresolu(int ord, int sl, int ns, FILE *fp);
73     extern int fgetresolu(int *sl, int *ns, FILE *fp);
74     extern char * resolu2str(char *buf, RESOLU *rp);
75     extern int str2resolu(RESOLU *rp, char *buf);
76     /* defined in header.c */
77     extern void newheader(char *t, FILE *fp);
78     extern int headidval(char *r, char *s);
79     extern int dateval(time_t *t, char *s);
80 greg 2.11 extern int gmtval(time_t *t, char *s);
81 greg 2.3 extern void fputdate(time_t t, FILE *fp);
82     extern void fputnow(FILE *fp);
83     extern void printargs(int ac, char **av, FILE *fp);
84     extern int formatval(char *r, char *s);
85     extern void fputformat(char *s, FILE *fp);
86 schorsch 2.9 typedef int gethfunc(char *s, void *p); /* callback to process header lines */
87     extern int getheader(FILE *fp, gethfunc *f, void *p);
88 greg 2.3 extern int globmatch(char *pat, char *str);
89     extern int checkheader(FILE *fin, char *fmt, FILE *fout);
90    
91     #ifdef __cplusplus
92     }
93     #endif
94 schorsch 2.5 #endif /* _RAD_RESOLU_H_ */
95