--- ray/src/px/protate.c 1990/06/26 09:09:35 1.5 +++ ray/src/px/protate.c 1991/04/18 14:42:06 1.8 @@ -9,21 +9,39 @@ static char SCCSid[] = "$SunId$ LBL"; * 2/26/88 */ -#include +#include "standard.h" #include "color.h" int xres, yres; /* input resolution */ +double inpaspect = 1.0; /* input aspect ratio */ char buf[1<<20]; /* output buffer */ int nrows; /* number of rows output at once */ +int wrongformat = 0; + #define scanbar ((COLR *)buf) char *progname; +headline(s) /* process line from header */ +char *s; +{ + char fmt[32]; + + fputs(s, stdout); + if (isaspect(s)) + inpaspect *= aspectval(s); + else if (isformat(s)) { + formatval(fmt, s); + wrongformat = strcmp(fmt, COLRFMT); + } +} + + main(argc, argv) int argc; char *argv[]; @@ -44,9 +62,15 @@ char *argv[]; fprintf(stderr, "%s: cannot open\n", argv[2]); exit(1); } - /* copy header */ - copyheader(fin, stdout); + /* transfer header */ + getheader(fin, headline, NULL); + if (wrongformat) { + fprintf(stderr, "%s: wrong picture format\n", progname); + exit(1); + } /* add new header info. */ + if (inpaspect < .99 || inpaspect > 1.01) + fputaspect(1./inpaspect/inpaspect, stdout); printf("%s\n\n", progname); /* get picture size */ if (fgetresolu(&xres, &yres, fin) != (YMAJOR|YDECR)) {