--- ray/src/px/macbethcal.c 1997/02/04 16:04:23 2.14 +++ ray/src/px/macbethcal.c 2003/06/05 19:29:34 2.18 @@ -1,9 +1,6 @@ -/* Copyright (c) 1997 Regents of the University of California */ - #ifndef lint -static char SCCSid[] = "$SunId$ LBL"; +static const char RCSid[] = "$Id: macbethcal.c,v 2.18 2003/06/05 19:29:34 schorsch Exp $"; #endif - /* * Calibrate a scanned MacBeth Color Checker Chart * @@ -15,9 +12,9 @@ static char SCCSid[] = "$SunId$ LBL"; #include #include -#ifdef MSDOS -#include -#endif +#include + +#include "platform.h" #include "color.h" #include "resolu.h" #include "pmap.h" @@ -100,6 +97,10 @@ short mbneu[NMBNEU] = {Black,Neutral35,Neutral5,Neutra #define RG_ORIG 02 /* original color region */ #define RG_CORR 04 /* corrected color region */ +#ifndef DISPCOM +#define DISPCOM "ximage -op %s" +#endif + int scanning = 1; /* scanned input (or recorded output)? */ double irrad = 1.0; /* irradiance multiplication factor */ int rawmap = 0; /* put out raw color mapping? */ @@ -121,9 +122,7 @@ WARP3D *wcor = NULL; /* color space warp */ FILE *debugfp = NULL; /* debug output picture */ char *progname; -extern char *malloc(); - main(argc, argv) int argc; char **argv; @@ -141,9 +140,7 @@ char **argv; perror(argv[i]); exit(1); } -#ifdef MSDOS - setmode(fileno(debugfp), O_BINARY); -#endif + SET_FILE_BINARY(debugfp); newheader("RADIANCE", debugfp); /* start */ printargs(argc, argv, debugfp); /* header */ break; @@ -160,6 +157,9 @@ char **argv; bounds[3][1] = atoi(argv[++i]); scanning = 2; break; + case 'P': /* pick position */ + scanning = 3; + break; case 'i': /* irradiance factor */ i++; if (badarg(argc-i, argv+i, "f")) @@ -185,14 +185,18 @@ char **argv; exit(1); } if (scanning) { /* load input picture header */ -#ifdef MSDOS - setmode(fileno(stdin), O_BINARY); -#endif + SET_FILE_BINARY(stdin); if (checkheader(stdin, COLRFMT, NULL) < 0 || fgetresolu(&xmax, &ymax, stdin) < 0) { fprintf(stderr, "%s: bad input picture\n", progname); exit(1); } + if (scanning == 3) { + if (i >= argc) + goto userr; + pickchartpos(argv[i]); + scanning = 2; + } } else { /* else set default xmax and ymax */ xmax = 512; ymax = 2*512/3; @@ -214,7 +218,7 @@ char **argv; printf("# Color correspondence produced by:\n#\t\t"); printargs(argc, argv, stdout); - printf("#\tUsage: pcwarp -m %s uncorrected.pic > corrected.pic\n", + printf("#\tUsage: pcwarp %s uncorrected.pic > corrected.pic\n", i+1 < argc ? argv[i+1] : "{this_file}"); printf("#\t Or: pcond [options] -m %s orig.pic > output.pic\n", i+1 < argc ? argv[i+1] : "{this_file}"); @@ -245,7 +249,7 @@ char **argv; exit(0); userr: fprintf(stderr, -"Usage: %s [-d dbg.pic][-p xul yul xur yur xll yll xlr ylr][-i irrad][-m] input.pic [output.{cal|cwp}]\n", +"Usage: %s [-d dbg.pic][-P | -p xul yul xur yur xll yll xlr ylr][-i irrad][-m] input.pic [output.{cal|cwp}]\n", progname); fprintf(stderr, " or: %s [-d dbg.pic][-i irrad][-m] -c [xyY.dat [output.{cal|cwp}]]\n", progname); @@ -349,7 +353,7 @@ getpicture() /* load in picture colors */ scalecolor(inpRGB[i], d); inpflags |= 1L<