📄 tif_dirinfo.c
字号:
#ifdef COLORIMETRY_SUPPORT { TIFFTAG_REFERENCEBLACKWHITE,6,6,TIFF_RATIONAL, FIELD_REFBLACKWHITE, TRUE, FALSE, "ReferenceBlackWhite" },/* XXX temporarily accept LONG for backwards compatibility */ { TIFFTAG_REFERENCEBLACKWHITE,6,6,TIFF_LONG, FIELD_REFBLACKWHITE, TRUE, FALSE, "ReferenceBlackWhite" },#endif/* begin SGI tags */ { TIFFTAG_MATTEING, 1, 1, TIFF_SHORT, FIELD_EXTRASAMPLES, FALSE, FALSE, "Matteing" }, { TIFFTAG_DATATYPE, -2,-1, TIFF_SHORT, FIELD_SAMPLEFORMAT, FALSE, FALSE, "DataType" }, { TIFFTAG_IMAGEDEPTH, 1, 1, TIFF_LONG, FIELD_IMAGEDEPTH, FALSE, FALSE, "ImageDepth" }, { TIFFTAG_IMAGEDEPTH, 1, 1, TIFF_SHORT, FIELD_IMAGEDEPTH, FALSE, FALSE, "ImageDepth" }, { TIFFTAG_TILEDEPTH, 1, 1, TIFF_LONG, FIELD_TILEDEPTH, FALSE, FALSE, "TileDepth" }, { TIFFTAG_TILEDEPTH, 1, 1, TIFF_SHORT, FIELD_TILEDEPTH, FALSE, FALSE, "TileDepth" },/* end SGI tags *//* begin Pixar tags */ { TIFFTAG_PIXAR_IMAGEFULLWIDTH, 1, 1, TIFF_LONG, FIELD_IMAGEFULLWIDTH, TRUE, FALSE, "ImageFullWidth" }, { TIFFTAG_PIXAR_IMAGEFULLLENGTH, 1, 1, TIFF_LONG, FIELD_IMAGEFULLLENGTH, TRUE, FALSE, "ImageFullLength" }, { TIFFTAG_PIXAR_TEXTUREFORMAT, -1,-1, TIFF_ASCII, FIELD_TEXTUREFORMAT, TRUE, FALSE, "TextureFormat" }, { TIFFTAG_PIXAR_WRAPMODES, -1,-1, TIFF_ASCII, FIELD_WRAPMODES, TRUE, FALSE, "TextureWrapModes" }, { TIFFTAG_PIXAR_FOVCOT, 1, 1, TIFF_FLOAT, FIELD_FOVCOT, TRUE, FALSE, "FieldOfViewCotan" }, { TIFFTAG_PIXAR_MATRIX_WORLDTOSCREEN, 16,16, TIFF_FLOAT, FIELD_MATRIX_WORLDTOSCREEN, TRUE, FALSE, "MatrixWorldToScreen" }, { TIFFTAG_PIXAR_MATRIX_WORLDTOCAMERA, 16,16, TIFF_FLOAT, FIELD_MATRIX_WORLDTOCAMERA, TRUE, FALSE, "MatrixWorldToCamera" }, { TIFFTAG_COPYRIGHT, -1,-1, TIFF_ASCII, FIELD_COPYRIGHT, TRUE, FALSE, "Copyright" },/* end Pixar tags */#ifdef IPTC_SUPPORT#ifdef PHOTOSHOP_SUPPORT { TIFFTAG_RICHTIFFIPTC, -1,-1, TIFF_LONG, FIELD_RICHTIFFIPTC, FALSE, TRUE, "RichTIFFIPTC" },#else { TIFFTAG_RICHTIFFIPTC, -1,-3, TIFF_UNDEFINED, FIELD_RICHTIFFIPTC, FALSE, TRUE, "RichTIFFIPTC" },#endif#endif#ifdef PHOTOSHOP_SUPPORT { TIFFTAG_PHOTOSHOP, -1,-3, TIFF_BYTE, FIELD_PHOTOSHOP, FALSE, TRUE, "Photoshop" },#endif#ifdef ICC_SUPPORT { TIFFTAG_ICCPROFILE, -1,-3, TIFF_UNDEFINED, FIELD_ICCPROFILE, FALSE, TRUE, "ICC Profile" },#endif { TIFFTAG_STONITS, 1, 1, TIFF_DOUBLE, FIELD_STONITS, FALSE, FALSE, "StoNits" },};#define N(a) (sizeof (a) / sizeof (a[0]))void_TIFFSetupFieldInfo(TIFF* tif){ if (tif->tif_fieldinfo) { _TIFFfree(tif->tif_fieldinfo); tif->tif_nfields = 0; } _TIFFMergeFieldInfo(tif, tiffFieldInfo, N(tiffFieldInfo));}static inttagCompare(const void* a, const void* b){ const TIFFFieldInfo* ta = *(const TIFFFieldInfo**) a; const TIFFFieldInfo* tb = *(const TIFFFieldInfo**) b; /* NB: be careful of return values for 16-bit platforms */ if (ta->field_tag != tb->field_tag) return (ta->field_tag < tb->field_tag ? -1 : 1); else return (tb->field_type < ta->field_type ? -1 : 1);}void_TIFFMergeFieldInfo(TIFF* tif, const TIFFFieldInfo info[], int n){ TIFFFieldInfo** tp; int i; if (tif->tif_nfields > 0) { tif->tif_fieldinfo = (TIFFFieldInfo**) _TIFFrealloc(tif->tif_fieldinfo, (tif->tif_nfields+n) * sizeof (TIFFFieldInfo*)); } else { tif->tif_fieldinfo = (TIFFFieldInfo**) _TIFFmalloc(n * sizeof (TIFFFieldInfo*)); } tp = &tif->tif_fieldinfo[tif->tif_nfields]; for (i = 0; i < n; i++) tp[i] = (TIFFFieldInfo*) &info[i]; /* XXX */ /* * NB: the core tags are presumed sorted correctly. */ if (tif->tif_nfields > 0) qsort(tif->tif_fieldinfo, (size_t) (tif->tif_nfields += n), sizeof (TIFFFieldInfo*), tagCompare); else tif->tif_nfields += n;}void_TIFFPrintFieldInfo(TIFF* tif, FILE* fd){ int i; fprintf(fd, "%s: \n", tif->tif_name); for (i = 0; i < tif->tif_nfields; i++) { const TIFFFieldInfo* fip = tif->tif_fieldinfo[i]; fprintf(fd, "field[%2d] %5lu, %2d, %2d, %d, %2d, %5s, %5s, %s\n" , i , (unsigned long) fip->field_tag , fip->field_readcount, fip->field_writecount , fip->field_type , fip->field_bit , fip->field_oktochange ? "TRUE" : "FALSE" , fip->field_passcount ? "TRUE" : "FALSE" , fip->field_name ); }}const int tiffDataWidth[] = { 1, /* nothing */ 1, /* TIFF_BYTE */ 1, /* TIFF_ASCII */ 2, /* TIFF_SHORT */ 4, /* TIFF_LONG */ 8, /* TIFF_RATIONAL */ 1, /* TIFF_SBYTE */ 1, /* TIFF_UNDEFINED */ 2, /* TIFF_SSHORT */ 4, /* TIFF_SLONG */ 8, /* TIFF_SRATIONAL */ 4, /* TIFF_FLOAT */ 8, /* TIFF_DOUBLE */};/* * Return nearest TIFFDataType to the sample type of an image. */TIFFDataType_TIFFSampleToTagType(TIFF* tif){ int bps = (int) TIFFhowmany(tif->tif_dir.td_bitspersample, 8); switch (tif->tif_dir.td_sampleformat) { case SAMPLEFORMAT_IEEEFP: return (bps == 4 ? TIFF_FLOAT : TIFF_DOUBLE); case SAMPLEFORMAT_INT: return (bps <= 1 ? TIFF_SBYTE : bps <= 2 ? TIFF_SSHORT : TIFF_SLONG); case SAMPLEFORMAT_UINT: return (bps <= 1 ? TIFF_BYTE : bps <= 2 ? TIFF_SHORT : TIFF_LONG); case SAMPLEFORMAT_VOID: return (TIFF_UNDEFINED); } /*NOTREACHED*/ return (TIFF_UNDEFINED);}const TIFFFieldInfo*_TIFFFindFieldInfo(TIFF* tif, ttag_t tag, TIFFDataType dt){ static const TIFFFieldInfo *last = NULL; int i, n; if (last && last->field_tag == tag && (dt == TIFF_ANY || dt == last->field_type)) return (last); /* NB: if table gets big, use sorted search (e.g. binary search) */ for (i = 0, n = tif->tif_nfields; i < n; i++) { const TIFFFieldInfo* fip = tif->tif_fieldinfo[i]; if (fip->field_tag == tag && (dt == TIFF_ANY || fip->field_type == dt)) return (last = fip); } return ((const TIFFFieldInfo *)0);}#include <assert.h>#include <stdio.h>const TIFFFieldInfo*_TIFFFieldWithTag(TIFF* tif, ttag_t tag){ const TIFFFieldInfo* fip = _TIFFFindFieldInfo(tif, tag, TIFF_ANY); if (!fip) { TIFFError("TIFFFieldWithTag", "Internal error, unknown tag 0x%x", (u_int) tag); assert(fip != NULL); /*NOTREACHED*/ } return (fip);}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -