LTP GCOV extension - code coverage report
Current view: directory - frmts/gtiff/libtiff - tif_print.c
Test: gdal_filtered.info
Date: 2010-07-12 Instrumented lines: 309
Code covered: 0.0 % Executed lines: 0

       1                 : /* $Id: tif_print.c,v 1.50 2010-05-06 02:56:17 olivier Exp $ */
       2                 : 
       3                 : /*
       4                 :  * Copyright (c) 1988-1997 Sam Leffler
       5                 :  * Copyright (c) 1991-1997 Silicon Graphics, Inc.
       6                 :  *
       7                 :  * Permission to use, copy, modify, distribute, and sell this software and 
       8                 :  * its documentation for any purpose is hereby granted without fee, provided
       9                 :  * that (i) the above copyright notices and this permission notice appear in
      10                 :  * all copies of the software and related documentation, and (ii) the names of
      11                 :  * Sam Leffler and Silicon Graphics may not be used in any advertising or
      12                 :  * publicity relating to the software without the specific, prior written
      13                 :  * permission of Sam Leffler and Silicon Graphics.
      14                 :  * 
      15                 :  * THE SOFTWARE IS PROVIDED "AS-IS" AND WITHOUT WARRANTY OF ANY KIND, 
      16                 :  * EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY 
      17                 :  * WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE.  
      18                 :  * 
      19                 :  * IN NO EVENT SHALL SAM LEFFLER OR SILICON GRAPHICS BE LIABLE FOR
      20                 :  * ANY SPECIAL, INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY KIND,
      21                 :  * OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
      22                 :  * WHETHER OR NOT ADVISED OF THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF 
      23                 :  * LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE 
      24                 :  * OF THIS SOFTWARE.
      25                 :  */
      26                 : 
      27                 : /*
      28                 :  * TIFF Library.
      29                 :  *
      30                 :  * Directory Printing Support
      31                 :  */
      32                 : #include "tiffiop.h"
      33                 : #include <stdio.h>
      34                 : 
      35                 : #include <ctype.h>
      36                 : 
      37                 : static const char *photoNames[] = {
      38                 :     "min-is-white",       /* PHOTOMETRIC_MINISWHITE */
      39                 :     "min-is-black",       /* PHOTOMETRIC_MINISBLACK */
      40                 :     "RGB color",        /* PHOTOMETRIC_RGB */
      41                 :     "palette color (RGB from colormap)",  /* PHOTOMETRIC_PALETTE */
      42                 :     "transparency mask",      /* PHOTOMETRIC_MASK */
      43                 :     "separated",        /* PHOTOMETRIC_SEPARATED */
      44                 :     "YCbCr",          /* PHOTOMETRIC_YCBCR */
      45                 :     "7 (0x7)",
      46                 :     "CIE L*a*b*",       /* PHOTOMETRIC_CIELAB */
      47                 : };
      48                 : #define NPHOTONAMES (sizeof (photoNames) / sizeof (photoNames[0]))
      49                 : 
      50                 : static const char *orientNames[] = {
      51                 :     "0 (0x0)",
      52                 :     "row 0 top, col 0 lhs",     /* ORIENTATION_TOPLEFT */
      53                 :     "row 0 top, col 0 rhs",     /* ORIENTATION_TOPRIGHT */
      54                 :     "row 0 bottom, col 0 rhs",      /* ORIENTATION_BOTRIGHT */
      55                 :     "row 0 bottom, col 0 lhs",      /* ORIENTATION_BOTLEFT */
      56                 :     "row 0 lhs, col 0 top",     /* ORIENTATION_LEFTTOP */
      57                 :     "row 0 rhs, col 0 top",     /* ORIENTATION_RIGHTTOP */
      58                 :     "row 0 rhs, col 0 bottom",      /* ORIENTATION_RIGHTBOT */
      59                 :     "row 0 lhs, col 0 bottom",      /* ORIENTATION_LEFTBOT */
      60                 : };
      61                 : #define NORIENTNAMES  (sizeof (orientNames) / sizeof (orientNames[0]))
      62                 : 
      63                 : static void
      64                 : _TIFFPrintField(FILE* fd, const TIFFField *fip,
      65                 :     uint32 value_count, void *raw_data)
      66               0 : {
      67                 :   uint32 j;
      68                 :     
      69               0 :   fprintf(fd, "  %s: ", fip->field_name);
      70                 : 
      71               0 :   for(j = 0; j < value_count; j++) {
      72               0 :     if(fip->field_type == TIFF_BYTE)
      73               0 :       fprintf(fd, "%u", ((uint8 *) raw_data)[j]);
      74               0 :     else if(fip->field_type == TIFF_UNDEFINED)
      75               0 :       fprintf(fd, "0x%x",
      76                 :           (unsigned int) ((unsigned char *) raw_data)[j]);
      77               0 :     else if(fip->field_type == TIFF_SBYTE)
      78               0 :       fprintf(fd, "%d", ((int8 *) raw_data)[j]);
      79               0 :     else if(fip->field_type == TIFF_SHORT)
      80               0 :       fprintf(fd, "%u", ((uint16 *) raw_data)[j]);
      81               0 :     else if(fip->field_type == TIFF_SSHORT)
      82               0 :       fprintf(fd, "%d", ((int16 *) raw_data)[j]);
      83               0 :     else if(fip->field_type == TIFF_LONG)
      84               0 :       fprintf(fd, "%lu",
      85                 :           (unsigned long)((uint32 *) raw_data)[j]);
      86               0 :     else if(fip->field_type == TIFF_SLONG)
      87               0 :       fprintf(fd, "%ld", (long)((int32 *) raw_data)[j]);
      88               0 :     else if(fip->field_type == TIFF_IFD)
      89               0 :       fprintf(fd, "0x%lx",
      90                 :         (unsigned long)((uint32 *) raw_data)[j]);
      91               0 :     else if(fip->field_type == TIFF_RATIONAL
      92                 :       || fip->field_type == TIFF_SRATIONAL
      93                 :       || fip->field_type == TIFF_FLOAT)
      94               0 :       fprintf(fd, "%f", ((float *) raw_data)[j]);
      95               0 :     else if(fip->field_type == TIFF_LONG8)
      96                 : #if defined(__WIN32__) && defined(_MSC_VER)
      97                 :       fprintf(fd, "%I64u",
      98                 :           (unsigned __int64)((uint64 *) raw_data)[j]);
      99                 : #else
     100               0 :       fprintf(fd, "%llu",
     101                 :           (unsigned long long)((uint64 *) raw_data)[j]);
     102                 : #endif
     103               0 :     else if(fip->field_type == TIFF_SLONG8)
     104                 : #if defined(__WIN32__) && defined(_MSC_VER)
     105                 :       fprintf(fd, "%I64d", (__int64)((int64 *) raw_data)[j]);
     106                 : #else
     107               0 :       fprintf(fd, "%lld", (long long)((int64 *) raw_data)[j]);
     108                 : #endif
     109               0 :     else if(fip->field_type == TIFF_IFD8)
     110                 : #if defined(__WIN32__) && defined(_MSC_VER)
     111                 :       fprintf(fd, "0x%I64x",
     112                 :         (unsigned __int64)((uint64 *) raw_data)[j]);
     113                 : #else
     114               0 :       fprintf(fd, "0x%llx",
     115                 :         (unsigned long long)((uint64 *) raw_data)[j]);
     116                 : #endif
     117               0 :     else if(fip->field_type == TIFF_FLOAT)
     118               0 :       fprintf(fd, "%f", ((float *)raw_data)[j]);
     119               0 :     else if(fip->field_type == TIFF_DOUBLE)
     120               0 :       fprintf(fd, "%f", ((double *) raw_data)[j]);
     121               0 :     else if(fip->field_type == TIFF_ASCII) {
     122               0 :       fprintf(fd, "%s", (char *) raw_data);
     123               0 :       break;
     124                 :     }
     125                 :     else {
     126               0 :       fprintf(fd, "<unsupported data type in TIFFPrint>");
     127               0 :       break;
     128                 :     }
     129                 : 
     130               0 :     if(j < value_count - 1)
     131               0 :       fprintf(fd, ",");
     132                 :   }
     133                 : 
     134               0 :   fprintf(fd, "\n");
     135               0 : }
     136                 : 
     137                 : static int
     138                 : _TIFFPrettyPrintField(TIFF* tif, FILE* fd, uint32 tag,
     139                 :           uint32 value_count, void *raw_data)
     140               0 : {
     141               0 :   TIFFDirectory *td = &tif->tif_dir;
     142                 : 
     143               0 :   switch (tag)
     144                 :   {
     145                 :     case TIFFTAG_INKSET:
     146               0 :       fprintf(fd, "  Ink Set: ");
     147               0 :       switch (*((uint16*)raw_data)) {
     148                 :         case INKSET_CMYK:
     149               0 :           fprintf(fd, "CMYK\n");
     150               0 :           break;
     151                 :         default:
     152               0 :           fprintf(fd, "%u (0x%x)\n",
     153                 :               *((uint16*)raw_data),
     154                 :               *((uint16*)raw_data));
     155                 :           break;
     156                 :       }
     157               0 :       return 1;
     158                 :     case TIFFTAG_DOTRANGE:
     159               0 :       fprintf(fd, "  Dot Range: %u-%u\n",
     160                 :           ((uint16*)raw_data)[0], ((uint16*)raw_data)[1]);
     161               0 :       return 1;
     162                 :     case TIFFTAG_WHITEPOINT:
     163               0 :       fprintf(fd, "  White Point: %g-%g\n",
     164                 :           ((float *)raw_data)[0], ((float *)raw_data)[1]);
     165               0 :       return 1;
     166                 :     case TIFFTAG_XMLPACKET:
     167                 :     {
     168                 :       uint32 i;
     169                 : 
     170               0 :       fprintf(fd, "  XMLPacket (XMP Metadata):\n" );
     171               0 :       for(i = 0; i < value_count; i++)
     172               0 :         fputc(((char *)raw_data)[i], fd);
     173               0 :       fprintf( fd, "\n" );
     174               0 :       return 1;
     175                 :     }
     176                 :     case TIFFTAG_RICHTIFFIPTC:
     177                 :       /*
     178                 :        * XXX: for some weird reason RichTIFFIPTC tag
     179                 :        * defined as array of LONG values.
     180                 :        */
     181               0 :       fprintf(fd,
     182                 :           "  RichTIFFIPTC Data: <present>, %lu bytes\n",
     183                 :           (unsigned long) value_count * 4);
     184               0 :       return 1;
     185                 :     case TIFFTAG_PHOTOSHOP:
     186               0 :       fprintf(fd, "  Photoshop Data: <present>, %lu bytes\n",
     187                 :           (unsigned long) value_count);
     188               0 :       return 1;
     189                 :     case TIFFTAG_ICCPROFILE:
     190               0 :       fprintf(fd, "  ICC Profile: <present>, %lu bytes\n",
     191                 :           (unsigned long) value_count);
     192               0 :       return 1;
     193                 :     case TIFFTAG_STONITS:
     194               0 :       fprintf(fd,
     195                 :           "  Sample to Nits conversion factor: %.4e\n",
     196                 :           *((double*)raw_data));
     197               0 :       return 1;
     198                 :   }
     199                 : 
     200               0 :   return 0;
     201                 : }
     202                 : 
     203                 : /*
     204                 :  * Print the contents of the current directory
     205                 :  * to the specified stdio file stream.
     206                 :  */
     207                 : void
     208                 : TIFFPrintDirectory(TIFF* tif, FILE* fd, long flags)
     209               0 : {
     210               0 :   TIFFDirectory *td = &tif->tif_dir;
     211                 :   char *sep;
     212                 :   uint16 i;
     213                 :   long l, n;
     214                 : 
     215                 : #if defined(__WIN32__) && defined(_MSC_VER)
     216                 :   fprintf(fd, "TIFF Directory at offset 0x%I64x (%I64u)\n",
     217                 :     (unsigned __int64) tif->tif_diroff,
     218                 :     (unsigned __int64) tif->tif_diroff);
     219                 : #else
     220               0 :   fprintf(fd, "TIFF Directory at offset 0x%llx (%llu)\n",
     221                 :     (unsigned long long) tif->tif_diroff,
     222                 :     (unsigned long long) tif->tif_diroff);
     223                 : #endif
     224               0 :   if (TIFFFieldSet(tif,FIELD_SUBFILETYPE)) {
     225               0 :     fprintf(fd, "  Subfile Type:");
     226               0 :     sep = " ";
     227               0 :     if (td->td_subfiletype & FILETYPE_REDUCEDIMAGE) {
     228               0 :       fprintf(fd, "%sreduced-resolution image", sep);
     229               0 :       sep = "/";
     230                 :     }
     231               0 :     if (td->td_subfiletype & FILETYPE_PAGE) {
     232               0 :       fprintf(fd, "%smulti-page document", sep);
     233               0 :       sep = "/";
     234                 :     }
     235               0 :     if (td->td_subfiletype & FILETYPE_MASK)
     236               0 :       fprintf(fd, "%stransparency mask", sep);
     237               0 :     fprintf(fd, " (%lu = 0x%lx)\n",
     238                 :         (long) td->td_subfiletype, (long) td->td_subfiletype);
     239                 :   }
     240               0 :   if (TIFFFieldSet(tif,FIELD_IMAGEDIMENSIONS)) {
     241               0 :     fprintf(fd, "  Image Width: %lu Image Length: %lu",
     242                 :         (unsigned long) td->td_imagewidth, (unsigned long) td->td_imagelength);
     243               0 :     if (TIFFFieldSet(tif,FIELD_IMAGEDEPTH))
     244               0 :       fprintf(fd, " Image Depth: %lu",
     245                 :           (unsigned long) td->td_imagedepth);
     246               0 :     fprintf(fd, "\n");
     247                 :   }
     248               0 :   if (TIFFFieldSet(tif,FIELD_TILEDIMENSIONS)) {
     249               0 :     fprintf(fd, "  Tile Width: %lu Tile Length: %lu",
     250                 :         (unsigned long) td->td_tilewidth, (unsigned long) td->td_tilelength);
     251               0 :     if (TIFFFieldSet(tif,FIELD_TILEDEPTH))
     252               0 :       fprintf(fd, " Tile Depth: %lu",
     253                 :           (unsigned long) td->td_tiledepth);
     254               0 :     fprintf(fd, "\n");
     255                 :   }
     256               0 :   if (TIFFFieldSet(tif,FIELD_RESOLUTION)) {
     257               0 :     fprintf(fd, "  Resolution: %g, %g",
     258                 :         td->td_xresolution, td->td_yresolution);
     259               0 :     if (TIFFFieldSet(tif,FIELD_RESOLUTIONUNIT)) {
     260               0 :       switch (td->td_resolutionunit) {
     261                 :       case RESUNIT_NONE:
     262               0 :         fprintf(fd, " (unitless)");
     263               0 :         break;
     264                 :       case RESUNIT_INCH:
     265               0 :         fprintf(fd, " pixels/inch");
     266               0 :         break;
     267                 :       case RESUNIT_CENTIMETER:
     268               0 :         fprintf(fd, " pixels/cm");
     269               0 :         break;
     270                 :       default:
     271               0 :         fprintf(fd, " (unit %u = 0x%x)",
     272                 :             td->td_resolutionunit,
     273                 :             td->td_resolutionunit);
     274                 :         break;
     275                 :       }
     276                 :     }
     277               0 :     fprintf(fd, "\n");
     278                 :   }
     279               0 :   if (TIFFFieldSet(tif,FIELD_POSITION))
     280               0 :     fprintf(fd, "  Position: %g, %g\n",
     281                 :         td->td_xposition, td->td_yposition);
     282               0 :   if (TIFFFieldSet(tif,FIELD_BITSPERSAMPLE))
     283               0 :     fprintf(fd, "  Bits/Sample: %u\n", td->td_bitspersample);
     284               0 :   if (TIFFFieldSet(tif,FIELD_SAMPLEFORMAT)) {
     285               0 :     fprintf(fd, "  Sample Format: ");
     286               0 :     switch (td->td_sampleformat) {
     287                 :     case SAMPLEFORMAT_VOID:
     288               0 :       fprintf(fd, "void\n");
     289               0 :       break;
     290                 :     case SAMPLEFORMAT_INT:
     291               0 :       fprintf(fd, "signed integer\n");
     292               0 :       break;
     293                 :     case SAMPLEFORMAT_UINT:
     294               0 :       fprintf(fd, "unsigned integer\n");
     295               0 :       break;
     296                 :     case SAMPLEFORMAT_IEEEFP:
     297               0 :       fprintf(fd, "IEEE floating point\n");
     298               0 :       break;
     299                 :     case SAMPLEFORMAT_COMPLEXINT:
     300               0 :       fprintf(fd, "complex signed integer\n");
     301               0 :       break;
     302                 :     case SAMPLEFORMAT_COMPLEXIEEEFP:
     303               0 :       fprintf(fd, "complex IEEE floating point\n");
     304               0 :       break;
     305                 :     default:
     306               0 :       fprintf(fd, "%u (0x%x)\n",
     307                 :           td->td_sampleformat, td->td_sampleformat);
     308                 :       break;
     309                 :     }
     310                 :   }
     311               0 :   if (TIFFFieldSet(tif,FIELD_COMPRESSION)) {
     312               0 :     const TIFFCodec* c = TIFFFindCODEC(td->td_compression);
     313               0 :     fprintf(fd, "  Compression Scheme: ");
     314               0 :     if (c)
     315               0 :       fprintf(fd, "%s\n", c->name);
     316                 :     else
     317               0 :       fprintf(fd, "%u (0x%x)\n",
     318                 :           td->td_compression, td->td_compression);
     319                 :   }
     320               0 :   if (TIFFFieldSet(tif,FIELD_PHOTOMETRIC)) {
     321               0 :     fprintf(fd, "  Photometric Interpretation: ");
     322               0 :     if (td->td_photometric < NPHOTONAMES)
     323               0 :       fprintf(fd, "%s\n", photoNames[td->td_photometric]);
     324                 :     else {
     325               0 :       switch (td->td_photometric) {
     326                 :       case PHOTOMETRIC_LOGL:
     327               0 :         fprintf(fd, "CIE Log2(L)\n");
     328               0 :         break;
     329                 :       case PHOTOMETRIC_LOGLUV:
     330               0 :         fprintf(fd, "CIE Log2(L) (u',v')\n");
     331               0 :         break;
     332                 :       default:
     333               0 :         fprintf(fd, "%u (0x%x)\n",
     334                 :             td->td_photometric, td->td_photometric);
     335                 :         break;
     336                 :       }
     337                 :     }
     338                 :   }
     339               0 :   if (TIFFFieldSet(tif,FIELD_EXTRASAMPLES) && td->td_extrasamples) {
     340               0 :     fprintf(fd, "  Extra Samples: %u<", td->td_extrasamples);
     341               0 :     sep = "";
     342               0 :     for (i = 0; i < td->td_extrasamples; i++) {
     343               0 :       switch (td->td_sampleinfo[i]) {
     344                 :       case EXTRASAMPLE_UNSPECIFIED:
     345               0 :         fprintf(fd, "%sunspecified", sep);
     346               0 :         break;
     347                 :       case EXTRASAMPLE_ASSOCALPHA:
     348               0 :         fprintf(fd, "%sassoc-alpha", sep);
     349               0 :         break;
     350                 :       case EXTRASAMPLE_UNASSALPHA:
     351               0 :         fprintf(fd, "%sunassoc-alpha", sep);
     352               0 :         break;
     353                 :       default:
     354               0 :         fprintf(fd, "%s%u (0x%x)", sep,
     355                 :             td->td_sampleinfo[i], td->td_sampleinfo[i]);
     356                 :         break;
     357                 :       }
     358               0 :       sep = ", ";
     359                 :     }
     360               0 :     fprintf(fd, ">\n");
     361                 :   }
     362               0 :   if (TIFFFieldSet(tif,FIELD_INKNAMES)) {
     363                 :     char* cp;
     364               0 :     fprintf(fd, "  Ink Names: ");
     365               0 :     i = td->td_samplesperpixel;
     366               0 :     sep = "";
     367               0 :     for (cp = td->td_inknames; i > 0; cp = strchr(cp,'\0')+1, i--) {
     368               0 :       fputs(sep, fd);
     369               0 :       _TIFFprintAscii(fd, cp);
     370               0 :       sep = ", ";
     371                 :     }
     372               0 :                 fputs("\n", fd);
     373                 :   }
     374               0 :   if (TIFFFieldSet(tif,FIELD_THRESHHOLDING)) {
     375               0 :     fprintf(fd, "  Thresholding: ");
     376               0 :     switch (td->td_threshholding) {
     377                 :     case THRESHHOLD_BILEVEL:
     378               0 :       fprintf(fd, "bilevel art scan\n");
     379               0 :       break;
     380                 :     case THRESHHOLD_HALFTONE:
     381               0 :       fprintf(fd, "halftone or dithered scan\n");
     382               0 :       break;
     383                 :     case THRESHHOLD_ERRORDIFFUSE:
     384               0 :       fprintf(fd, "error diffused\n");
     385               0 :       break;
     386                 :     default:
     387               0 :       fprintf(fd, "%u (0x%x)\n",
     388                 :           td->td_threshholding, td->td_threshholding);
     389                 :       break;
     390                 :     }
     391                 :   }
     392               0 :   if (TIFFFieldSet(tif,FIELD_FILLORDER)) {
     393               0 :     fprintf(fd, "  FillOrder: ");
     394               0 :     switch (td->td_fillorder) {
     395                 :     case FILLORDER_MSB2LSB:
     396               0 :       fprintf(fd, "msb-to-lsb\n");
     397               0 :       break;
     398                 :     case FILLORDER_LSB2MSB:
     399               0 :       fprintf(fd, "lsb-to-msb\n");
     400               0 :       break;
     401                 :     default:
     402               0 :       fprintf(fd, "%u (0x%x)\n",
     403                 :           td->td_fillorder, td->td_fillorder);
     404                 :       break;
     405                 :     }
     406                 :   }
     407               0 :   if (TIFFFieldSet(tif,FIELD_YCBCRSUBSAMPLING))
     408                 :         {
     409               0 :     fprintf(fd, "  YCbCr Subsampling: %u, %u\n",
     410                 :       td->td_ycbcrsubsampling[0], td->td_ycbcrsubsampling[1] );
     411                 :   }
     412               0 :   if (TIFFFieldSet(tif,FIELD_YCBCRPOSITIONING)) {
     413               0 :     fprintf(fd, "  YCbCr Positioning: ");
     414               0 :     switch (td->td_ycbcrpositioning) {
     415                 :     case YCBCRPOSITION_CENTERED:
     416               0 :       fprintf(fd, "centered\n");
     417               0 :       break;
     418                 :     case YCBCRPOSITION_COSITED:
     419               0 :       fprintf(fd, "cosited\n");
     420               0 :       break;
     421                 :     default:
     422               0 :       fprintf(fd, "%u (0x%x)\n",
     423                 :           td->td_ycbcrpositioning, td->td_ycbcrpositioning);
     424                 :       break;
     425                 :     }
     426                 :   }
     427               0 :   if (TIFFFieldSet(tif,FIELD_HALFTONEHINTS))
     428               0 :     fprintf(fd, "  Halftone Hints: light %u dark %u\n",
     429                 :         td->td_halftonehints[0], td->td_halftonehints[1]);
     430               0 :   if (TIFFFieldSet(tif,FIELD_ORIENTATION)) {
     431               0 :     fprintf(fd, "  Orientation: ");
     432               0 :     if (td->td_orientation < NORIENTNAMES)
     433               0 :       fprintf(fd, "%s\n", orientNames[td->td_orientation]);
     434                 :     else
     435               0 :       fprintf(fd, "%u (0x%x)\n",
     436                 :           td->td_orientation, td->td_orientation);
     437                 :   }
     438               0 :   if (TIFFFieldSet(tif,FIELD_SAMPLESPERPIXEL))
     439               0 :     fprintf(fd, "  Samples/Pixel: %u\n", td->td_samplesperpixel);
     440               0 :   if (TIFFFieldSet(tif,FIELD_ROWSPERSTRIP)) {
     441               0 :     fprintf(fd, "  Rows/Strip: ");
     442               0 :     if (td->td_rowsperstrip == (uint32) -1)
     443               0 :       fprintf(fd, "(infinite)\n");
     444                 :     else
     445               0 :       fprintf(fd, "%lu\n", (unsigned long) td->td_rowsperstrip);
     446                 :   }
     447               0 :   if (TIFFFieldSet(tif,FIELD_MINSAMPLEVALUE))
     448               0 :     fprintf(fd, "  Min Sample Value: %u\n", td->td_minsamplevalue);
     449               0 :   if (TIFFFieldSet(tif,FIELD_MAXSAMPLEVALUE))
     450               0 :     fprintf(fd, "  Max Sample Value: %u\n", td->td_maxsamplevalue);
     451               0 :   if (TIFFFieldSet(tif,FIELD_SMINSAMPLEVALUE))
     452               0 :     fprintf(fd, "  SMin Sample Value: %g\n",
     453                 :         td->td_sminsamplevalue);
     454               0 :   if (TIFFFieldSet(tif,FIELD_SMAXSAMPLEVALUE))
     455               0 :     fprintf(fd, "  SMax Sample Value: %g\n",
     456                 :         td->td_smaxsamplevalue);
     457               0 :   if (TIFFFieldSet(tif,FIELD_PLANARCONFIG)) {
     458               0 :     fprintf(fd, "  Planar Configuration: ");
     459               0 :     switch (td->td_planarconfig) {
     460                 :     case PLANARCONFIG_CONTIG:
     461               0 :       fprintf(fd, "single image plane\n");
     462               0 :       break;
     463                 :     case PLANARCONFIG_SEPARATE:
     464               0 :       fprintf(fd, "separate image planes\n");
     465               0 :       break;
     466                 :     default:
     467               0 :       fprintf(fd, "%u (0x%x)\n",
     468                 :           td->td_planarconfig, td->td_planarconfig);
     469                 :       break;
     470                 :     }
     471                 :   }
     472               0 :   if (TIFFFieldSet(tif,FIELD_PAGENUMBER))
     473               0 :     fprintf(fd, "  Page Number: %u-%u\n",
     474                 :         td->td_pagenumber[0], td->td_pagenumber[1]);
     475               0 :   if (TIFFFieldSet(tif,FIELD_COLORMAP)) {
     476               0 :     fprintf(fd, "  Color Map: ");
     477               0 :     if (flags & TIFFPRINT_COLORMAP) {
     478               0 :       fprintf(fd, "\n");
     479               0 :       n = 1L<<td->td_bitspersample;
     480               0 :       for (l = 0; l < n; l++)
     481               0 :         fprintf(fd, "   %5lu: %5u %5u %5u\n",
     482                 :             l,
     483                 :             td->td_colormap[0][l],
     484                 :             td->td_colormap[1][l],
     485                 :             td->td_colormap[2][l]);
     486                 :     } else
     487               0 :       fprintf(fd, "(present)\n");
     488                 :   }
     489               0 :   if (TIFFFieldSet(tif,FIELD_REFBLACKWHITE)) {
     490               0 :     fprintf(fd, "  Reference Black/White:\n");
     491               0 :     for (i = 0; i < 3; i++)
     492               0 :     fprintf(fd, "    %2d: %5g %5g\n", i,
     493                 :       td->td_refblackwhite[2*i+0],
     494                 :       td->td_refblackwhite[2*i+1]);
     495                 :   }
     496               0 :   if (TIFFFieldSet(tif,FIELD_TRANSFERFUNCTION)) {
     497               0 :     fprintf(fd, "  Transfer Function: ");
     498               0 :     if (flags & TIFFPRINT_CURVES) {
     499               0 :       fprintf(fd, "\n");
     500               0 :       n = 1L<<td->td_bitspersample;
     501               0 :       for (l = 0; l < n; l++) {
     502               0 :         fprintf(fd, "    %2lu: %5u",
     503                 :             l, td->td_transferfunction[0][l]);
     504               0 :         for (i = 1; i < td->td_samplesperpixel; i++)
     505               0 :           fprintf(fd, " %5u",
     506                 :               td->td_transferfunction[i][l]);
     507               0 :         fputc('\n', fd);
     508                 :       }
     509                 :     } else
     510               0 :       fprintf(fd, "(present)\n");
     511                 :   }
     512               0 :   if (TIFFFieldSet(tif, FIELD_SUBIFD) && (td->td_subifd)) {
     513               0 :     fprintf(fd, "  SubIFD Offsets:");
     514               0 :     for (i = 0; i < td->td_nsubifd; i++)
     515                 : #if defined(__WIN32__) && defined(_MSC_VER)
     516                 :       fprintf(fd, " %5I64u",
     517                 :         (unsigned __int64) td->td_subifd[i]);
     518                 : #else
     519               0 :       fprintf(fd, " %5llu",
     520                 :         (unsigned long long) td->td_subifd[i]);
     521                 : #endif
     522               0 :     fputc('\n', fd);
     523                 :   }
     524                 : 
     525                 :   /*
     526                 :   ** Custom tag support.
     527                 :   */
     528                 :   {
     529                 :     int  i;
     530                 :     short count;
     531                 : 
     532               0 :     count = (short) TIFFGetTagListCount(tif);
     533               0 :     for(i = 0; i < count; i++) {
     534               0 :       uint32 tag = TIFFGetTagListEntry(tif, i);
     535                 :       const TIFFField *fip;
     536                 :       uint32 value_count;
     537               0 :       int mem_alloc = 0;
     538                 :       void *raw_data;
     539                 : 
     540               0 :       fip = TIFFFieldWithTag(tif, tag);
     541               0 :       if(fip == NULL)
     542               0 :         continue;
     543                 : 
     544               0 :       if(fip->field_passcount) {
     545               0 :         if(TIFFGetField(tif, tag, &value_count, &raw_data) != 1)
     546               0 :           continue;
     547                 :       } else {
     548               0 :         if (fip->field_readcount == TIFF_VARIABLE
     549                 :             || fip->field_readcount == TIFF_VARIABLE2)
     550               0 :           value_count = 1;
     551               0 :         else if (fip->field_readcount == TIFF_SPP)
     552               0 :           value_count = td->td_samplesperpixel;
     553                 :         else
     554               0 :           value_count = fip->field_readcount;
     555               0 :         if ((fip->field_type == TIFF_ASCII
     556                 :             || fip->field_readcount == TIFF_VARIABLE
     557                 :             || fip->field_readcount == TIFF_VARIABLE2
     558                 :             || fip->field_readcount == TIFF_SPP
     559                 :             || value_count > 1)
     560                 :             && fip->field_tag != TIFFTAG_PAGENUMBER
     561                 :             && fip->field_tag != TIFFTAG_HALFTONEHINTS
     562                 :             && fip->field_tag != TIFFTAG_YCBCRSUBSAMPLING
     563                 :             && fip->field_tag != TIFFTAG_DOTRANGE) {
     564               0 :           if(TIFFGetField(tif, tag, &raw_data) != 1)
     565               0 :             continue;
     566               0 :         } else if (fip->field_tag != TIFFTAG_PAGENUMBER
     567                 :             && fip->field_tag != TIFFTAG_HALFTONEHINTS
     568                 :             && fip->field_tag != TIFFTAG_YCBCRSUBSAMPLING
     569                 :             && fip->field_tag != TIFFTAG_DOTRANGE) {
     570               0 :           raw_data = _TIFFmalloc(
     571                 :               _TIFFDataSize(fip->field_type)
     572                 :               * value_count);
     573               0 :           mem_alloc = 1;
     574               0 :           if(TIFFGetField(tif, tag, raw_data) != 1) {
     575               0 :             _TIFFfree(raw_data);
     576               0 :             continue;
     577                 :           }
     578                 :         } else {
     579                 :           /*
     580                 :            * XXX: Should be fixed and removed,
     581                 :            * see the notes related to
     582                 :            * TIFFTAG_PAGENUMBER,
     583                 :            * TIFFTAG_HALFTONEHINTS,
     584                 :            * TIFFTAG_YCBCRSUBSAMPLING and
     585                 :            * TIFFTAG_DOTRANGE tags in tif_dir.c.
     586                 :            */
     587                 :           char *tmp;
     588               0 :           raw_data = _TIFFmalloc(
     589                 :               _TIFFDataSize(fip->field_type)
     590                 :               * value_count);
     591               0 :           tmp = raw_data;
     592               0 :           mem_alloc = 1;
     593               0 :           if(TIFFGetField(tif, tag, tmp,
     594                 :               tmp + _TIFFDataSize(fip->field_type)) != 1) {
     595               0 :             _TIFFfree(raw_data);
     596               0 :             continue;
     597                 :           }
     598                 :         }
     599                 :       }
     600                 : 
     601                 :       /*
     602                 :        * Catch the tags which needs to be specially handled
     603                 :        * and pretty print them. If tag not handled in
     604                 :        * _TIFFPrettyPrintField() fall down and print it as
     605                 :        * any other tag.
     606                 :        */
     607               0 :       if (!_TIFFPrettyPrintField(tif, fd, tag, value_count, raw_data))
     608               0 :         _TIFFPrintField(fd, fip, value_count, raw_data);
     609                 : 
     610               0 :       if(mem_alloc)
     611               0 :         _TIFFfree(raw_data);
     612                 :     }
     613                 :   }
     614                 :         
     615               0 :   if (tif->tif_tagmethods.printdir)
     616               0 :     (*tif->tif_tagmethods.printdir)(tif, fd, flags);
     617               0 :   if ((flags & TIFFPRINT_STRIPS) &&
     618                 :       TIFFFieldSet(tif,FIELD_STRIPOFFSETS)) {
     619                 :     uint32 s;
     620                 : 
     621               0 :     fprintf(fd, "  %lu %s:\n",
     622                 :         (long) td->td_nstrips,
     623                 :         isTiled(tif) ? "Tiles" : "Strips");
     624               0 :     for (s = 0; s < td->td_nstrips; s++)
     625                 : #if defined(__WIN32__) && defined(_MSC_VER)
     626                 :       fprintf(fd, "    %3lu: [%8I64u, %8I64u]\n",
     627                 :           (unsigned long) s,
     628                 :           (unsigned __int64) td->td_stripoffset[s],
     629                 :           (unsigned __int64) td->td_stripbytecount[s]);
     630                 : #else
     631               0 :       fprintf(fd, "    %3lu: [%8llu, %8llu]\n",
     632                 :           (unsigned long) s,
     633                 :           (unsigned long long) td->td_stripoffset[s],
     634                 :           (unsigned long long) td->td_stripbytecount[s]);
     635                 : #endif
     636                 :   }
     637               0 : }
     638                 : 
     639                 : void
     640                 : _TIFFprintAscii(FILE* fd, const char* cp)
     641               0 : {
     642               0 :   for (; *cp != '\0'; cp++) {
     643                 :     const char* tp;
     644                 : 
     645               0 :     if (isprint((int)*cp)) {
     646               0 :       fputc(*cp, fd);
     647               0 :       continue;
     648                 :     }
     649               0 :     for (tp = "\tt\bb\rr\nn\vv"; *tp; tp++)
     650               0 :       if (*tp++ == *cp)
     651               0 :         break;
     652               0 :     if (*tp)
     653               0 :       fprintf(fd, "\\%c", *tp);
     654                 :     else
     655               0 :       fprintf(fd, "\\%03o", *cp & 0xff);
     656                 :   }
     657               0 : }
     658                 : 
     659                 : void
     660                 : _TIFFprintAsciiTag(FILE* fd, const char* name, const char* value)
     661               0 : {
     662               0 :   fprintf(fd, "  %s: \"", name);
     663               0 :   _TIFFprintAscii(fd, value);
     664               0 :   fprintf(fd, "\"\n");
     665               0 : }
     666                 : 
     667                 : /* vim: set ts=8 sts=8 sw=8 noet: */
     668                 : /*
     669                 :  * Local Variables:
     670                 :  * mode: c
     671                 :  * c-basic-offset: 8
     672                 :  * fill-column: 78
     673                 :  * End:
     674                 :  */

Generated by: LTP GCOV extension version 1.5