ViewVC Help
View File | Revision Log | Show Annotations | Download File | Root Listing
root/radiance/ray/src/px/macbethcal.c
(Generate patch)

Comparing ray/src/px/macbethcal.c (file contents):
Revision 2.15 by greg, Thu Feb 6 11:36:53 1997 UTC vs.
Revision 2.18 by schorsch, Thu Jun 5 19:29:34 2003 UTC

# Line 1 | Line 1
1 /* Copyright (c) 1997 Regents of the University of California */
2
1   #ifndef lint
2 < static char SCCSid[] = "$SunId$ LBL";
2 > static const char       RCSid[] = "$Id$";
3   #endif
6
4   /*
5   * Calibrate a scanned MacBeth Color Checker Chart
6   *
# Line 15 | Line 12 | static char SCCSid[] = "$SunId$ LBL";
12  
13   #include <stdio.h>
14   #include <math.h>
15 < #ifdef MSDOS
16 < #include <fcntl.h>
17 < #endif
15 > #include <time.h>
16 >
17 > #include "platform.h"
18   #include "color.h"
19   #include "resolu.h"
20   #include "pmap.h"
# Line 100 | Line 97 | short  mbneu[NMBNEU] = {Black,Neutral35,Neutral5,Neutra
97   #define  RG_ORIG        02      /* original color region */
98   #define  RG_CORR        04      /* corrected color region */
99  
100 + #ifndef  DISPCOM
101 + #define  DISPCOM        "ximage -op %s"
102 + #endif
103 +
104   int     scanning = 1;           /* scanned input (or recorded output)? */
105   double  irrad = 1.0;            /* irradiance multiplication factor */
106   int     rawmap = 0;             /* put out raw color mapping? */
# Line 121 | Line 122 | WARP3D *wcor = NULL;           /* color space warp */
122   FILE    *debugfp = NULL;        /* debug output picture */
123   char    *progname;
124  
124 extern char     *malloc();
125  
126
126   main(argc, argv)
127   int     argc;
128   char    **argv;
# Line 141 | Line 140 | char   **argv;
140                                  perror(argv[i]);
141                                  exit(1);
142                          }
143 < #ifdef MSDOS
145 <                        setmode(fileno(debugfp), O_BINARY);
146 < #endif
143 >                        SET_FILE_BINARY(debugfp);
144                          newheader("RADIANCE", debugfp);         /* start */
145                          printargs(argc, argv, debugfp);         /* header */
146                          break;
# Line 160 | Line 157 | char   **argv;
157                          bounds[3][1] = atoi(argv[++i]);
158                          scanning = 2;
159                          break;
160 +                case 'P':                               /* pick position */
161 +                        scanning = 3;
162 +                        break;
163                  case 'i':                               /* irradiance factor */
164                          i++;
165                          if (badarg(argc-i, argv+i, "f"))
# Line 185 | Line 185 | char   **argv;
185                  exit(1);
186          }
187          if (scanning) {                 /* load input picture header */
188 < #ifdef MSDOS
189 <                setmode(fileno(stdin), O_BINARY);
190 < #endif
188 >                SET_FILE_BINARY(stdin);
189                  if (checkheader(stdin, COLRFMT, NULL) < 0 ||
190                                  fgetresolu(&xmax, &ymax, stdin) < 0) {
191                          fprintf(stderr, "%s: bad input picture\n", progname);
192                          exit(1);
193                  }
194 +                if (scanning == 3) {
195 +                        if (i >= argc)
196 +                                goto userr;
197 +                        pickchartpos(argv[i]);
198 +                        scanning = 2;
199 +                }
200          } else {                        /* else set default xmax and ymax */
201                  xmax = 512;
202                  ymax = 2*512/3;
# Line 245 | Line 249 | char   **argv;
249          exit(0);
250   userr:
251          fprintf(stderr,
252 < "Usage: %s [-d dbg.pic][-p xul yul xur yur xll yll xlr ylr][-i irrad][-m] input.pic [output.{cal|cwp}]\n",
252 > "Usage: %s [-d dbg.pic][-P | -p xul yul xur yur xll yll xlr ylr][-i irrad][-m] input.pic [output.{cal|cwp}]\n",
253                          progname);
254          fprintf(stderr, "   or: %s [-d dbg.pic][-i irrad][-m] -c [xyY.dat [output.{cal|cwp}]]\n",
255                          progname);
# Line 349 | Line 353 | getpicture()                           /* load in picture colors */
353                  scalecolor(inpRGB[i], d);
354                  inpflags |= 1L<<i;
355          }
356 <        free((char *)scanln);
356 >        free((void *)scanln);
357   }
358  
359  
# Line 699 | Line 703 | picdebug()                     /* put out debugging picture */
703          }
704                                                  /* clean up */
705          fclose(debugfp);
706 <        free((char *)scan);
706 >        free((void *)scan);
707   }
708  
709  
# Line 769 | Line 773 | clrdebug()                     /* put out debug picture from color input
773          }
774                                                  /* clean up */
775          fclose(debugfp);
776 <        free((char *)scan);
776 >        free((void *)scan);
777 > }
778 >
779 >
780 > getpos(name, bnds, fp)          /* get boundary position */
781 > char    *name;
782 > int     bnds[2];
783 > FILE    *fp;
784 > {
785 >        char    buf[64];
786 >
787 >        fprintf(stderr, "\tSelect corner: %s\n", name);
788 >        if (fgets(buf, sizeof(buf), fp) == NULL ||
789 >                        sscanf(buf, "%d %d", &bnds[0], &bnds[1]) != 2) {
790 >                fprintf(stderr, "%s: read error from display process\n",
791 >                                progname);
792 >                exit(1);
793 >        }
794 > }
795 >
796 >
797 > pickchartpos(pfn)               /* display picture and pick chart location */
798 > char    *pfn;
799 > {
800 >        char    combuf[512];
801 >        FILE    *pfp;
802 >
803 >        sprintf(combuf, DISPCOM, pfn);
804 >        if ((pfp = popen(combuf, "r")) == NULL) {
805 >                perror(combuf);
806 >                exit(1);
807 >        }
808 >        fputs("Use middle mouse button to select chart corners:\n", stderr);
809 >        getpos("upper left (dark skin)", bounds[0], pfp);
810 >        getpos("upper right (bluish green)", bounds[1], pfp);
811 >        getpos("lower left (white)", bounds[2], pfp);
812 >        getpos("lower right (black)", bounds[3], pfp);
813 >        fputs("Got it -- quit display program.\n", stderr);
814 >        pclose(pfp);
815   }

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines