home *** CD-ROM | disk | FTP | other *** search
/ rtsi.com / 2014.01.www.rtsi.com.tar / www.rtsi.com / OS9 / OSK / NETWORK / netpbm_src.lzh / NETPBM / LIBTIFF / tif_print.c < prev    next >
Text File  |  1996-11-18  |  18KB  |  591 lines

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