| 1 |
greg |
1.1 |
/* Copyright (c) 1991 Regents of the University of California */
|
| 2 |
|
|
|
| 3 |
|
|
/* SCCSid "$SunId$ LBL" */
|
| 4 |
|
|
|
| 5 |
|
|
/*
|
| 6 |
|
|
* Definitions for resolution line in image file.
|
| 7 |
|
|
*
|
| 8 |
|
|
* True image orientation is defined by an xy coordinate system
|
| 9 |
|
|
* whose origin is at the lower left corner of the image, with
|
| 10 |
|
|
* x increasing to the right and y increasing in the upward direction.
|
| 11 |
|
|
* This true orientation is independent of how the pixels are actually
|
| 12 |
|
|
* ordered in the file, which is indicated by the resolution line.
|
| 13 |
|
|
* This line is of the form "{+-}{XY} xyres {+-}{YX} yxres\n".
|
| 14 |
|
|
* A typical line for a 1024x600 image might be "-Y 600 +X 1024\n",
|
| 15 |
|
|
* indicating that the scanlines are in English text order (PIXSTANDARD).
|
| 16 |
|
|
*/
|
| 17 |
|
|
|
| 18 |
|
|
/* flags for scanline ordering */
|
| 19 |
|
|
#define XDECR 1
|
| 20 |
|
|
#define YDECR 2
|
| 21 |
|
|
#define YMAJOR 4
|
| 22 |
|
|
|
| 23 |
|
|
/* standard scanline ordering */
|
| 24 |
|
|
#define PIXSTANDARD (YMAJOR|YDECR)
|
| 25 |
|
|
#define PIXSTDFMT "-Y %d +X %d\n"
|
| 26 |
|
|
|
| 27 |
|
|
/* structure for image dimensions */
|
| 28 |
|
|
typedef struct {
|
| 29 |
|
|
int or; /* orientation (from flags above) */
|
| 30 |
|
|
int xr, yr; /* x and y resolution */
|
| 31 |
|
|
} RESOLU;
|
| 32 |
|
|
|
| 33 |
|
|
/* macros to get scanline length and number */
|
| 34 |
|
|
#define scanlen(rs) ((rs)->or & YMAJOR ? (rs)->xr : (rs)->yr)
|
| 35 |
|
|
#define numscans(rs) ((rs)->or & YMAJOR ? (rs)->yr : (rs)->xr)
|
| 36 |
|
|
|
| 37 |
|
|
/* resolution string buffer and its size */
|
| 38 |
|
|
#define RESOLU_BUFLEN 32
|
| 39 |
|
|
extern char resolu_buf[RESOLU_BUFLEN];
|
| 40 |
|
|
|
| 41 |
|
|
/* macros for reading/writing resolution struct */
|
| 42 |
|
|
#define fputsresolu(rs,fp) fputs(resolu2str(resolu_buf,rs),fp)
|
| 43 |
|
|
#define fgetsresolu(rs,fp) str2resolu(rs, \
|
| 44 |
|
|
fgets(resolu_buf,RESOLU_BUFLEN,fp))
|
| 45 |
|
|
|
| 46 |
|
|
/* reading/writing of standard ordering */
|
| 47 |
|
|
#define fprtresolu(sl,ns,fp) fprintf(fp,PIXSTDFMT,ns,sl)
|
| 48 |
|
|
#define fscnresolu(sl,ns,fp) (fscanf(fp,PIXSTDFMT,ns,sl)==2)
|
| 49 |
|
|
|
| 50 |
|
|
extern char *fgets(), *resolu2str();
|