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

Comparing ray/src/px/ra_tiff.c (file contents):
Revision 2.21 by greg, Tue Jul 1 19:04:08 2003 UTC vs.
Revision 2.24 by greg, Wed Jul 16 01:32:53 2003 UTC

# Line 9 | Line 9 | static const char      RCSid[] = "$Id$";
9  
10   #include  <stdio.h>
11   #include  <math.h>
12 + #include  <ctype.h>
13   #include  <time.h>
14   #include  "tiffio.h"
15   #include  "color.h"
# Line 29 | Line 30 | static const char      RCSid[] = "$Id$";
30  
31   struct {
32          uint16  flags;          /* conversion flags (defined above) */
33 +        char    capdate[20];    /* capture date/time */
34 +        char    owner[256];     /* content owner */
35          uint16  comp;           /* TIFF compression type */
36          uint16  phot;           /* TIFF photometric type */
37          uint16  pconf;          /* TIFF planar configuration */
# Line 55 | Line 58 | struct {
58          } t;                    /* TIFF scanline */
59          void    (*tf)();        /* translation procedure */
60   }       cvts = {        /* conversion structure */
61 <        0, COMPRESSION_NONE, PHOTOMETRIC_RGB,
61 >        0, "", "", COMPRESSION_NONE, PHOTOMETRIC_RGB,
62          PLANARCONFIG_CONTIG, GAMCOR, 0, 1, 1., 1.,
63   };
64  
# Line 86 | Line 89 | short  ortab[8] = {            /* orientation conversion table */
89  
90   #define pixorder()      ortab[cvts.orient-1]
91  
92 + extern char     TMSTR[];        /* "CAPDATE=" from header.c */
93 + char            OWNSTR[] = "OWNER=";
94 +
95   char  *progname;
96  
97  
# Line 209 | Line 215 | allocbufs()                    /* allocate scanline buffers */
215   initfromtif()           /* initialize conversion from TIFF input */
216   {
217          uint16  hi;
218 +        char    *cp;
219          float   *fa, f1, f2;
220  
221          CLR(C_GRY|C_GAMMA|C_PRIM|C_RFLT|C_TFLT|C_TWRD|C_CXFM);
# Line 338 | Line 345 | initfromtif()          /* initialize conversion from TIFF inpu
345  
346          if (!TIFFGetField(cvts.tif, TIFFTAG_STONITS, &cvts.stonits))
347                  cvts.stonits = 1.;
348 +
349 +        if (!TIFFGetField(cvts.tif, TIFFTAG_DATETIME, &cp))
350 +                cvts.capdate[0] = '\0';
351 +        else {
352 +                strncpy(cvts.capdate, cp, 19);
353 +                cvts.capdate[19] = '\0';
354 +        }
355 +        if (!TIFFGetField(cvts.tif, TIFFTAG_ARTIST, &cp))
356 +                cvts.owner[0] = '\0';
357 +        else {
358 +                strncpy(cvts.owner, cp, sizeof(cvts.owner));
359 +                cvts.owner[sizeof(cvts.owner)-1] = '\0';
360 +        }
361                                          /* add to Radiance header */
362          if (cvts.pixrat < .99 || cvts.pixrat > 1.01)
363                  fputaspect(cvts.pixrat, cvts.rfp);
# Line 351 | Line 371 | initfromtif()          /* initialize conversion from TIFF inpu
371                                  cvts.rfp);
372                  fputformat(COLRFMT, cvts.rfp);
373          }
374 +        if (cvts.capdate[0])
375 +                fprintf(cvts.rfp, "%s %s\n", TMSTR, cvts.capdate);
376 +        if (cvts.owner[0])
377 +                fprintf(cvts.rfp, "%s %s\n", OWNSTR, cvts.owner);
378  
379          allocbufs();                    /* allocate scanline buffers */
380   }
# Line 390 | Line 414 | int
414   headline(s)                     /* process Radiance input header line */
415   char    *s;
416   {
417 +        static int      tmstrlen = 0;
418 +        static int      ownstrlen = 0;
419          char    fmt[32];
420  
421 +        if (!tmstrlen)
422 +                tmstrlen = strlen(TMSTR);
423 +        if (!ownstrlen)
424 +                ownstrlen = strlen(OWNSTR);
425          if (formatval(fmt, s)) {
426                  if (!strcmp(fmt, COLRFMT))
427                          CLR(C_XYZE);
# Line 414 | Line 444 | char   *s;
444                  SET(C_PRIM);
445                  return(1);
446          }
447 +        if (isdate(s)) {
448 +                if (s[tmstrlen] == ' ')
449 +                        strncpy(cvts.capdate, s+tmstrlen+1, 19);
450 +                else
451 +                        strncpy(cvts.capdate, s+tmstrlen, 19);
452 +                cvts.capdate[19] = '\0';
453 +                return(1);
454 +        }
455 +        if (!strncmp(s, OWNSTR, ownstrlen)) {
456 +                register char   *cp = s + ownstrlen;
457 +
458 +                while (isspace(*cp))
459 +                        ++cp;
460 +                strncpy(cvts.owner, cp, sizeof(cvts.owner));
461 +                cvts.owner[sizeof(cvts.owner)-1] = '\0';
462 +                for (cp = cvts.owner; *cp; cp++)
463 +                        ;
464 +                while (cp > cvts.owner && isspace(cp[-1]))
465 +                        *--cp = '\0';
466 +                return(1);
467 +        }
468          return(0);
469   }
470  
# Line 423 | Line 474 | initfromrad()                  /* initialize input from a Radiance pi
474          int     i1, i2, po;
475                                                  /* read Radiance header */
476          CLR(C_RFLT|C_XYZE|C_PRIM|C_GAMMA|C_CXFM);
477 +        cvts.capdate[0] = '\0';
478 +        cvts.owner[0] = '\0';
479          cvts.stonits = 1.;
480          cvts.pixrat = 1.;
481          cvts.pconf = PLANARCONFIG_CONTIG;
# Line 489 | Line 542 | initfromrad()                  /* initialize input from a Radiance pi
542                          cvts.tf = Color2RRGGBB;
543                          SET(C_RFLT);
544                  } else if (CHK(C_TFLT)) {
545 +                        TIFFSetField(cvts.tif, TIFFTAG_SAMPLEFORMAT,
546 +                                        SAMPLEFORMAT_IEEEFP);
547                          cvts.tf = Color2RfGfBf;
548                          SET(C_RFLT);
549                  } else
# Line 501 | Line 556 | initfromrad()                  /* initialize input from a Radiance pi
556                          cvts.tf = Color2GGry;
557                          SET(C_RFLT);
558                  } else if (CHK(C_TFLT)) {
559 +                        TIFFSetField(cvts.tif, TIFFTAG_SAMPLEFORMAT,
560 +                                        SAMPLEFORMAT_IEEEFP);
561                          cvts.tf = Color2Gryf;
562                          SET(C_RFLT);
563                  } else
# Line 523 | Line 580 | initfromrad()                  /* initialize input from a Radiance pi
580          TIFFSetField(cvts.tif, TIFFTAG_PLANARCONFIG, cvts.pconf);
581          TIFFSetField(cvts.tif, TIFFTAG_STONITS,
582                          cvts.stonits/pow(2.,(double)cvts.bradj));
583 +        if (cvts.capdate[0])
584 +                TIFFSetField(cvts.tif, TIFFTAG_DATETIME, cvts.capdate);
585 +        if (cvts.owner[0])
586 +                TIFFSetField(cvts.tif, TIFFTAG_ARTIST, cvts.owner);
587          if (cvts.comp == COMPRESSION_NONE)
588                  i1 = TIFFScanlineSize(cvts.tif);
589          else

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines