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.22 by greg, Tue Jul 1 22:44:02 2003 UTC

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

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines