--- ray/src/px/ximage.c 1991/03/18 09:35:04 1.28 +++ ray/src/px/ximage.c 1991/11/12 16:05:14 2.1 @@ -23,6 +23,8 @@ static char SCCSid[] = "$SunId$ LBL"; #include "color.h" +#include "resolu.h" + #include "xraster.h" #include "view.h" @@ -72,6 +74,8 @@ int cury = 0; /* current scan location */ double exposure = 1.0; /* exposure compensation used */ +int wrongformat = 0; /* input in another format */ + struct { int xmin, ymin, xsiz, ysiz; } box = {0, 0, 0, 0}; /* current box */ @@ -141,9 +145,9 @@ char *argv[]; } } /* get header */ - getheader(fin, headline); + getheader(fin, headline, NULL); /* get picture dimensions */ - if (fgetresolu(&xmax, &ymax, fin) != (YMAJOR|YDECR)) + if (wrongformat || fgetresolu(&xmax, &ymax, fin) != (YMAJOR|YDECR)) quiterr("bad picture size"); /* set view parameters */ if (gotview && setview(&ourview) != NULL) @@ -168,10 +172,14 @@ char *s; { static char *altname[] = {"rview","rpict",VIEWSTR,NULL}; register char **an; + char fmt[32]; if (isexpos(s)) exposure *= exposval(s); - else + else if (isformat(s)) { + formatval(fmt, s); + wrongformat = strcmp(fmt, COLRFMT); + } else for (an = altname; *an != NULL; an++) if (!strncmp(*an, s, strlen(*an))) { if (sscanview(&ourview, s+strlen(*an)) > 0) @@ -373,7 +381,7 @@ XKeyEvent *ekey; sprintf(buf, "%.3f", intens(cval)/exposure); break; case 'l': /* luminance */ - sprintf(buf, "%.0fn", luminance(cval)/exposure); + sprintf(buf, "%.0fL", luminance(cval)/exposure); break; case 'c': /* color */ comp = pow(2.0, (double)scale); @@ -542,7 +550,7 @@ getmono() /* get monochrome data */ { register unsigned short *dp; register int x, err; - int y; + int y, errp; rgbpixel *inl; short *cerr; @@ -556,12 +564,14 @@ getmono() /* get monochrome data */ for (x = 0; x < xmax; x++) { if (!(x&0xf)) *++dp = 0; + errp = err; err += rgb_bright(&inl[x]) + cerr[x]; if (err > 127) err -= 255; else *dp |= 1<<(x&0xf); - cerr[x] = err >>= 1; + err /= 3; + cerr[x] = err + errp; } } free((char *)inl);