--- ray/src/common/header.c 2020/07/25 01:10:38 2.40 +++ ray/src/common/header.c 2022/03/06 16:33:44 2.45 @@ -1,5 +1,5 @@ #ifndef lint -static const char RCSid[] = "$Id: header.c,v 2.40 2020/07/25 01:10:38 greg Exp $"; +static const char RCSid[] = "$Id: header.c,v 2.45 2022/03/06 16:33:44 greg Exp $"; #endif /* * header.c - routines for reading and writing information headers. @@ -31,6 +31,7 @@ static const char RCSid[] = "$Id: header.c,v 2.40 2020 #include "tiff.h" /* for int32 */ #include "rtio.h" +#include "color.h" #include "resolu.h" #define MAXLINE 2048 @@ -57,7 +58,7 @@ newheader( /* identifying line of information header { fputs(HDRSTR, fp); fputs(s, fp); - putc('\n', fp); + fputc('\n', fp); } @@ -209,9 +210,35 @@ fputformat( /* put out a format value */ FILE *fp ) { + int align = 0; + fputs(FMTSTR, fp); fputs(s, fp); - putc('\n', fp); + /* pad to align binary type for mmap() */ + if (globmatch(PICFMT, s)) + align = 0; /* not needed for picture data */ + else if (!strncmp("float", s, 5)) + align = sizeof(float); + else if (!strncmp("double", s, 6)) + align = sizeof(double); + else if (!strncmp("16-bit", s, 6)) + align = 2; + else if (!strncmp("32-bit", s, 6)) + align = 4; + else if (!strncmp("64-bit", s, 6)) + align = 8; + if (align) { + long pos = ftell(fp); + if (pos >= 0) { + pos = (pos + 2) % align; + if (pos) align -= pos; + else align = 0; + } else + align = 0; + } + while (align-- > 0) + putc(' ', fp); + fputc('\n', fp); } @@ -343,7 +370,7 @@ globmatch( /* check for match of s against pattern p if (!*p) return(0); if (*p == '-') { - setmatch += (p[-1] <= *s && *s <= p[1]); + setmatch += (p[-1] <= *s) & (*s <= p[1]); if (!*++p) break; } else