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

Comparing ray/src/px/pvalue.c (file contents):
Revision 2.36 by greg, Mon Jul 15 23:42:44 2019 UTC vs.
Revision 2.39 by greg, Mon Mar 30 19:02:26 2020 UTC

# Line 173 | Line 173 | main(
173                                  }
174                                  break;
175                          case 'd':               /* data only (no indices) */
176 <                                dataonly = argv[i][0] == '-';
176 >                                dataonly = (argv[i][0] == '-');
177                                  switch (argv[i][2]) {
178                                  case '\0':
179                                  case 'a':               /* ascii */
# Line 312 | Line 312 | unkopt:
312                  SET_FILE_BINARY(stdout);
313                                          /* get header */
314                  if (header) {
315 <                        if (checkheader(fin, fmtid, stdout) < 0) {
316 <                                fprintf(stderr, "%s: wrong input format\n",
317 <                                                progname);
315 >                        getheader(fin, checkhead, stdout);
316 >                        if (wrongformat) {
317 >                                fprintf(stderr, "%s: wrong input format (expected %s)\n",
318 >                                                progname, fmtid);
319                                  quit(1);
320                          }
321                          if (fin2 != NULL) {
# Line 361 | Line 362 | unkopt:
362                  if ((format != 'a') & (format != 'i'))
363                          SET_FILE_BINARY(stdout);
364                                                  /* get header */
365 <                getheader(fin, checkhead, NULL);
365 >                getheader(fin, checkhead, header ? stdout : (FILE *)NULL);
366                  if (wrongformat) {
367                          fprintf(stderr,
368                                  "%s: input not a Radiance RGBE picture\n",
# Line 374 | Line 375 | unkopt:
375                  }
376                  if (header) {
377                          printargs(i, argv, stdout);
378 +                        printf("NCOMP=%d\n", putprim==ALL ? 3 : 1);
379 +                        if (!resolution && dataonly && !uniq)
380 +                                printf("NCOLS=%d\nNROWS=%d\n", scanlen(&picres),
381 +                                                numscans(&picres));
382                          if (expval < .99 || expval > 1.01)
383                                  fputexpos(expval, stdout);
384 +                        if (swapbytes) {
385 +                                if (nativebigendian())
386 +                                        puts("BigEndian=0");
387 +                                else
388 +                                        puts("BigEndian=1");
389 +                        } else if ((format != 'a') & (format != 'i'))
390 +                                fputendian(stdout);
391                          fputformat(fmtid, stdout);
392                          putchar('\n');
393                  }
# Line 395 | Line 407 | checkhead(                             /* deal with line from header */
407          void    *p
408   )
409   {
410 +        FILE    *fout = (FILE *)p;
411          char    fmt[MAXFMTLEN];
412          double  d;
413          COLOR   ctmp;
414 +        int     rv;
415  
416          if (formatval(fmt, line)) {
417 <                if (!strcmp(fmt, CIEFMT))
417 >                if (reverse)
418 >                        wrongformat = strcmp(fmt, fmtid);
419 >                else if (!strcmp(fmt, CIEFMT))
420                          mybright = &xyz_bright;
421                  else if (!strcmp(fmt, COLRFMT))
422                          mybright = &rgb_bright;
423                  else
424                          wrongformat++;
425 <        } else if (original && isexpos(line)) {
425 >                return(1);
426 >        }
427 >        if (original && isexpos(line)) {
428                  d = 1.0/exposval(line);
429                  scalecolor(exposure, d);
430                  doexposure++;
431 <        } else if (original && iscolcor(line)) {
431 >                return(1);
432 >        }
433 >        if (original && iscolcor(line)) {
434                  colcorval(ctmp, line);
435                  setcolor(exposure, colval(exposure,RED)/colval(ctmp,RED),
436                                  colval(exposure,GRN)/colval(ctmp,GRN),
437                                  colval(exposure,BLU)/colval(ctmp,BLU));
438                  doexposure++;
439 <        } else if (header)
440 <                fputs(line, stdout);
439 >                return(1);
440 >        }
441 >        if ((rv = isbigendian(line)) >= 0) {
442 >                if (reverse)
443 >                        swapbytes = (nativebigendian() != rv);
444 >                return(1);
445 >        }
446 >        if (fout != NULL)
447 >                fputs(line, fout);
448          return(0);
449   }
450  

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines