| 1 | greg | 2.3 | /* 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.3 | /* ==================================================================== | 
| 18 |  |  | * The Radiance Software License, Version 1.0 | 
| 19 |  |  | * | 
| 20 |  |  | * Copyright (c) 1990 - 2002 The Regents of the University of California, | 
| 21 |  |  | * through Lawrence Berkeley National Laboratory.   All rights reserved. | 
| 22 |  |  | * | 
| 23 |  |  | * Redistribution and use in source and binary forms, with or without | 
| 24 |  |  | * modification, are permitted provided that the following conditions | 
| 25 |  |  | * are met: | 
| 26 |  |  | * | 
| 27 |  |  | * 1. Redistributions of source code must retain the above copyright | 
| 28 |  |  | *         notice, this list of conditions and the following disclaimer. | 
| 29 |  |  | * | 
| 30 |  |  | * 2. Redistributions in binary form must reproduce the above copyright | 
| 31 |  |  | *       notice, this list of conditions and the following disclaimer in | 
| 32 |  |  | *       the documentation and/or other materials provided with the | 
| 33 |  |  | *       distribution. | 
| 34 |  |  | * | 
| 35 |  |  | * 3. The end-user documentation included with the redistribution, | 
| 36 |  |  | *           if any, must include the following acknowledgment: | 
| 37 |  |  | *             "This product includes Radiance software | 
| 38 |  |  | *                 (http://radsite.lbl.gov/) | 
| 39 |  |  | *                 developed by the Lawrence Berkeley National Laboratory | 
| 40 |  |  | *               (http://www.lbl.gov/)." | 
| 41 |  |  | *       Alternately, this acknowledgment may appear in the software itself, | 
| 42 |  |  | *       if and wherever such third-party acknowledgments normally appear. | 
| 43 |  |  | * | 
| 44 |  |  | * 4. The names "Radiance," "Lawrence Berkeley National Laboratory" | 
| 45 |  |  | *       and "The Regents of the University of California" must | 
| 46 |  |  | *       not be used to endorse or promote products derived from this | 
| 47 |  |  | *       software without prior written permission. For written | 
| 48 |  |  | *       permission, please contact [email protected]. | 
| 49 |  |  | * | 
| 50 |  |  | * 5. Products derived from this software may not be called "Radiance", | 
| 51 |  |  | *       nor may "Radiance" appear in their name, without prior written | 
| 52 |  |  | *       permission of Lawrence Berkeley National Laboratory. | 
| 53 |  |  | * | 
| 54 |  |  | * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED | 
| 55 |  |  | * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES | 
| 56 |  |  | * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE | 
| 57 |  |  | * DISCLAIMED.   IN NO EVENT SHALL Lawrence Berkeley National Laboratory OR | 
| 58 |  |  | * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, | 
| 59 |  |  | * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT | 
| 60 |  |  | * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF | 
| 61 |  |  | * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND | 
| 62 |  |  | * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, | 
| 63 |  |  | * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT | 
| 64 |  |  | * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF | 
| 65 |  |  | * SUCH DAMAGE. | 
| 66 |  |  | * ==================================================================== | 
| 67 |  |  | * | 
| 68 |  |  | * This software consists of voluntary contributions made by many | 
| 69 |  |  | * individuals on behalf of Lawrence Berkeley National Laboratory.   For more | 
| 70 |  |  | * information on Lawrence Berkeley National Laboratory, please see | 
| 71 |  |  | * <http://www.lbl.gov/>. | 
| 72 |  |  | */ | 
| 73 |  |  |  | 
| 74 |  |  | #ifdef __cplusplus | 
| 75 |  |  | extern "C" { | 
| 76 |  |  | #endif | 
| 77 |  |  |  | 
| 78 | greg | 1.1 | /* flags for scanline ordering */ | 
| 79 |  |  | #define  XDECR                  1 | 
| 80 |  |  | #define  YDECR                  2 | 
| 81 |  |  | #define  YMAJOR                 4 | 
| 82 |  |  |  | 
| 83 |  |  | /* standard scanline ordering */ | 
| 84 |  |  | #define  PIXSTANDARD            (YMAJOR|YDECR) | 
| 85 |  |  | #define  PIXSTDFMT              "-Y %d +X %d\n" | 
| 86 |  |  |  | 
| 87 |  |  | /* structure for image dimensions */ | 
| 88 |  |  | typedef struct { | 
| 89 | greg | 2.3 | int     rt;             /* orientation (from flags above) */ | 
| 90 | greg | 1.1 | int     xr, yr;         /* x and y resolution */ | 
| 91 |  |  | } RESOLU; | 
| 92 |  |  |  | 
| 93 |  |  | /* macros to get scanline length and number */ | 
| 94 | greg | 2.3 | #define  scanlen(rs)            ((rs)->rt & YMAJOR ? (rs)->xr : (rs)->yr) | 
| 95 |  |  | #define  numscans(rs)           ((rs)->rt & YMAJOR ? (rs)->yr : (rs)->xr) | 
| 96 | greg | 1.1 |  | 
| 97 |  |  | /* resolution string buffer and its size */ | 
| 98 |  |  | #define  RESOLU_BUFLEN          32 | 
| 99 |  |  | extern char  resolu_buf[RESOLU_BUFLEN]; | 
| 100 |  |  |  | 
| 101 |  |  | /* macros for reading/writing resolution struct */ | 
| 102 |  |  | #define  fputsresolu(rs,fp)     fputs(resolu2str(resolu_buf,rs),fp) | 
| 103 |  |  | #define  fgetsresolu(rs,fp)     str2resolu(rs, \ | 
| 104 |  |  | fgets(resolu_buf,RESOLU_BUFLEN,fp)) | 
| 105 |  |  |  | 
| 106 |  |  | /* reading/writing of standard ordering */ | 
| 107 |  |  | #define  fprtresolu(sl,ns,fp)   fprintf(fp,PIXSTDFMT,ns,sl) | 
| 108 |  |  | #define  fscnresolu(sl,ns,fp)   (fscanf(fp,PIXSTDFMT,ns,sl)==2) | 
| 109 |  |  |  | 
| 110 | greg | 2.3 | #ifdef NOPROTO | 
| 111 |  |  | /* defined in resolu.c */ | 
| 112 |  |  | extern void     fputresolu(); | 
| 113 |  |  | extern int      fgetresolu(); | 
| 114 |  |  | extern char     *resolu2str(); | 
| 115 |  |  | extern int      str2resolu(); | 
| 116 |  |  | /* defined in header.c */ | 
| 117 |  |  | extern void     newheader(); | 
| 118 |  |  | extern int      isheadid(); | 
| 119 |  |  | extern int      headidval(); | 
| 120 |  |  | extern int      dateval(); | 
| 121 |  |  | extern int      isdate(); | 
| 122 |  |  | extern void     fputdate(); | 
| 123 |  |  | extern void     fputnow(); | 
| 124 |  |  | extern void     printargs(); | 
| 125 |  |  | extern int      isformat(); | 
| 126 |  |  | extern int      formatval(); | 
| 127 |  |  | extern void     fputformat(); | 
| 128 |  |  | extern int      getheader(); | 
| 129 |  |  | extern int      globmatch(); | 
| 130 |  |  | extern int      checkheader(); | 
| 131 |  |  |  | 
| 132 |  |  | #else | 
| 133 |  |  | /* defined in resolu.c */ | 
| 134 |  |  | extern void     fputresolu(int ord, int sl, int ns, FILE *fp); | 
| 135 |  |  | extern int      fgetresolu(int *sl, int *ns, FILE *fp); | 
| 136 |  |  | extern char *   resolu2str(char *buf, RESOLU *rp); | 
| 137 |  |  | extern int      str2resolu(RESOLU *rp, char *buf); | 
| 138 |  |  | /* defined in header.c */ | 
| 139 |  |  | extern void     newheader(char *t, FILE *fp); | 
| 140 |  |  | extern int      isheadid(char *s); | 
| 141 |  |  | extern int      headidval(char *r, char *s); | 
| 142 |  |  | extern int      dateval(time_t *t, char *s); | 
| 143 |  |  | extern int      isdate(char *s); | 
| 144 |  |  | extern void     fputdate(time_t t, FILE *fp); | 
| 145 |  |  | extern void     fputnow(FILE *fp); | 
| 146 |  |  | extern void     printargs(int ac, char **av, FILE *fp); | 
| 147 |  |  | extern int      isformat(char *s); | 
| 148 |  |  | extern int      formatval(char *r, char *s); | 
| 149 |  |  | extern void     fputformat(char *s, FILE *fp); | 
| 150 |  |  | extern int      getheader(FILE *fp, int (*f)(), char *p); | 
| 151 |  |  | extern int      globmatch(char *pat, char *str); | 
| 152 |  |  | extern int      checkheader(FILE *fin, char *fmt, FILE *fout); | 
| 153 |  |  |  | 
| 154 |  |  | #endif | 
| 155 |  |  |  | 
| 156 |  |  | #ifdef __cplusplus | 
| 157 |  |  | } | 
| 158 |  |  | #endif |