Home | Info | Community | Development | myReactOS | Contact Us
ReactOS Development > Doxygentif_print.c
Go to the documentation of this file.
00001 /* $Id: tif_print.c,v 1.36.2.4 2010-06-08 18:50:42 bfriesen Exp $ */ 00002 00003 /* 00004 * Copyright (c) 1988-1997 Sam Leffler 00005 * Copyright (c) 1991-1997 Silicon Graphics, Inc. 00006 * 00007 * Permission to use, copy, modify, distribute, and sell this software and 00008 * its documentation for any purpose is hereby granted without fee, provided 00009 * that (i) the above copyright notices and this permission notice appear in 00010 * all copies of the software and related documentation, and (ii) the names of 00011 * Sam Leffler and Silicon Graphics may not be used in any advertising or 00012 * publicity relating to the software without the specific, prior written 00013 * permission of Sam Leffler and Silicon Graphics. 00014 * 00015 * THE SOFTWARE IS PROVIDED "AS-IS" AND WITHOUT WARRANTY OF ANY KIND, 00016 * EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY 00017 * WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. 00018 * 00019 * IN NO EVENT SHALL SAM LEFFLER OR SILICON GRAPHICS BE LIABLE FOR 00020 * ANY SPECIAL, INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY KIND, 00021 * OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, 00022 * WHETHER OR NOT ADVISED OF THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF 00023 * LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE 00024 * OF THIS SOFTWARE. 00025 */ 00026 00027 /* 00028 * TIFF Library. 00029 * 00030 * Directory Printing Support 00031 */ 00032 #include "tiffiop.h" 00033 #include <stdio.h> 00034 #include <string.h> 00035 #include <ctype.h> 00036 00037 static const char *photoNames[] = { 00038 "min-is-white", /* PHOTOMETRIC_MINISWHITE */ 00039 "min-is-black", /* PHOTOMETRIC_MINISBLACK */ 00040 "RGB color", /* PHOTOMETRIC_RGB */ 00041 "palette color (RGB from colormap)", /* PHOTOMETRIC_PALETTE */ 00042 "transparency mask", /* PHOTOMETRIC_MASK */ 00043 "separated", /* PHOTOMETRIC_SEPARATED */ 00044 "YCbCr", /* PHOTOMETRIC_YCBCR */ 00045 "7 (0x7)", 00046 "CIE L*a*b*", /* PHOTOMETRIC_CIELAB */ 00047 }; 00048 #define NPHOTONAMES (sizeof (photoNames) / sizeof (photoNames[0])) 00049 00050 static const char *orientNames[] = { 00051 "0 (0x0)", 00052 "row 0 top, col 0 lhs", /* ORIENTATION_TOPLEFT */ 00053 "row 0 top, col 0 rhs", /* ORIENTATION_TOPRIGHT */ 00054 "row 0 bottom, col 0 rhs", /* ORIENTATION_BOTRIGHT */ 00055 "row 0 bottom, col 0 lhs", /* ORIENTATION_BOTLEFT */ 00056 "row 0 lhs, col 0 top", /* ORIENTATION_LEFTTOP */ 00057 "row 0 rhs, col 0 top", /* ORIENTATION_RIGHTTOP */ 00058 "row 0 rhs, col 0 bottom", /* ORIENTATION_RIGHTBOT */ 00059 "row 0 lhs, col 0 bottom", /* ORIENTATION_LEFTBOT */ 00060 }; 00061 #define NORIENTNAMES (sizeof (orientNames) / sizeof (orientNames[0])) 00062 00063 static void 00064 _TIFFPrintField(FILE* fd, const TIFFFieldInfo *fip, 00065 uint32 value_count, void *raw_data) 00066 { 00067 uint32 j; 00068 00069 fprintf(fd, " %s: ", fip->field_name); 00070 00071 for(j = 0; j < value_count; j++) { 00072 if(fip->field_type == TIFF_BYTE) 00073 fprintf(fd, "%u", ((uint8 *) raw_data)[j]); 00074 else if(fip->field_type == TIFF_UNDEFINED) 00075 fprintf(fd, "0x%x", 00076 (unsigned int) ((unsigned char *) raw_data)[j]); 00077 else if(fip->field_type == TIFF_SBYTE) 00078 fprintf(fd, "%d", ((int8 *) raw_data)[j]); 00079 else if(fip->field_type == TIFF_SHORT) 00080 fprintf(fd, "%u", ((uint16 *) raw_data)[j]); 00081 else if(fip->field_type == TIFF_SSHORT) 00082 fprintf(fd, "%d", ((int16 *) raw_data)[j]); 00083 else if(fip->field_type == TIFF_LONG) 00084 fprintf(fd, "%lu", 00085 (unsigned long)((uint32 *) raw_data)[j]); 00086 else if(fip->field_type == TIFF_SLONG) 00087 fprintf(fd, "%ld", (long)((int32 *) raw_data)[j]); 00088 else if(fip->field_type == TIFF_RATIONAL 00089 || fip->field_type == TIFF_SRATIONAL 00090 || fip->field_type == TIFF_FLOAT) 00091 fprintf(fd, "%f", ((float *) raw_data)[j]); 00092 else if(fip->field_type == TIFF_IFD) 00093 fprintf(fd, "0x%ulx", ((uint32 *) raw_data)[j]); 00094 else if(fip->field_type == TIFF_ASCII) { 00095 fprintf(fd, "%s", (char *) raw_data); 00096 break; 00097 } 00098 else if(fip->field_type == TIFF_DOUBLE) 00099 fprintf(fd, "%f", ((double *) raw_data)[j]); 00100 else if(fip->field_type == TIFF_FLOAT) 00101 fprintf(fd, "%f", ((float *)raw_data)[j]); 00102 else { 00103 fprintf(fd, "<unsupported data type in TIFFPrint>"); 00104 break; 00105 } 00106 00107 if(j < value_count - 1) 00108 fprintf(fd, ","); 00109 } 00110 00111 fprintf(fd, "\n"); 00112 } 00113 00114 static int 00115 _TIFFPrettyPrintField(TIFF* tif, FILE* fd, ttag_t tag, 00116 uint32 value_count, void *raw_data) 00117 { 00118 TIFFDirectory *td = &tif->tif_dir; 00119 00120 switch (tag) 00121 { 00122 case TIFFTAG_INKSET: 00123 fprintf(fd, " Ink Set: "); 00124 switch (*((uint16*)raw_data)) { 00125 case INKSET_CMYK: 00126 fprintf(fd, "CMYK\n"); 00127 break; 00128 default: 00129 fprintf(fd, "%u (0x%x)\n", 00130 *((uint16*)raw_data), 00131 *((uint16*)raw_data)); 00132 break; 00133 } 00134 return 1; 00135 case TIFFTAG_DOTRANGE: 00136 fprintf(fd, " Dot Range: %u-%u\n", 00137 ((uint16*)raw_data)[0], ((uint16*)raw_data)[1]); 00138 return 1; 00139 case TIFFTAG_WHITEPOINT: 00140 fprintf(fd, " White Point: %g-%g\n", 00141 ((float *)raw_data)[0], ((float *)raw_data)[1]); return 1; 00142 case TIFFTAG_REFERENCEBLACKWHITE: 00143 { 00144 uint16 i; 00145 00146 fprintf(fd, " Reference Black/White:\n"); 00147 for (i = 0; i < 3; i++) 00148 fprintf(fd, " %2d: %5g %5g\n", i, 00149 ((float *)raw_data)[2*i+0], 00150 ((float *)raw_data)[2*i+1]); 00151 return 1; 00152 } 00153 case TIFFTAG_XMLPACKET: 00154 { 00155 uint32 i; 00156 00157 fprintf(fd, " XMLPacket (XMP Metadata):\n" ); 00158 for(i = 0; i < value_count; i++) 00159 fputc(((char *)raw_data)[i], fd); 00160 fprintf( fd, "\n" ); 00161 return 1; 00162 } 00163 case TIFFTAG_RICHTIFFIPTC: 00164 /* 00165 * XXX: for some weird reason RichTIFFIPTC tag 00166 * defined as array of LONG values. 00167 */ 00168 fprintf(fd, 00169 " RichTIFFIPTC Data: <present>, %lu bytes\n", 00170 (unsigned long) value_count * 4); 00171 return 1; 00172 case TIFFTAG_PHOTOSHOP: 00173 fprintf(fd, " Photoshop Data: <present>, %lu bytes\n", 00174 (unsigned long) value_count); 00175 return 1; 00176 case TIFFTAG_ICCPROFILE: 00177 fprintf(fd, " ICC Profile: <present>, %lu bytes\n", 00178 (unsigned long) value_count); 00179 return 1; 00180 case TIFFTAG_STONITS: 00181 fprintf(fd, 00182 " Sample to Nits conversion factor: %.4e\n", 00183 *((double*)raw_data)); 00184 return 1; 00185 } 00186 00187 return 0; 00188 } 00189 00190 /* 00191 * Print the contents of the current directory 00192 * to the specified stdio file stream. 00193 */ 00194 void 00195 TIFFPrintDirectory(TIFF* tif, FILE* fd, long flags) 00196 { 00197 TIFFDirectory *td = &tif->tif_dir; 00198 char *sep; 00199 uint16 i; 00200 long l, n; 00201 00202 fprintf(fd, "TIFF Directory at offset 0x%lx (%lu)\n", 00203 (unsigned long)tif->tif_diroff, (unsigned long)tif->tif_diroff); 00204 if (TIFFFieldSet(tif,FIELD_SUBFILETYPE)) { 00205 fprintf(fd, " Subfile Type:"); 00206 sep = " "; 00207 if (td->td_subfiletype & FILETYPE_REDUCEDIMAGE) { 00208 fprintf(fd, "%sreduced-resolution image", sep); 00209 sep = "/"; 00210 } 00211 if (td->td_subfiletype & FILETYPE_PAGE) { 00212 fprintf(fd, "%smulti-page document", sep); 00213 sep = "/"; 00214 } 00215 if (td->td_subfiletype & FILETYPE_MASK) 00216 fprintf(fd, "%stransparency mask", sep); 00217 fprintf(fd, " (%lu = 0x%lx)\n", 00218 (long) td->td_subfiletype, (long) td->td_subfiletype); 00219 } 00220 if (TIFFFieldSet(tif,FIELD_IMAGEDIMENSIONS)) { 00221 fprintf(fd, " Image Width: %lu Image Length: %lu", 00222 (unsigned long) td->td_imagewidth, (unsigned long) td->td_imagelength); 00223 if (TIFFFieldSet(tif,FIELD_IMAGEDEPTH)) 00224 fprintf(fd, " Image Depth: %lu", 00225 (unsigned long) td->td_imagedepth); 00226 fprintf(fd, "\n"); 00227 } 00228 if (TIFFFieldSet(tif,FIELD_TILEDIMENSIONS)) { 00229 fprintf(fd, " Tile Width: %lu Tile Length: %lu", 00230 (unsigned long) td->td_tilewidth, (unsigned long) td->td_tilelength); 00231 if (TIFFFieldSet(tif,FIELD_TILEDEPTH)) 00232 fprintf(fd, " Tile Depth: %lu", 00233 (unsigned long) td->td_tiledepth); 00234 fprintf(fd, "\n"); 00235 } 00236 if (TIFFFieldSet(tif,FIELD_RESOLUTION)) { 00237 fprintf(fd, " Resolution: %g, %g", 00238 td->td_xresolution, td->td_yresolution); 00239 if (TIFFFieldSet(tif,FIELD_RESOLUTIONUNIT)) { 00240 switch (td->td_resolutionunit) { 00241 case RESUNIT_NONE: 00242 fprintf(fd, " (unitless)"); 00243 break; 00244 case RESUNIT_INCH: 00245 fprintf(fd, " pixels/inch"); 00246 break; 00247 case RESUNIT_CENTIMETER: 00248 fprintf(fd, " pixels/cm"); 00249 break; 00250 default: 00251 fprintf(fd, " (unit %u = 0x%x)", 00252 td->td_resolutionunit, 00253 td->td_resolutionunit); 00254 break; 00255 } 00256 } 00257 fprintf(fd, "\n"); 00258 } 00259 if (TIFFFieldSet(tif,FIELD_POSITION)) 00260 fprintf(fd, " Position: %g, %g\n", 00261 td->td_xposition, td->td_yposition); 00262 if (TIFFFieldSet(tif,FIELD_BITSPERSAMPLE)) 00263 fprintf(fd, " Bits/Sample: %u\n", td->td_bitspersample); 00264 if (TIFFFieldSet(tif,FIELD_SAMPLEFORMAT)) { 00265 fprintf(fd, " Sample Format: "); 00266 switch (td->td_sampleformat) { 00267 case SAMPLEFORMAT_VOID: 00268 fprintf(fd, "void\n"); 00269 break; 00270 case SAMPLEFORMAT_INT: 00271 fprintf(fd, "signed integer\n"); 00272 break; 00273 case SAMPLEFORMAT_UINT: 00274 fprintf(fd, "unsigned integer\n"); 00275 break; 00276 case SAMPLEFORMAT_IEEEFP: 00277 fprintf(fd, "IEEE floating point\n"); 00278 break; 00279 case SAMPLEFORMAT_COMPLEXINT: 00280 fprintf(fd, "complex signed integer\n"); 00281 break; 00282 case SAMPLEFORMAT_COMPLEXIEEEFP: 00283 fprintf(fd, "complex IEEE floating point\n"); 00284 break; 00285 default: 00286 fprintf(fd, "%u (0x%x)\n", 00287 td->td_sampleformat, td->td_sampleformat); 00288 break; 00289 } 00290 } 00291 if (TIFFFieldSet(tif,FIELD_COMPRESSION)) { 00292 const TIFFCodec* c = TIFFFindCODEC(td->td_compression); 00293 fprintf(fd, " Compression Scheme: "); 00294 if (c) 00295 fprintf(fd, "%s\n", c->name); 00296 else 00297 fprintf(fd, "%u (0x%x)\n", 00298 td->td_compression, td->td_compression); 00299 } 00300 if (TIFFFieldSet(tif,FIELD_PHOTOMETRIC)) { 00301 fprintf(fd, " Photometric Interpretation: "); 00302 if (td->td_photometric < NPHOTONAMES) 00303 fprintf(fd, "%s\n", photoNames[td->td_photometric]); 00304 else { 00305 switch (td->td_photometric) { 00306 case PHOTOMETRIC_LOGL: 00307 fprintf(fd, "CIE Log2(L)\n"); 00308 break; 00309 case PHOTOMETRIC_LOGLUV: 00310 fprintf(fd, "CIE Log2(L) (u',v')\n"); 00311 break; 00312 default: 00313 fprintf(fd, "%u (0x%x)\n", 00314 td->td_photometric, td->td_photometric); 00315 break; 00316 } 00317 } 00318 } 00319 if (TIFFFieldSet(tif,FIELD_EXTRASAMPLES) && td->td_extrasamples) { 00320 fprintf(fd, " Extra Samples: %u<", td->td_extrasamples); 00321 sep = ""; 00322 for (i = 0; i < td->td_extrasamples; i++) { 00323 switch (td->td_sampleinfo[i]) { 00324 case EXTRASAMPLE_UNSPECIFIED: 00325 fprintf(fd, "%sunspecified", sep); 00326 break; 00327 case EXTRASAMPLE_ASSOCALPHA: 00328 fprintf(fd, "%sassoc-alpha", sep); 00329 break; 00330 case EXTRASAMPLE_UNASSALPHA: 00331 fprintf(fd, "%sunassoc-alpha", sep); 00332 break; 00333 default: 00334 fprintf(fd, "%s%u (0x%x)", sep, 00335 td->td_sampleinfo[i], td->td_sampleinfo[i]); 00336 break; 00337 } 00338 sep = ", "; 00339 } 00340 fprintf(fd, ">\n"); 00341 } 00342 if (TIFFFieldSet(tif,FIELD_INKNAMES)) { 00343 char* cp; 00344 fprintf(fd, " Ink Names: "); 00345 i = td->td_samplesperpixel; 00346 sep = ""; 00347 for (cp = td->td_inknames; i > 0; cp = strchr(cp,'\0')+1, i--) { 00348 fputs(sep, fd); 00349 _TIFFprintAscii(fd, cp); 00350 sep = ", "; 00351 } 00352 fputs("\n", fd); 00353 } 00354 if (TIFFFieldSet(tif,FIELD_THRESHHOLDING)) { 00355 fprintf(fd, " Thresholding: "); 00356 switch (td->td_threshholding) { 00357 case THRESHHOLD_BILEVEL: 00358 fprintf(fd, "bilevel art scan\n"); 00359 break; 00360 case THRESHHOLD_HALFTONE: 00361 fprintf(fd, "halftone or dithered scan\n"); 00362 break; 00363 case THRESHHOLD_ERRORDIFFUSE: 00364 fprintf(fd, "error diffused\n"); 00365 break; 00366 default: 00367 fprintf(fd, "%u (0x%x)\n", 00368 td->td_threshholding, td->td_threshholding); 00369 break; 00370 } 00371 } 00372 if (TIFFFieldSet(tif,FIELD_FILLORDER)) { 00373 fprintf(fd, " FillOrder: "); 00374 switch (td->td_fillorder) { 00375 case FILLORDER_MSB2LSB: 00376 fprintf(fd, "msb-to-lsb\n"); 00377 break; 00378 case FILLORDER_LSB2MSB: 00379 fprintf(fd, "lsb-to-msb\n"); 00380 break; 00381 default: 00382 fprintf(fd, "%u (0x%x)\n", 00383 td->td_fillorder, td->td_fillorder); 00384 break; 00385 } 00386 } 00387 if (TIFFFieldSet(tif,FIELD_YCBCRSUBSAMPLING)) 00388 { 00389 /* 00390 * For hacky reasons (see tif_jpeg.c - JPEGFixupTestSubsampling), 00391 * we need to fetch this rather than trust what is in our 00392 * structures. 00393 */ 00394 uint16 subsampling[2]; 00395 00396 TIFFGetField( tif, TIFFTAG_YCBCRSUBSAMPLING, 00397 subsampling + 0, subsampling + 1 ); 00398 fprintf(fd, " YCbCr Subsampling: %u, %u\n", 00399 subsampling[0], subsampling[1] ); 00400 } 00401 if (TIFFFieldSet(tif,FIELD_YCBCRPOSITIONING)) { 00402 fprintf(fd, " YCbCr Positioning: "); 00403 switch (td->td_ycbcrpositioning) { 00404 case YCBCRPOSITION_CENTERED: 00405 fprintf(fd, "centered\n"); 00406 break; 00407 case YCBCRPOSITION_COSITED: 00408 fprintf(fd, "cosited\n"); 00409 break; 00410 default: 00411 fprintf(fd, "%u (0x%x)\n", 00412 td->td_ycbcrpositioning, td->td_ycbcrpositioning); 00413 break; 00414 } 00415 } 00416 if (TIFFFieldSet(tif,FIELD_HALFTONEHINTS)) 00417 fprintf(fd, " Halftone Hints: light %u dark %u\n", 00418 td->td_halftonehints[0], td->td_halftonehints[1]); 00419 if (TIFFFieldSet(tif,FIELD_ORIENTATION)) { 00420 fprintf(fd, " Orientation: "); 00421 if (td->td_orientation < NORIENTNAMES) 00422 fprintf(fd, "%s\n", orientNames[td->td_orientation]); 00423 else 00424 fprintf(fd, "%u (0x%x)\n", 00425 td->td_orientation, td->td_orientation); 00426 } 00427 if (TIFFFieldSet(tif,FIELD_SAMPLESPERPIXEL)) 00428 fprintf(fd, " Samples/Pixel: %u\n", td->td_samplesperpixel); 00429 if (TIFFFieldSet(tif,FIELD_ROWSPERSTRIP)) { 00430 fprintf(fd, " Rows/Strip: "); 00431 if (td->td_rowsperstrip == (uint32) -1) 00432 fprintf(fd, "(infinite)\n"); 00433 else 00434 fprintf(fd, "%lu\n", (unsigned long) td->td_rowsperstrip); 00435 } 00436 if (TIFFFieldSet(tif,FIELD_MINSAMPLEVALUE)) 00437 fprintf(fd, " Min Sample Value: %u\n", td->td_minsamplevalue); 00438 if (TIFFFieldSet(tif,FIELD_MAXSAMPLEVALUE)) 00439 fprintf(fd, " Max Sample Value: %u\n", td->td_maxsamplevalue); 00440 if (TIFFFieldSet(tif,FIELD_SMINSAMPLEVALUE)) 00441 fprintf(fd, " SMin Sample Value: %g\n", 00442 td->td_sminsamplevalue); 00443 if (TIFFFieldSet(tif,FIELD_SMAXSAMPLEVALUE)) 00444 fprintf(fd, " SMax Sample Value: %g\n", 00445 td->td_smaxsamplevalue); 00446 if (TIFFFieldSet(tif,FIELD_PLANARCONFIG)) { 00447 fprintf(fd, " Planar Configuration: "); 00448 switch (td->td_planarconfig) { 00449 case PLANARCONFIG_CONTIG: 00450 fprintf(fd, "single image plane\n"); 00451 break; 00452 case PLANARCONFIG_SEPARATE: 00453 fprintf(fd, "separate image planes\n"); 00454 break; 00455 default: 00456 fprintf(fd, "%u (0x%x)\n", 00457 td->td_planarconfig, td->td_planarconfig); 00458 break; 00459 } 00460 } 00461 if (TIFFFieldSet(tif,FIELD_PAGENUMBER)) 00462 fprintf(fd, " Page Number: %u-%u\n", 00463 td->td_pagenumber[0], td->td_pagenumber[1]); 00464 if (TIFFFieldSet(tif,FIELD_COLORMAP)) { 00465 fprintf(fd, " Color Map: "); 00466 if (flags & TIFFPRINT_COLORMAP) { 00467 fprintf(fd, "\n"); 00468 n = 1L<<td->td_bitspersample; 00469 for (l = 0; l < n; l++) 00470 fprintf(fd, " %5lu: %5u %5u %5u\n", 00471 l, 00472 td->td_colormap[0][l], 00473 td->td_colormap[1][l], 00474 td->td_colormap[2][l]); 00475 } else 00476 fprintf(fd, "(present)\n"); 00477 } 00478 if (TIFFFieldSet(tif,FIELD_TRANSFERFUNCTION)) { 00479 fprintf(fd, " Transfer Function: "); 00480 if (flags & TIFFPRINT_CURVES) { 00481 fprintf(fd, "\n"); 00482 n = 1L<<td->td_bitspersample; 00483 for (l = 0; l < n; l++) { 00484 fprintf(fd, " %2lu: %5u", 00485 l, td->td_transferfunction[0][l]); 00486 for (i = 1; i < td->td_samplesperpixel; i++) 00487 fprintf(fd, " %5u", 00488 td->td_transferfunction[i][l]); 00489 fputc('\n', fd); 00490 } 00491 } else 00492 fprintf(fd, "(present)\n"); 00493 } 00494 if (TIFFFieldSet(tif, FIELD_SUBIFD) && (td->td_subifd)) { 00495 fprintf(fd, " SubIFD Offsets:"); 00496 for (i = 0; i < td->td_nsubifd; i++) 00497 fprintf(fd, " %5lu", (long) td->td_subifd[i]); 00498 fputc('\n', fd); 00499 } 00500 00501 /* 00502 ** Custom tag support. 00503 */ 00504 { 00505 int i; 00506 short count; 00507 00508 count = (short) TIFFGetTagListCount(tif); 00509 for(i = 0; i < count; i++) { 00510 ttag_t tag = TIFFGetTagListEntry(tif, i); 00511 const TIFFFieldInfo *fip; 00512 uint32 value_count; 00513 int mem_alloc = 0; 00514 void *raw_data; 00515 00516 fip = TIFFFieldWithTag(tif, tag); 00517 if(fip == NULL) 00518 continue; 00519 00520 if(fip->field_passcount) { 00521 if(TIFFGetField(tif, tag, &value_count, &raw_data) != 1) 00522 continue; 00523 } else { 00524 if (fip->field_readcount == TIFF_VARIABLE 00525 || fip->field_readcount == TIFF_VARIABLE2) 00526 value_count = 1; 00527 else if (fip->field_readcount == TIFF_SPP) 00528 value_count = td->td_samplesperpixel; 00529 else 00530 value_count = fip->field_readcount; 00531 if ((fip->field_type == TIFF_ASCII 00532 || fip->field_readcount == TIFF_VARIABLE 00533 || fip->field_readcount == TIFF_VARIABLE2 00534 || fip->field_readcount == TIFF_SPP 00535 || value_count > 1) 00536 && fip->field_tag != TIFFTAG_PAGENUMBER 00537 && fip->field_tag != TIFFTAG_HALFTONEHINTS 00538 && fip->field_tag != TIFFTAG_YCBCRSUBSAMPLING 00539 && fip->field_tag != TIFFTAG_DOTRANGE) { 00540 if(TIFFGetField(tif, tag, &raw_data) != 1) 00541 continue; 00542 } else if (fip->field_tag != TIFFTAG_PAGENUMBER 00543 && fip->field_tag != TIFFTAG_HALFTONEHINTS 00544 && fip->field_tag != TIFFTAG_YCBCRSUBSAMPLING 00545 && fip->field_tag != TIFFTAG_DOTRANGE) { 00546 raw_data = _TIFFmalloc( 00547 _TIFFDataSize(fip->field_type) 00548 * value_count); 00549 mem_alloc = 1; 00550 if(TIFFGetField(tif, tag, raw_data) != 1) { 00551 _TIFFfree(raw_data); 00552 continue; 00553 } 00554 } else { 00555 /* 00556 * XXX: Should be fixed and removed, see the 00557 * notes related to TIFFTAG_PAGENUMBER, 00558 * TIFFTAG_HALFTONEHINTS, 00559 * TIFFTAG_YCBCRSUBSAMPLING and 00560 * TIFFTAG_DOTRANGE tags in tif_dir.c. */ 00561 char *tmp; 00562 raw_data = _TIFFmalloc( 00563 _TIFFDataSize(fip->field_type) 00564 * value_count); 00565 tmp = raw_data; 00566 mem_alloc = 1; 00567 if(TIFFGetField(tif, tag, tmp, 00568 tmp + _TIFFDataSize(fip->field_type)) != 1) { 00569 _TIFFfree(raw_data); 00570 continue; 00571 } 00572 } 00573 } 00574 00575 /* 00576 * Catch the tags which needs to be specially handled and 00577 * pretty print them. If tag not handled in 00578 * _TIFFPrettyPrintField() fall down and print it as any other 00579 * tag. 00580 */ 00581 if (_TIFFPrettyPrintField(tif, fd, tag, value_count, raw_data)) { 00582 if(mem_alloc) 00583 _TIFFfree(raw_data); 00584 continue; 00585 } 00586 else 00587 _TIFFPrintField(fd, fip, value_count, raw_data); 00588 00589 if(mem_alloc) 00590 _TIFFfree(raw_data); 00591 } 00592 } 00593 00594 if (tif->tif_tagmethods.printdir) 00595 (*tif->tif_tagmethods.printdir)(tif, fd, flags); 00596 if ((flags & TIFFPRINT_STRIPS) && 00597 TIFFFieldSet(tif,FIELD_STRIPOFFSETS)) { 00598 tstrip_t s; 00599 00600 fprintf(fd, " %lu %s:\n", 00601 (long) td->td_nstrips, 00602 isTiled(tif) ? "Tiles" : "Strips"); 00603 for (s = 0; s < td->td_nstrips; s++) 00604 fprintf(fd, " %3lu: [%8lu, %8lu]\n", 00605 (unsigned long) s, 00606 (unsigned long) td->td_stripoffset[s], 00607 (unsigned long) td->td_stripbytecount[s]); 00608 } 00609 } 00610 00611 void 00612 _TIFFprintAscii(FILE* fd, const char* cp) 00613 { 00614 for (; *cp != '\0'; cp++) { 00615 const char* tp; 00616 00617 if (isprint((int)*cp)) { 00618 fputc(*cp, fd); 00619 continue; 00620 } 00621 for (tp = "\tt\bb\rr\nn\vv"; *tp; tp++) 00622 if (*tp++ == *cp) 00623 break; 00624 if (*tp) 00625 fprintf(fd, "\\%c", *tp); 00626 else 00627 fprintf(fd, "\\%03o", *cp & 0xff); 00628 } 00629 } 00630 00631 void 00632 _TIFFprintAsciiTag(FILE* fd, const char* name, const char* value) 00633 { 00634 fprintf(fd, " %s: \"", name); 00635 _TIFFprintAscii(fd, value); 00636 fprintf(fd, "\"\n"); 00637 } 00638 00639 /* vim: set ts=8 sts=8 sw=8 noet: */ 00640 /* 00641 * Local Variables: 00642 * mode: c 00643 * c-basic-offset: 8 00644 * fill-column: 78 00645 * End: 00646 */ Generated on Sun May 27 2012 04:19:35 for ReactOS by
1.7.6.1
|