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.4 by greg, Wed Oct 11 20:48:17 1995 UTC vs.
Revision 2.8 by greg, Mon Oct 23 10:19:40 1995 UTC

# Line 77 | Line 77 | COLOR  mbRGB[24];              /* MacBeth RGB values */
77   #define NMBNEU          6       /* Number of MacBeth neutral colors */
78   short   mbneu[NMBNEU] = {Black,Neutral35,Neutral5,Neutral65,Neutral8,White};
79  
80 < #define NMBMOD          17      /* Number of MacBeth unsaturated colors */
81 < short   mbmod[NMBMOD] = {
82 <                DarkSkin,LightSkin,BlueSky,Foliage,BlueFlower,BluishGreen,
83 <                Orange,PurplishBlue,ModerateRed,Purple,YellowGreen,
84 <                Black,Neutral35,Neutral5,Neutral65,Neutral8,White
85 <        };
80 > #define  NEUFLGS        (1L<<White|1L<<Neutral8|1L<<Neutral65| \
81 >                                1L<<Neutral5|1L<<Neutral35|1L<<Black)
82  
83 < #define NMBSAT          8       /* Number of MacBeth saturated colors */
84 < short   mbsat[NMBSAT] = {
85 <                Red,Green,Blue,Magenta,Yellow,Cyan,
90 <                Orange,OrangeYellow
91 <        };
83 > #define  SATFLGS        (1L<<Red|1L<<Green|1L<<Blue|1L<<Magenta|1L<<Yellow| \
84 >                        1L<<Cyan|1L<<Orange|1L<<Purple|1L<<PurplishBlue| \
85 >                        1L<<YellowGreen|1<<OrangeYellow|1L<<BlueFlower)
86  
87 + #define  UNSFLGS        (1L<<DarkSkin|1L<<LightSkin|1L<<BlueSky|1L<<Foliage| \
88 +                        1L<<BluishGreen|1L<<ModerateRed)
89 +
90 + #define  REQFLGS        NEUFLGS                 /* need these colors */
91 + #define  MODFLGS        (NEUFLGS|UNSFLGS)       /* should be in gamut */
92 +
93 + #define  CENTCVG        0.3     /* measured coverage of square sample */
94 + #define  FULLCVG        0.9     /* coverage of entire square */
95 +
96   int     xmax, ymax;             /* input image dimensions */
97   int     bounds[4][2];           /* image coordinates of chart corners */
98   double  imgxfm[3][3];           /* coordinate transformation matrix */
99  
100 < COLOR   picRGB[24];             /* picture colors */
100 > COLOR   inpRGB[24];             /* measured or scanned input colors */
101 > long    inpflags = 0;           /* flags of which colors were input */
102 > long    gmtflags = 0;           /* flags of out-of-gamut colors */
103  
104   COLOR   bramp[NMBNEU][2];       /* brightness ramp (per primary) */
105   double  solmat[3][3];           /* color mapping matrix */
# Line 109 | Line 114 | main(argc, argv)
114   int     argc;
115   char    **argv;
116   {
117 +        int     inpispic = 1;
118          int     i;
119  
120          progname = argv[0];
121 <        if (argc > 2 && !strcmp(argv[1], "-d")) {       /* debug output */
122 <                if ((debugfp = fopen(argv[2], "w")) == NULL) {
123 <                        perror(argv[2]);
124 <                        exit(1);
125 <                }
121 >        for (i = 1; i < argc && argv[i][0] == '-'; i++)
122 >                switch (argv[i][1]) {
123 >                case 'd':                               /* debug output */
124 >                        i++;
125 >                        if (badarg(argc-i, argv+i, "s"))
126 >                                goto userr;
127 >                        if ((debugfp = fopen(argv[i], "w")) == NULL) {
128 >                                perror(argv[i]);
129 >                                exit(1);
130 >                        }
131   #ifdef MSDOS
132 <                setmode(fileno(debugfp), O_BINARY);
132 >                        setmode(fileno(debugfp), O_BINARY);
133   #endif
134 <                newheader("RADIANCE", debugfp);
135 <                printargs(argc, argv, debugfp);
136 <                argv += 2;
137 <                argc -= 2;
138 <        }
139 <        if (argc != 3 && argc != 11)
140 <                goto userr;
141 <        if (strcmp(argv[1], "-") && freopen(argv[1], "r", stdin) == NULL) {
134 >                        newheader("RADIANCE", debugfp);         /* start */
135 >                        printargs(argc, argv, debugfp);         /* header */
136 >                        break;
137 >                case 'p':                               /* picture position */
138 >                        if (badarg(argc-i-1, argv+i+1, "iiiiiiii"))
139 >                                goto userr;
140 >                        bounds[0][0] = atoi(argv[++i]);
141 >                        bounds[0][1] = atoi(argv[++i]);
142 >                        bounds[1][0] = atoi(argv[++i]);
143 >                        bounds[1][1] = atoi(argv[++i]);
144 >                        bounds[2][0] = atoi(argv[++i]);
145 >                        bounds[2][1] = atoi(argv[++i]);
146 >                        bounds[3][0] = atoi(argv[++i]);
147 >                        bounds[3][1] = atoi(argv[++i]);
148 >                        inpispic = 2;
149 >                        break;
150 >                case 'c':                               /* color input */
151 >                        inpispic = 0;
152 >                        break;
153 >                default:
154 >                        goto userr;
155 >                }
156 >                                                        /* open files */
157 >        if (i < argc && freopen(argv[i], "r", stdin) == NULL) {
158                  perror(argv[1]);
159                  exit(1);
160          }
161 <        if (strcmp(argv[2], "-") && freopen(argv[2], "w", stdout) == NULL) {
161 >        if (i+1 < argc && freopen(argv[i+1], "w", stdout) == NULL) {
162                  perror(argv[2]);
163                  exit(1);
164          }
165 +        if (inpispic) {                 /* load input picture header */
166   #ifdef MSDOS
167 <        setmode(fileno(stdin), O_BINARY);
167 >                setmode(fileno(stdin), O_BINARY);
168   #endif
169 <        if (checkheader(stdin, COLRFMT, NULL) < 0 ||
170 <                        fgetresolu(&xmax, &ymax, stdin) < 0) {
171 <                fprintf(stderr, "%s: bad input picture\n", progname);
172 <                exit(1);
145 <        }
146 <                                        /* get chart boundaries */
147 <        if (argc == 11) {
148 <                for (i = 0; i < 4; i++) {
149 <                        if (!isint(argv[2*i+3]) | !isint(argv[2*i+4]))
150 <                                goto userr;
151 <                        bounds[i][0] = atoi(argv[2*i+3]);
152 <                        bounds[i][1] = atoi(argv[2*i+4]);
169 >                if (checkheader(stdin, COLRFMT, NULL) < 0 ||
170 >                                fgetresolu(&xmax, &ymax, stdin) < 0) {
171 >                        fprintf(stderr, "%s: bad input picture\n", progname);
172 >                        exit(1);
173                  }
174 <        } else {
174 >        } else {                        /* else set default xmax and ymax */
175 >                xmax = 512;
176 >                ymax = 2*512/3;
177 >        }
178 >        if (inpispic != 2) {            /* use default boundaries */
179                  bounds[0][0] = bounds[2][0] = .029*xmax + .5;
180                  bounds[0][1] = bounds[1][1] = .956*ymax + .5;
181                  bounds[1][0] = bounds[3][0] = .971*xmax + .5;
182                  bounds[2][1] = bounds[3][1] = .056*ymax + .5;
183          }
184          init();                         /* initialize */
185 <        getcolors();                    /* get picture colors */
185 >        if (inpispic)                   /* get picture colors */
186 >                getpicture();
187 >        else
188 >                getcolors();
189          compute();                      /* compute color mapping */
190                                          /* print comment */
191 <        printf("{ Color correction file computed by %s }\n", progname);
192 <        printf("{ from scanned MacBetch color chart %s }\n", argv[1]);
191 >        printf("{ Color correction file computed by:\n\t");
192 >        printargs(argc, argv, stdout);
193 >        printf("}\n");
194          putmapping();                   /* put out color mapping */
195 <        putdebug();                     /* put out debug picture */
195 >        if (debugfp != NULL)            /* put out debug picture */
196 >                if (inpispic)
197 >                        picdebug();
198 >                else
199 >                        clrdebug();
200          exit(0);
201   userr:
202 <        fprintf(stderr, "Usage: %s [-d dbg.pic] input.pic output.cal [xul yul xur yur xll yll xlr ylr]\n",
202 >        fprintf(stderr,
203 > "Usage: %s [-d dbg.pic][-p xul yul xur yur xll yll xlr ylr] input.pic [output.cal]\n",
204                          progname);
205 +        fprintf(stderr, "   or: %s [-d dbg.pic] -c [xyY.dat [output.cal]]\n",
206 +                        progname);
207          exit(1);
208   }
209  
# Line 176 | Line 211 | userr:
211   init()                          /* initialize */
212   {
213          double  quad[4][2];
214 +        register int    i;
215                                          /* make coordinate transformation */
216          quad[0][0] = bounds[0][0];
217          quad[0][1] = bounds[0][1];
# Line 190 | Line 226 | init()                         /* initialize */
226                  fprintf(stderr, "%s: bad chart boundaries\n", progname);
227                  exit(1);
228          }
229 +                                        /* map MacBeth colors to RGB space */
230 +        for (i = 0; i < 24; i++)
231 +                xyY2RGB(mbRGB[i], mbxyY[i]);
232   }
233  
234  
235   int
236 < chartndx(x, y)                          /* find color number for position */
236 > chartndx(x, y, cvg)                     /* find color number for position */
237   int     x, y;
238 + double  cvg;
239   {
240          double  ipos[3], cpos[3];
241          int     ix, iy;
242          double  fx, fy;
243 +        double  cmin, cmax;
244  
245          ipos[0] = x;
246          ipos[1] = y;
# Line 213 | Line 254 | int    x, y;
254          iy = cpos[1];
255          fx = cpos[0] - ix;
256          fy = cpos[1] - iy;
257 <        if (fx < .35 || fx >= .65 || fy < .35 || fy >= .65)
257 >        cmin = .5*(1.-cvg);
258 >        cmax = 1. - cmin;
259 >        if (fx < cmin || fx >= cmax || fy < cmin || fy >= cmax)
260                  return(-1);
261          return(iy*6 + ix);
262   }
263  
264  
265 < getcolors()                             /* load in picture colors */
265 > getpicture()                            /* load in picture colors */
266   {
267          COLR    *scanln;
268          COLOR   pval;
# Line 234 | Line 277 | getcolors()                            /* load in picture colors */
277                  exit(1);
278          }
279          for (i = 0; i < 24; i++) {
280 <                setcolor(picRGB[i], 0., 0., 0.);
280 >                setcolor(inpRGB[i], 0., 0., 0.);
281                  ccount[i] = 0;
282          }
283          for (y = ymax-1; y >= 0; y--) {
# Line 244 | Line 287 | getcolors()                            /* load in picture colors */
287                          exit(1);
288                  }
289                  for (x = 0; x < xmax; x++) {
290 <                        i = chartndx(x, y);
290 >                        i = chartndx(x, y, CENTCVG);
291                          if (i >= 0) {
292                                  colr_color(pval, scanln[x]);
293 <                                addcolor(picRGB[i], pval);
293 >                                addcolor(inpRGB[i], pval);
294                                  ccount[i]++;
295                          }
296                  }
297          }
298 <        for (i = 0; i < 24; i++) {
299 <                if (ccount[i] == 0) {
300 <                        fprintf(stderr, "%s: bad chart boundaries\n",
298 >        for (i = 0; i < 24; i++) {              /* compute averages */
299 >                if (ccount[i] == 0)
300 >                        continue;
301 >                d = 1./ccount[i];
302 >                scalecolor(inpRGB[i], d);
303 >                inpflags |= 1L<<i;
304 >        }
305 >        free((char *)scanln);
306 > }
307 >
308 >
309 > getcolors()                     /* get xyY colors from standard input */
310 > {
311 >        int     gotwhite = 0;
312 >        COLOR   whiteclr;
313 >        int     n;
314 >        float   xyYin[3];
315 >
316 >        while (fgetval(stdin, 'i', &n) == 1) {          /* read colors */
317 >                if (n < 0 | n > 24 ||
318 >                                fgetval(stdin, 'f', &xyYin[0]) != 1 ||
319 >                                fgetval(stdin, 'f', &xyYin[1]) != 1 ||
320 >                                fgetval(stdin, 'f', &xyYin[2]) != 1 ||
321 >                                xyYin[0] < 0. | xyYin[0] > 1. |
322 >                                xyYin[1] < 0. | xyYin[1] > 1.) {
323 >                        fprintf(stderr, "%s: bad color input data\n",
324                                          progname);
325                          exit(1);
326                  }
327 <                d = 1.0/ccount[i];
328 <                scalecolor(picRGB[i], d);
327 >                if (n == 0) {                           /* calibration white */
328 >                        xyY2RGB(whiteclr, xyYin);
329 >                        gotwhite++;
330 >                } else {                                /* standard color */
331 >                        n--;
332 >                        xyY2RGB(inpRGB[n], xyYin);
333 >                        inpflags |= 1L<<n;
334 >                }
335          }
336 <        free((char *)scanln);
336 >                                        /* normalize colors */
337 >        if (!gotwhite) {
338 >                if (!(inpflags & 1L<<White)) {
339 >                        fprintf(stderr, "%s: missing input for White\n",
340 >                                        progname);
341 >                        exit(1);
342 >                }
343 >                setcolor(whiteclr,
344 >                        colval(inpRGB[White],RED)/colval(mbRGB[White],RED),
345 >                        colval(inpRGB[White],GRN)/colval(mbRGB[White],GRN),
346 >                        colval(inpRGB[White],BLU)/colval(mbRGB[White],BLU));
347 >        }
348 >        for (n = 0; n < 24; n++)
349 >                if (inpflags & 1L<<n)
350 >                        setcolor(inpRGB[n],
351 >                                colval(inpRGB[n],RED)/colval(whiteclr,RED),
352 >                                colval(inpRGB[n],GRN)/colval(whiteclr,GRN),
353 >                                colval(inpRGB[n],BLU)/colval(whiteclr,BLU));
354   }
355  
356  
357   bresp(y, x)             /* piecewise linear interpolation of primaries */
358   COLOR   y, x;
359   {
271        double  cv[3];
360          register int    i, n;
361  
362          for (i = 0; i < 3; i++) {
363 <                n = NMBNEU;
364 <                while (n > 0 && colval(x,i) < colval(bramp[--n][0],i))
365 <                        ;
366 <                cv[i] = ((colval(bramp[n+1][0],i) - colval(x,i)) *
363 >                for (n = 0; n < NMBNEU-2; n++)
364 >                        if (colval(x,i) < colval(bramp[n+1][0],i))
365 >                                break;
366 >                colval(y,i) = ((colval(bramp[n+1][0],i) - colval(x,i)) *
367                                                  colval(bramp[n][1],i) +
368                                  (colval(x,i) - colval(bramp[n][0],i)) *
369                                                  colval(bramp[n+1][1],i)) /
370                          (colval(bramp[n+1][0],i) - colval(bramp[n][0],i));
283                if (cv[i] < 0.) cv[i] = 0.;
371          }
285        setcolor(y, cv[0], cv[1], cv[2]);
372   }
373  
374  
375   compute()                       /* compute color mapping */
376   {
377 <        COLOR   clrin[NMBMOD], clrout[NMBMOD];
377 >        COLOR   clrin[24], clrout[24];
378 >        long    cflags;
379          COLOR   ctmp;
380 <        double  d;
381 <        register int    i;
382 <                                        /* map MacBeth colors to RGB space */
383 <        for (i = 0; i < 24; i++) {
384 <                d = mbxyY[i][2] / mbxyY[i][1];
385 <                ctmp[0] = mbxyY[i][0] * d;
299 <                ctmp[1] = mbxyY[i][2];
300 <                ctmp[2] = (1. - mbxyY[i][0] - mbxyY[i][1]) * d;
301 <                cie_rgb(mbRGB[i], ctmp);
380 >        register int    i, j, n;
381 >                                        /* did we get what we need? */
382 >        if ((inpflags & REQFLGS) != REQFLGS) {
383 >                fprintf(stderr, "%s: missing required input colors\n",
384 >                                progname);
385 >                exit(1);
386          }
387                                          /* compute piecewise luminance curve */
388          for (i = 0; i < NMBNEU; i++) {
389 <                copycolor(bramp[i][0], picRGB[mbneu[i]]);
389 >                copycolor(bramp[i][0], inpRGB[mbneu[i]]);
390                  copycolor(bramp[i][1], mbRGB[mbneu[i]]);
391          }
392 <                                        /* compute color matrix */
393 <        for (i = 0; i < NMBMOD; i++) {
394 <                bresp(clrin[i], picRGB[mbmod[i]]);
395 <                copycolor(clrout[i], mbRGB[mbmod[i]]);
396 <        }
397 <        compsoln(clrin, clrout, NMBMOD);
392 >                                        /* compute color mapping */
393 >        do {
394 >                cflags = inpflags & ~gmtflags;
395 >                n = 0;                          /* compute transform matrix */
396 >                for (i = 0; i < 24; i++)
397 >                        if (cflags & 1L<<i) {
398 >                                bresp(clrin[n], inpRGB[i]);
399 >                                copycolor(clrout[n], mbRGB[i]);
400 >                                n++;
401 >                        }
402 >                compsoln(clrin, clrout, n);
403 >                                                /* check out-of-gamut colors */
404 >                for (i = 0; i < 24; i++)
405 >                        if (cflags & 1L<<i) {
406 >                                cresp(ctmp, mbRGB[i]);
407 >                                for (j = 0; j < 3; j++)
408 >                                        if (colval(ctmp,j) <= 0. ||
409 >                                                colval(ctmp,j) >= 1.) {
410 >                                                gmtflags |= 1L<<i;
411 >                                                break;
412 >                                        }
413 >                        }
414 >        } while (cflags & gmtflags);
415 >        if (gmtflags & MODFLGS)
416 >                fprintf(stderr,
417 >                "%s: warning - some moderate colors are out of gamut\n",
418 >                                progname);
419   }
420  
421  
# Line 362 | Line 467 | int    n;
467          double  colv[3], rowv[3];
468          register int    i, j, k;
469  
470 <        if (n < 3 | n > NMBMOD) {
471 <                fprintf(stderr, "%s: inconsistent code!\n", progname);
470 >        if (n < 3) {
471 >                fprintf(stderr, "%s: too few colors to match!\n", progname);
472                  exit(1);
473          }
474          if (n == 3)
# Line 415 | Line 520 | int    n;
520   cvtcolor(cout, cin)             /* convert color according to our mapping */
521   COLOR   cout, cin;
522   {
523 +        COLOR   ctmp;
524 +
525 +        bresp(ctmp, cin);
526 +        cresp(cout, ctmp);
527 +        if (colval(cout,RED) < 0.)
528 +                colval(cout,RED) = 0.;
529 +        if (colval(cout,GRN) < 0.)
530 +                colval(cout,GRN) = 0.;
531 +        if (colval(cout,BLU) < 0.)
532 +                colval(cout,BLU) = 0.;
533 + }
534 +
535 +
536 + cresp(cout, cin)                /* transform color according to matrix */
537 + COLOR   cout, cin;
538 + {
539          double  r, g, b;
540  
541 <        bresp(cout, cin);
542 <        r = colval(cout,0)*solmat[0][0] + colval(cout,1)*solmat[0][1]
543 <                        + colval(cout,2)*solmat[0][2];
544 <        if (r < 0) r = 0;
545 <        g = colval(cout,0)*solmat[1][0] + colval(cout,1)*solmat[1][1]
546 <                        + colval(cout,2)*solmat[1][2];
426 <        if (g < 0) g = 0;
427 <        b = colval(cout,0)*solmat[2][0] + colval(cout,1)*solmat[2][1]
428 <                        + colval(cout,2)*solmat[2][2];
429 <        if (b < 0) b = 0;
541 >        r = colval(cin,0)*solmat[0][0] + colval(cin,1)*solmat[0][1]
542 >                        + colval(cin,2)*solmat[0][2];
543 >        g = colval(cin,0)*solmat[1][0] + colval(cin,1)*solmat[1][1]
544 >                        + colval(cin,2)*solmat[1][2];
545 >        b = colval(cin,0)*solmat[2][0] + colval(cin,1)*solmat[2][1]
546 >                        + colval(cin,2)*solmat[2][2];
547          setcolor(cout, r, g, b);
548   }
549  
550  
551 < putdebug()                      /* put out debugging picture */
551 > xyY2RGB(rgbout, xyYin)          /* convert xyY to RGB */
552 > COLOR   rgbout;
553 > register float  xyYin[3];
554   {
555 +        COLOR   ctmp;
556 +        double  d;
557 +
558 +        d = xyYin[2] / xyYin[1];
559 +        ctmp[0] = xyYin[0] * d;
560 +        ctmp[1] = xyYin[2];
561 +        ctmp[2] = (1. - xyYin[0] - xyYin[1]) * d;
562 +        cie_rgb(rgbout, ctmp);
563 + }
564 +
565 +
566 + picdebug()                      /* put out debugging picture */
567 + {
568 +        static COLOR    blkcol = BLKCOLOR;
569          COLOR   *scan;
570          int     y;
571          register int    x, i;
572  
440        if (debugfp == NULL)
441                return;
573          if (fseek(stdin, 0L, 0) == EOF) {
574                  fprintf(stderr, "%s: cannot seek on input picture\n", progname);
575                  exit(1);
# Line 452 | Line 583 | putdebug()                     /* put out debugging picture */
583                  exit(1);
584          }
585                                                  /* finish debug header */
586 +        fputformat(COLRFMT, debugfp);
587          putc('\n', debugfp);
588          fprtresolu(xmax, ymax, debugfp);
589 +                                                /* write debug picture */
590          for (y = ymax-1; y >= 0; y--) {
591                  if (freadscan(scan, xmax, stdin) < 0) {
592                          fprintf(stderr, "%s: error rereading input picture\n",
# Line 461 | Line 594 | putdebug()                     /* put out debugging picture */
594                          exit(1);
595                  }
596                  for (x = 0; x < xmax; x++) {
597 <                        i = chartndx(x, y);
597 >                        i = chartndx(x, y, CENTCVG);
598                          if (i < 0)
599                                  cvtcolor(scan[x], scan[x]);
600 <                        else
600 >                        else if (!(1L<<i & gmtflags) || (x+y)&07)
601                                  copycolor(scan[x], mbRGB[i]);
602 +                        else
603 +                                copycolor(scan[x], blkcol);
604                  }
605                  if (fwritescan(scan, xmax, debugfp) < 0) {
606                          fprintf(stderr, "%s: error writing debugging picture\n",
# Line 473 | Line 608 | putdebug()                     /* put out debugging picture */
608                          exit(1);
609                  }
610          }
611 +                                                /* clean up */
612 +        fclose(debugfp);
613 +        free((char *)scan);
614 + }
615 +
616 +
617 + clrdebug()                      /* put out debug picture from color input */
618 + {
619 +        static COLR     blkclr = BLKCOLR;
620 +        COLR    mbclr[24], cvclr[24];
621 +        COLR    *scan;
622 +        COLOR   ctmp;
623 +        int     y;
624 +        register int    i, x;
625 +                                                /* convert colors */
626 +        for (i = 0; i < 24; i++) {
627 +                setcolr(mbclr[i], colval(mbRGB[i],RED),
628 +                                colval(mbRGB[i],GRN), colval(mbRGB[i],BLU));
629 +                if (inpflags & 1L<<i) {
630 +                        cvtcolor(ctmp, inpRGB[i]);
631 +                        setcolr(cvclr[i], colval(ctmp,RED),
632 +                                        colval(ctmp,GRN), colval(ctmp,BLU));
633 +                }
634 +        }
635 +                                                /* allocate scanline */
636 +        scan = (COLR *)malloc(xmax*sizeof(COLR));
637 +        if (scan == NULL) {
638 +                perror(progname);
639 +                exit(1);
640 +        }
641 +                                                /* finish debug header */
642 +        fputformat(COLRFMT, debugfp);
643 +        putc('\n', debugfp);
644 +        fprtresolu(xmax, ymax, debugfp);
645 +                                                /* write debug picture */
646 +        for (y = ymax-1; y >= 0; y--) {
647 +                for (x = 0; x < xmax; x++)
648 +                        if ((i = chartndx(x, y, CENTCVG)) >= 0) {
649 +                                if (!(1L<<i & gmtflags) || (x+y)&07)
650 +                                        copycolr(scan[x], mbclr[i]);
651 +                                else
652 +                                        copycolr(scan[x], blkclr);
653 +                        } else if ((i = chartndx(x, y, FULLCVG)) >= 0 &&
654 +                                        inpflags & 1L<<i)
655 +                                copycolr(scan[x], cvclr[i]);
656 +                        else
657 +                                copycolr(scan[x], blkclr);
658 +                if (fwritecolrs(scan, xmax, debugfp) < 0) {
659 +                        fprintf(stderr, "%s: error writing debugging picture\n",
660 +                                        progname);
661 +                        exit(1);
662 +                }
663 +        }
664 +                                                /* clean up */
665 +        fclose(debugfp);
666          free((char *)scan);
667   }

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines