home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 11 Util / 11-Util.zip / xloadimg.zip / xloadimage.4.1 / tiff / tif_print.c < prev    next >
C/C++ Source or Header  |  1993-10-21  |  17KB  |  572 lines

  1. #ifndef lint
  2. static char rcsid[] = "$Header: /usr/people/sam/tiff/libtiff/RCS/tif_print.c,v 1.43 92/03/17 11:08:58 sam Exp $";
  3. #endif
  4.  
  5. /*
  6.  * Copyright (c) 1988, 1989, 1990, 1991, 1992 Sam Leffler
  7.  * Copyright (c) 1991, 1992 Silicon Graphics, Inc.
  8.  *
  9.  * Permission to use, copy, modify, distribute, and sell this software and 
  10.  * its documentation for any purpose is hereby granted without fee, provided
  11.  * that (i) the above copyright notices and this permission notice appear in
  12.  * all copies of the software and related documentation, and (ii) the names of
  13.  * Sam Leffler and Silicon Graphics may not be used in any advertising or
  14.  * publicity relating to the software without the specific, prior written
  15.  * permission of Sam Leffler and Silicon Graphics.
  16.  * 
  17.  * THE SOFTWARE IS PROVIDED "AS-IS" AND WITHOUT WARRANTY OF ANY KIND, 
  18.  * EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY 
  19.  * WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE.  
  20.  * 
  21.  * IN NO EVENT SHALL SAM LEFFLER OR SILICON GRAPHICS BE LIABLE FOR
  22.  * ANY SPECIAL, INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY KIND,
  23.  * OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
  24.  * WHETHER OR NOT ADVISED OF THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF 
  25.  * LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE 
  26.  * OF THIS SOFTWARE.
  27.  */
  28.  
  29. /*
  30.  * TIFF Library.
  31.  *
  32.  * Directory Printing Support
  33.  */
  34. #include <stdio.h>
  35. #include <string.h>
  36. #include "tiffioP.h"
  37.  
  38. #ifdef JPEG_SUPPORT
  39. static
  40. JPEGPrintQTable(fd, tab)
  41.     FILE *fd;
  42.     u_char tab[64];
  43. {
  44.     int i, j;
  45.     char *sep;
  46.  
  47.     fputc('\n', fd);
  48.     for (i = 0; i < 8; i++) {
  49.         sep = "    ";
  50.         for (j = 0; j < 8; j++) {
  51.             fprintf(fd, "%s%2u", sep, tab[8*i+j]);
  52.             sep = ", ";
  53.         }
  54.         fputc('\n', fd);
  55.     }
  56. }
  57.  
  58. static
  59. JPEGPrintCTable(fd, tab)
  60.     FILE *fd;
  61.     u_char *tab;
  62. {
  63.     int i, n, count;
  64.     char *sep;
  65.  
  66.     fprintf(fd, "\n    Bits:");
  67.     count = 0;
  68.     for (i = 0; i < 16; i++) {
  69.         fprintf(fd, " %u", tab[i]);
  70.         count += tab[i];
  71.     }
  72.     n = 0;
  73.     for (; count > 0; count--) {
  74.         if ((n % 8) == 0) {
  75.             fputc('\n', fd);
  76.             sep = "    ";
  77.         }
  78.         fprintf(fd, "%s0x%02x", sep, tab[i++]);
  79.         sep = ", ";
  80.         n++;
  81.  
  82.     }
  83.     if (n % 8)
  84.         fputc('\n', fd);
  85. }
  86. #endif
  87.  
  88. static const char *photoNames[] = {
  89.     "min-is-white",                /* PHOTOMETRIC_MINISWHITE */
  90.     "min-is-black",                /* PHOTOMETRIC_MINISBLACK */
  91.     "RGB color",                /* PHOTOMETRIC_RGB */
  92.     "palette color (RGB from colormap)",    /* PHOTOMETRIC_PALETTE */
  93.     "transparency mask",            /* PHOTOMETRIC_MASK */
  94.     "separated",                /* PHOTOMETRIC_SEPARATED */
  95.     "YCbCr",                    /* PHOTOMETRIC_YCBCR */
  96.     "7 (0x7)",
  97.     "CIE L*a*b*",                /* PHOTOMETRIC_CIELAB */
  98. };
  99. #define    NPHOTONAMES    (sizeof (photoNames) / sizeof (photoNames[0]))
  100.  
  101. static const char *orientNames[] = {
  102.     "0 (0x0)",
  103.     "row 0 top, col 0 lhs",            /* ORIENTATION_TOPLEFT */
  104.     "row 0 top, col 0 rhs",            /* ORIENTATION_TOPRIGHT */
  105.     "row 0 bottom, col 0 rhs",            /* ORIENTATION_BOTRIGHT */
  106.     "row 0 bottom, col 0 lhs",            /* ORIENTATION_BOTLEFT */
  107.     "row 0 lhs, col 0 top",            /* ORIENTATION_LEFTTOP */
  108.     "row 0 rhs, col 0 top",            /* ORIENTATION_RIGHTTOP */
  109.     "row 0 rhs, col 0 bottom",            /* ORIENTATION_RIGHTBOT */
  110.     "row 0 lhs, col 0 bottom",            /* ORIENTATION_LEFTBOT */
  111. };
  112. #define    NORIENTNAMES    (sizeof (orientNames) / sizeof (orientNames[0]))
  113.  
  114. /*
  115.  * Print the contents of the current directory
  116.  * to the specified stdio file stream.
  117.  */
  118. void
  119. TIFFPrintDirectory(tif, fd, flags)
  120.     TIFF *tif;
  121.     FILE *fd;
  122.     long flags;
  123. {
  124.     register TIFFDirectory *td;
  125.     char *sep;
  126.     int i, j;
  127.     long n;
  128.  
  129.     fprintf(fd, "TIFF Directory at offset 0x%x\n", tif->tif_diroff);
  130.     td = &tif->tif_dir;
  131.     if (TIFFFieldSet(tif,FIELD_SUBFILETYPE)) {
  132.         fprintf(fd, "  Subfile Type:");
  133.         sep = " ";
  134.         if (td->td_subfiletype & FILETYPE_REDUCEDIMAGE) {
  135.             fprintf(fd, "%sreduced-resolution image", sep);
  136.             sep = "/";
  137.         }
  138.         if (td->td_subfiletype & FILETYPE_PAGE) {
  139.             fprintf(fd, "%smulti-page document", sep);
  140.             sep = "/";
  141.         }
  142.         if (td->td_subfiletype & FILETYPE_MASK)
  143.             fprintf(fd, "%stransparency mask", sep);
  144.         fprintf(fd, " (%u = 0x%x)\n",
  145.             td->td_subfiletype, td->td_subfiletype);
  146.     }
  147.     if (TIFFFieldSet(tif,FIELD_IMAGEDIMENSIONS)) {
  148.         fprintf(fd, "  Image Width: %lu Image Length: %lu",
  149.             td->td_imagewidth, td->td_imagelength);
  150.         if (TIFFFieldSet(tif,FIELD_IMAGEDEPTH))
  151.             fprintf(fd, " Image Depth: %lu", td->td_imagedepth);
  152.         fprintf(fd, "\n");
  153.     }
  154.     if (TIFFFieldSet(tif,FIELD_TILEDIMENSIONS)) {
  155.         fprintf(fd, "  Tile Width: %lu Tile Length: %lu",
  156.             td->td_tilewidth, td->td_tilelength);
  157.         if (TIFFFieldSet(tif,FIELD_TILEDEPTH))
  158.             fprintf(fd, " Tile Depth: %lu", td->td_tiledepth);
  159.         fprintf(fd, "\n");
  160.     }
  161.     if (TIFFFieldSet(tif,FIELD_RESOLUTION)) {
  162.         fprintf(fd, "  Resolution: %g, %g",
  163.             td->td_xresolution, td->td_yresolution);
  164.         if (TIFFFieldSet(tif,FIELD_RESOLUTIONUNIT)) {
  165.             switch (td->td_resolutionunit) {
  166.             case RESUNIT_NONE:
  167.                 fprintf(fd, " (unitless)");
  168.                 break;
  169.             case RESUNIT_INCH:
  170.                 fprintf(fd, " pixels/inch");
  171.                 break;
  172.             case RESUNIT_CENTIMETER:
  173.                 fprintf(fd, " pixels/cm");
  174.                 break;
  175.             default:
  176.                 fprintf(fd, " (unit %u = 0x%x)",
  177.                     td->td_resolutionunit,
  178.                     td->td_resolutionunit);
  179.                 break;
  180.             }
  181.         }
  182.         fprintf(fd, "\n");
  183.     }
  184.     if (TIFFFieldSet(tif,FIELD_POSITION))
  185.         fprintf(fd, "  Position: %g, %g\n",
  186.             td->td_xposition, td->td_yposition);
  187.     if (TIFFFieldSet(tif,FIELD_BITSPERSAMPLE))
  188.         fprintf(fd, "  Bits/Sample: %u\n", td->td_bitspersample);
  189.     if (TIFFFieldSet(tif,FIELD_SAMPLEFORMAT)) {
  190.         fprintf(fd, "  Sample Format: ");
  191.         switch (td->td_sampleformat) {
  192.         case SAMPLEFORMAT_VOID:
  193.             fprintf(fd, "void\n");
  194.             break;
  195.         case SAMPLEFORMAT_INT:
  196.             fprintf(fd, "signed integer\n");
  197.             break;
  198.         case SAMPLEFORMAT_UINT:
  199.             fprintf(fd, "unsigned integer\n");
  200.             break;
  201.         case SAMPLEFORMAT_IEEEFP:
  202.             fprintf(fd, "IEEE floating point\n");
  203.             break;
  204.         default:
  205.             fprintf(fd, "%u (0x%x)\n",
  206.                 td->td_sampleformat, td->td_sampleformat);
  207.             break;
  208.         }
  209.     }
  210.     if (TIFFFieldSet(tif,FIELD_COMPRESSION)) {
  211.         fprintf(fd, "  Compression Scheme: ");
  212.         switch (td->td_compression) {
  213.         case COMPRESSION_NONE:
  214.             fprintf(fd, "none\n");
  215.             break;
  216.         case COMPRESSION_CCITTRLE:
  217.             fprintf(fd, "CCITT modified Huffman encoding\n");
  218.             break;
  219.         case COMPRESSION_CCITTFAX3:
  220.             fprintf(fd, "CCITT Group 3 facsimile encoding\n");
  221.             break;
  222.         case COMPRESSION_CCITTFAX4:
  223.             fprintf(fd, "CCITT Group 4 facsimile encoding\n");
  224.             break;
  225.         case COMPRESSION_CCITTRLEW:
  226.             fprintf(fd, "CCITT modified Huffman encoding %s\n",
  227.                 "w/ word alignment");
  228.             break;
  229.         case COMPRESSION_PACKBITS:
  230.             fprintf(fd, "Macintosh PackBits encoding\n");
  231.             break;
  232.         case COMPRESSION_THUNDERSCAN:
  233.             fprintf(fd, "ThunderScan 4-bit encoding\n");
  234.             break;
  235.         case COMPRESSION_LZW:
  236.             fprintf(fd, "Lempel-Ziv & Welch encoding\n");
  237.             break;
  238.         case COMPRESSION_NEXT:
  239.             fprintf(fd, "NeXT 2-bit encoding\n");
  240.             break;
  241.         case COMPRESSION_JPEG:
  242.             fprintf(fd, "JPEG encoding\n");
  243.             break;
  244.         default:
  245.             fprintf(fd, "%u (0x%x)\n",
  246.                 td->td_compression, td->td_compression);
  247.             break;
  248.         }
  249.     }
  250.     if (TIFFFieldSet(tif,FIELD_PHOTOMETRIC)) {
  251.         fprintf(fd, "  Photometric Interpretation: ");
  252.         if (td->td_photometric < NPHOTONAMES)
  253.             fprintf(fd, "%s\n", photoNames[td->td_photometric]);
  254.         else
  255.             fprintf(fd, "%u (0x%x)\n",
  256.                 td->td_photometric, td->td_photometric);
  257.     }
  258.     if (TIFFFieldSet(tif,FIELD_MATTEING))
  259.         fprintf(fd, "  Matteing: %s\n", td->td_matteing ?
  260.             "pre-multiplied with alpha channel" : "none");
  261. #ifdef CMYK_SUPPORT
  262.     if (TIFFFieldSet(tif,FIELD_INKSET)) {
  263.         fprintf(fd, "  Ink Set: ");
  264.         switch (td->td_inkset) {
  265.         case INKSET_CMYK:
  266.             fprintf(fd, "CMYK\n");
  267.             break;
  268.         default:
  269.             fprintf(fd, "%u (0x%x)\n",
  270.                 td->td_inkset, td->td_inkset);
  271.             break;
  272.         }
  273.     }
  274.     if (TIFFFieldSet(tif,FIELD_INKNAMES)) {
  275.         char *cp;
  276.         fprintf(fd, "  Ink Names: ");
  277.         i = td->td_samplesperpixel;
  278.         sep = "";
  279.         for (cp = td->td_inknames; i > 0; cp = strchr(cp, '\0')) {
  280.             fprintf(fd, "%s%s", sep, cp);
  281.             sep = ", ";
  282.         }
  283.     }
  284.     if (TIFFFieldSet(tif,FIELD_DOTRANGE))
  285.         fprintf(fd, "  Dot Range: %u-%u\n",
  286.             td->td_dotrange[0], td->td_dotrange[1]);
  287.     if (TIFFFieldSet(tif,FIELD_TARGETPRINTER))
  288.         fprintf(fd, "  Target Printer: %s\n", td->td_targetprinter);
  289. #endif
  290.     if (TIFFFieldSet(tif,FIELD_THRESHHOLDING)) {
  291.         fprintf(fd, "  Thresholding: ");
  292.         switch (td->td_threshholding) {
  293.         case THRESHHOLD_BILEVEL:
  294.             fprintf(fd, "bilevel art scan\n");
  295.             break;
  296.         case THRESHHOLD_HALFTONE:
  297.             fprintf(fd, "halftone or dithered scan\n");
  298.             break;
  299.         case THRESHHOLD_ERRORDIFFUSE:
  300.             fprintf(fd, "error diffused\n");
  301.             break;
  302.         default:
  303.             fprintf(fd, "%u (0x%x)\n",
  304.                 td->td_threshholding, td->td_threshholding);
  305.             break;
  306.         }
  307.     }
  308.     if (TIFFFieldSet(tif,FIELD_FILLORDER)) {
  309.         fprintf(fd, "  FillOrder: ");
  310.         switch (td->td_fillorder) {
  311.         case FILLORDER_MSB2LSB:
  312.             fprintf(fd, "msb-to-lsb\n");
  313.             break;
  314.         case FILLORDER_LSB2MSB:
  315.             fprintf(fd, "lsb-to-msb\n");
  316.             break;
  317.         default:
  318.             fprintf(fd, "%u (0x%x)\n",
  319.                 td->td_fillorder, td->td_fillorder);
  320.             break;
  321.         }
  322.     }
  323.     if (TIFFFieldSet(tif,FIELD_PREDICTOR)) {
  324.         fprintf(fd, "  Predictor: ");
  325.         switch (td->td_predictor) {
  326.         case 1:
  327.             fprintf(fd, "none\n");
  328.             break;
  329.         case 2:
  330.             fprintf(fd, "horizontal differencing\n");
  331.             break;
  332.         default:
  333.             fprintf(fd, "%u (0x%x)\n",
  334.                 td->td_predictor, td->td_predictor);
  335.             break;
  336.         }
  337.     }
  338. #ifdef YCBCR_SUPPORT
  339.     if (TIFFFieldSet(tif,FIELD_YCBCRSUBSAMPLING))
  340.         fprintf(fd, "  YCbCr Subsampling: %u, %u\n",
  341.             td->td_ycbcrsubsampling[0], td->td_ycbcrsubsampling[1]);
  342.     if (TIFFFieldSet(tif,FIELD_YCBCRPOSITIONING)) {
  343.         fprintf(fd, "  YCbCr Positioning: ");
  344.         switch (td->td_ycbcrpositioning) {
  345.         case YCBCRPOSITION_CENTERED:
  346.             fprintf(fd, "centered\n");
  347.             break;
  348.         case YCBCRPOSITION_COSITED:
  349.             fprintf(fd, "cosited\n");
  350.             break;
  351.         default:
  352.             fprintf(fd, "%u (0x%x)\n",
  353.                 td->td_ycbcrpositioning, td->td_ycbcrpositioning);
  354.             break;
  355.         }
  356.     }
  357.     if (TIFFFieldSet(tif,FIELD_YCBCRCOEFFICIENTS))
  358.         fprintf(fd, "  YCbCr Coefficients: %g, %g, %g\n",
  359.             td->td_ycbcrcoeffs[0],
  360.             td->td_ycbcrcoeffs[1],
  361.             td->td_ycbcrcoeffs[2]);
  362. #endif
  363. #ifdef JPEG_SUPPORT
  364.     if (TIFFFieldSet(tif,FIELD_JPEGPROC)) {
  365.         fprintf(fd, "  JPEG Processing Mode: ");
  366.         switch (td->td_jpegproc) {
  367.         case JPEGPROC_BASELINE:
  368.             fprintf(fd, "baseline sequential algorithm\n");
  369.             break;
  370.         case JPEGPROC_LOSSLESS:
  371.             fprintf(fd, "lossless algorithm with Huffman coding\n");
  372.             break;
  373.         default:
  374.             fprintf(fd, "%u (0x%x)\n",
  375.                 td->td_jpegproc, td->td_jpegproc);
  376.             break;
  377.         }
  378.     }
  379.     if (TIFFFieldSet(tif,FIELD_JPEGRESTARTINTERVAL)) {
  380.         fprintf(fd, "  JPEG Restart Interval: ");
  381.         if (td->td_jpegrestartinterval)
  382.             fprintf(fd, "%u\n", td->td_jpegrestartinterval);
  383.         else
  384.             fprintf(fd, "(no restart markers)\n");
  385.     }
  386.     if (TIFFFieldSet(tif,FIELD_JPEGQTABLES)) {
  387.         fprintf(fd, "  JPEG Quantization Tables: ");
  388.         if (flags & TIFFPRINT_JPEGQTABLES) {
  389.             for (i = 0; i < td->td_samplesperpixel; i++)
  390.                 JPEGPrintQTable(fd, td->td_qtab[i]);
  391.         } else
  392.             fprintf(fd, "(present)\n");
  393.     }
  394.     if (TIFFFieldSet(tif,FIELD_JPEGDCTABLES)) {
  395.         fprintf(fd, "  JPEG DC Tables: ");
  396.         if (flags & TIFFPRINT_JPEGDCTABLES) {
  397.             for (i = 0; i < td->td_samplesperpixel; i++)
  398.                 JPEGPrintCTable(fd, td->td_dctab[i]);
  399.         } else
  400.             fprintf(fd, "(present)\n");
  401.     }
  402.     if (TIFFFieldSet(tif,FIELD_JPEGACTABLES)) {
  403.         fprintf(fd, "  JPEG AC Tables: ");
  404.         if (flags & TIFFPRINT_JPEGACTABLES) {
  405.             for (i = 0; i < td->td_samplesperpixel; i++)
  406.                 JPEGPrintCTable(fd, td->td_actab[i]);
  407.         } else
  408.             fprintf(fd, "(present)\n");
  409.     }
  410. #endif
  411.     if (TIFFFieldSet(tif,FIELD_HALFTONEHINTS))
  412.         fprintf(fd, "  Halftone Hints: light %u dark %u\n",
  413.             td->td_halftonehints[0], td->td_halftonehints[1]);
  414.     if (TIFFFieldSet(tif,FIELD_ARTIST))
  415.         fprintf(fd, "  Artist: \"%s\"\n", td->td_artist);
  416.     if (TIFFFieldSet(tif,FIELD_DATETIME))
  417.         fprintf(fd, "  Date & Time: \"%s\"\n", td->td_datetime);
  418.     if (TIFFFieldSet(tif,FIELD_HOSTCOMPUTER))
  419.         fprintf(fd, "  Host Computer: \"%s\"\n", td->td_hostcomputer);
  420.     if (TIFFFieldSet(tif,FIELD_SOFTWARE))
  421.         fprintf(fd, "  Software: \"%s\"\n", td->td_software);
  422.     if (TIFFFieldSet(tif,FIELD_DOCUMENTNAME))
  423.         fprintf(fd, "  Document Name: \"%s\"\n", td->td_documentname);
  424.     if (TIFFFieldSet(tif,FIELD_IMAGEDESCRIPTION))
  425.         fprintf(fd, "  Image Description: \"%s\"\n",
  426.             td->td_imagedescription);
  427.     if (TIFFFieldSet(tif,FIELD_MAKE))
  428.         fprintf(fd, "  Make: \"%s\"\n", td->td_make);
  429.     if (TIFFFieldSet(tif,FIELD_MODEL))
  430.         fprintf(fd, "  Model: \"%s\"\n", td->td_model);
  431.     if (TIFFFieldSet(tif,FIELD_ORIENTATION)) {
  432.         fprintf(fd, "  Orientation: ");
  433.         if (td->td_orientation < NORIENTNAMES)
  434.             fprintf(fd, "%s\n", orientNames[td->td_orientation]);
  435.         else
  436.             fprintf(fd, "%u (0x%x)\n",
  437.                 td->td_orientation, td->td_orientation);
  438.     }
  439.     if (TIFFFieldSet(tif,FIELD_SAMPLESPERPIXEL))
  440.         fprintf(fd, "  Samples/Pixel: %u\n", td->td_samplesperpixel);
  441.     if (TIFFFieldSet(tif,FIELD_ROWSPERSTRIP)) {
  442.         fprintf(fd, "  Rows/Strip: ");
  443.         if (td->td_rowsperstrip == 0xffffffffL)
  444.             fprintf(fd, "(infinite)\n");
  445.         else
  446.             fprintf(fd, "%u\n", td->td_rowsperstrip);
  447.     }
  448.     if (TIFFFieldSet(tif,FIELD_MINSAMPLEVALUE))
  449.         fprintf(fd, "  Min Sample Value: %u\n", td->td_minsamplevalue);
  450.     if (TIFFFieldSet(tif,FIELD_MAXSAMPLEVALUE))
  451.         fprintf(fd, "  Max Sample Value: %u\n", td->td_maxsamplevalue);
  452.     if (TIFFFieldSet(tif,FIELD_PLANARCONFIG)) {
  453.         fprintf(fd, "  Planar Configuration: ");
  454.         switch (td->td_planarconfig) {
  455.         case PLANARCONFIG_CONTIG:
  456.             fprintf(fd, "single image plane\n");
  457.             break;
  458.         case PLANARCONFIG_SEPARATE:
  459.             fprintf(fd, "separate image planes\n");
  460.             break;
  461.         default:
  462.             fprintf(fd, "%u (0x%x)\n",
  463.                 td->td_planarconfig, td->td_planarconfig);
  464.             break;
  465.         }
  466.     }
  467.     if (TIFFFieldSet(tif,FIELD_PAGENAME))
  468.         fprintf(fd, "  Page Name: \"%s\"\n", td->td_pagename);
  469.     if (TIFFFieldSet(tif,FIELD_GROUP3OPTIONS)) {
  470.         fprintf(fd, "  Group 3 Options:");
  471.         sep = " ";
  472.         if (td->td_group3options & GROUP3OPT_2DENCODING)
  473.             fprintf(fd, "%s2-d encoding", sep), sep = "+";
  474.         if (td->td_group3options & GROUP3OPT_FILLBITS)
  475.             fprintf(fd, "%sEOL padding", sep), sep = "+";
  476.         if (td->td_group3options & GROUP3OPT_UNCOMPRESSED)
  477.             fprintf(fd, "%suncompressed data", sep);
  478.         fprintf(fd, " (%u = 0x%x)\n",
  479.             td->td_group3options, td->td_group3options);
  480.     }
  481.     if (TIFFFieldSet(tif,FIELD_CLEANFAXDATA)) {
  482.         fprintf(fd, "  Fax Data: ");
  483.         switch (td->td_cleanfaxdata) {
  484.         case CLEANFAXDATA_CLEAN:
  485.             fprintf(fd, "clean\n");
  486.             break;
  487.         case CLEANFAXDATA_REGENERATED:
  488.             fprintf(fd, "receiver regenerated\n");
  489.             break;
  490.         case CLEANFAXDATA_UNCLEAN:
  491.             fprintf(fd, "uncorrected errors\n");
  492.             break;
  493.         default:
  494.             fprintf(fd, "(%u = 0x%x)\n",
  495.                 td->td_cleanfaxdata, td->td_cleanfaxdata);
  496.             break;
  497.         }
  498.     }
  499.     if (TIFFFieldSet(tif,FIELD_BADFAXLINES))
  500.         fprintf(fd, "  Bad Fax Lines: %u\n", td->td_badfaxlines);
  501.     if (TIFFFieldSet(tif,FIELD_BADFAXRUN))
  502.         fprintf(fd, "  Consecutive Bad Fax Lines: %u\n",
  503.             td->td_badfaxrun);
  504.     if (TIFFFieldSet(tif,FIELD_GROUP4OPTIONS)) {
  505.         fprintf(fd, "  Group 4 Options:");
  506.         if (td->td_group4options & GROUP4OPT_UNCOMPRESSED)
  507.             fprintf(fd, "uncompressed data");
  508.         fprintf(fd, " (%u = 0x%x)\n",
  509.             td->td_group4options, td->td_group4options);
  510.     }
  511.     if (TIFFFieldSet(tif,FIELD_PAGENUMBER))
  512.         fprintf(fd, "  Page Number: %u-%u\n",
  513.             td->td_pagenumber[0], td->td_pagenumber[1]);
  514.     if (TIFFFieldSet(tif,FIELD_COLORMAP)) {
  515.         fprintf(fd, "  Color Map: ");
  516.         if (flags & TIFFPRINT_COLORMAP) {
  517.             fprintf(fd, "\n");
  518.             n = 1L<<td->td_bitspersample;
  519.             for (i = 0; i < n; i++)
  520.                 fprintf(fd, "   %5d: %5u %5u %5u\n",
  521.                     i,
  522.                     td->td_colormap[0][i],
  523.                     td->td_colormap[1][i],
  524.                     td->td_colormap[2][i]);
  525.         } else
  526.             fprintf(fd, "(present)\n");
  527.     }
  528. #ifdef COLORIMETRY_SUPPORT
  529.     if (TIFFFieldSet(tif,FIELD_WHITEPOINT))
  530.         fprintf(fd, "  White Point: %g-%g\n",
  531.             td->td_whitepoint[0], td->td_whitepoint[1]);
  532.     if (TIFFFieldSet(tif,FIELD_PRIMARYCHROMAS))
  533.         fprintf(fd, "  Primary Chromaticities: %g,%g %g,%g %g,%g\n",
  534.             td->td_primarychromas[0], td->td_primarychromas[1],
  535.             td->td_primarychromas[2], td->td_primarychromas[3],
  536.             td->td_primarychromas[4], td->td_primarychromas[5]);
  537.     if (TIFFFieldSet(tif,FIELD_REFBLACKWHITE)) {
  538.         fprintf(fd, "  Reference Black/White:\n");
  539.         for (i = 0; i < td->td_samplesperpixel; i++)
  540.             fprintf(fd, "    %2d: %5g %5g\n",
  541.                 i,
  542.                 td->td_refblackwhite[2*i+0],
  543.                 td->td_refblackwhite[2*i+1]);
  544.     }
  545.     if (TIFFFieldSet(tif,FIELD_TRANSFERFUNCTION)) {
  546.         fprintf(fd, "  Transfer Function: ");
  547.         if (flags & TIFFPRINT_CURVES) {
  548.             fprintf(fd, "\n");
  549.             n = 1L<<td->td_bitspersample;
  550.             for (i = 0; i < n; i++) {
  551.                 fprintf(fd, "    %2d: %5u",
  552.                     i, td->td_transferfunction[0][i]);
  553.                 for (j = 1; j < td->td_samplesperpixel; j++)
  554.                     fprintf(fd, " %5u",
  555.                         td->td_transferfunction[j][i]);
  556.                 putc('\n', fd);
  557.             }
  558.         } else
  559.             fprintf(fd, "(present)\n");
  560.     }
  561. #endif
  562.     if ((flags & TIFFPRINT_STRIPS) &&
  563.         TIFFFieldSet(tif,FIELD_STRIPOFFSETS)) {
  564.         fprintf(fd, "  %u %s:\n",
  565.             td->td_nstrips,
  566.             isTiled(tif) ? "Tiles" : "Strips");
  567.         for (i = 0; i < td->td_nstrips; i++)
  568.             fprintf(fd, "    %3d: [%8u, %8u]\n",
  569.                 i, td->td_stripoffset[i], td->td_stripbytecount[i]);
  570.     }
  571. }
  572.