📄 tiff_support.hpp
字号:
#ifndef __TIFF_Support_hpp__#define __TIFF_Support_hpp__ 1// =================================================================================================// ADOBE SYSTEMS INCORPORATED// Copyright 2006-2007 Adobe Systems Incorporated// All Rights Reserved//// NOTICE: Adobe permits you to use, modify, and distribute this file in accordance with the terms// of the Adobe license agreement accompanying it.// =================================================================================================#include "XMP_Environment.h" // ! This must be the first include.#include <map>#include "XMP_Const.h"#include "XMPFiles_Impl.hpp"#include "EndianUtils.hpp"// =================================================================================================/// \file TIFF_Support.hpp/// \brief XMPFiles support for TIFF streams.////// This header provides TIFF stream support specific to the needs of XMPFiles. This is not intended/// for general purpose TIFF processing. TIFF_Manager is an abstract base class with 2 concrete/// derived classes, TIFF_MemoryReader and TIFF_FileWriter.////// TIFF_MemoryReader provides read-only support for TIFF streams that are small enough to be kept/// entirely in memory. This allows optimizations to reduce heap usage and processing code. It is/// sufficient for browsing access to the Exif metadata in JPEG and Photoshop files. Think of/// TIFF_MemoryReader as "memory-based AND read-only". Since the entire TIFF stream is available,/// GetTag will return information about any tag in the stream.////// TIFF_FileWriter is for cases where updates are needed or the TIFF stream is too large to be kept/// entirely in memory. Think of TIFF_FileWriter as "file-based OR read-write". TIFF_FileWriter only/// maintains information for tags of interest as metadata.////// The needs of XMPFiles are well defined metadata access. Only 5 IFDs are recognized:/// \li The 0th IFD, for the primary image, the first one in the outer list of IFDs./// \li The 1st IFD, for an Exif thumbnail, the second one in the outer list of IFDs./// \li The Exif general metadata IFD, from tag 34665 in the primary image IFD./// \li The Exif GPS Info metadata IFD, from tag 34853 in the primary image IFD./// \li The Exif Interoperability IFD, from tag 40965 in the Exif general metadata IFD.////// \note In the future we should add support for the non-Exif thumbnails in DNG (TIFF/EP) files.////// \note These classes are for use only when directly compiled and linked. They should not be/// packaged in a DLL by themselves. They do not provide any form of C++ ABI protection.// =================================================================================================// =================================================================================================// TIFF IFD and type constants// ===========================//// These aren't inside TIFF_Manager because static data members can't be initialized there.enum { // Constants for the recognized IFDs. kTIFF_PrimaryIFD = 0, // The primary image IFD, also called the 0th IFD. kTIFF_TNailIFD = 1, // The thumbnail image IFD also called the 1st IFD. kTIFF_ExifIFD = 2, // The Exif general metadata IFD. kTIFF_GPSInfoIFD = 3, // The Exif GPS Info IFD. kTIFF_InteropIFD = 4, // The Exif Interoperability IFD. kTIFF_LastRealIFD = 4, kTIFF_KnownIFDCount = 5, kTIFF_KnownIFD = 9 // The IFD that a tag is known to belong in.};enum { // Constants for the type field of a tag, as defined by TIFF. kTIFF_ShortOrLongType = 0, // ! Not part of the TIFF spec, never in a tag! kTIFF_ByteType = 1, kTIFF_ASCIIType = 2, kTIFF_ShortType = 3, kTIFF_LongType = 4, kTIFF_RationalType = 5, kTIFF_SByteType = 6, kTIFF_UndefinedType = 7, kTIFF_SShortType = 8, kTIFF_SLongType = 9, kTIFF_SRationalType = 10, kTIFF_FloatType = 11, kTIFF_DoubleType = 12, kTIFF_LastType = 12};static const size_t kTIFF_TypeSizes[] = { 0, 1, 1, 2, 4, 8, 1, 1, 2, 4, 8, 4, 8 };static const char * kTIFF_TypeNames[] = { "ShortOrLong", "BYTE", "ASCII", "SHORT", "LONG", "RATIONAL", "SBYTE", "UNDEFINED", "SSHORT", "SLONG", "SRATIONAL", "FLOAT", "DOUBLE" };enum { // Encodings for SetTag_EncodedString. kTIFF_EncodeUndefined = 0, kTIFF_EncodeASCII = 1, kTIFF_EncodeUnicode = 2, // UTF-16 in the endianness of the TIFF stream. kTIFF_EncodeJIS = 3, // Exif 2.2 uses JIS X 208-1990. kTIFF_EncodeUnknown = 9};// =================================================================================================// Recognized TIFF tags// ====================// ---------------------------------------------------------------------------// An enum of IDs for all of the tags as potential interest as metadata.enum { // General 0th IFD tags. Some of these can also be in the thumbnail IFD. kTIFF_ImageWidth = 256, kTIFF_ImageLength = 257, kTIFF_BitsPerSample = 258, kTIFF_Compression = 259, kTIFF_PhotometricInterpretation = 262, kTIFF_ImageDescription = 270, kTIFF_Make = 271, kTIFF_Model = 272, kTIFF_Orientation = 274, kTIFF_SamplesPerPixel = 277, kTIFF_XResolution = 282, kTIFF_YResolution = 283, kTIFF_PlanarConfiguration = 284, kTIFF_ResolutionUnit = 296, kTIFF_TransferFunction = 301, kTIFF_Software = 305, kTIFF_DateTime = 306, kTIFF_Artist = 315, kTIFF_WhitePoint = 318, kTIFF_PrimaryChromaticities = 319, kTIFF_YCbCrCoefficients = 529, kTIFF_YCbCrSubSampling = 530, kTIFF_YCbCrPositioning = 531, kTIFF_ReferenceBlackWhite = 532, kTIFF_XMP = 700, kTIFF_Copyright = 33432, kTIFF_IPTC = 33723, kTIFF_PSIR = 34377, kTIFF_ExifIFDPointer = 34665, kTIFF_GPSInfoIFDPointer = 34853, // Additional thumbnail IFD tags. We also care about 256, 257, and 259 in thumbnails. kTIFF_JPEGInterchangeFormat = 513, kTIFF_JPEGInterchangeFormatLength = 514, // Additional tags that need special handling when rewriting memory-based TIFF. kTIFF_StripOffsets = 273, kTIFF_StripByteCounts = 279, kTIFF_FreeOffsets = 288, kTIFF_FreeByteCounts = 289, kTIFF_TileOffsets = 324, kTIFF_TileByteCounts = 325, kTIFF_SubIFDs = 330, kTIFF_JPEGQTables = 519, kTIFF_JPEGDCTables = 520, kTIFF_JPEGACTables = 521, // Exif IFD tags. kTIFF_ExposureTime = 33434, kTIFF_FNumber = 33437, kTIFF_ExposureProgram = 34850, kTIFF_SpectralSensitivity = 34852, kTIFF_ISOSpeedRatings = 34855, kTIFF_OECF = 34856, kTIFF_ExifVersion = 36864, kTIFF_DateTimeOriginal = 36867, kTIFF_DateTimeDigitized = 36868, kTIFF_ComponentsConfiguration = 37121, kTIFF_CompressedBitsPerPixel = 37122, kTIFF_ShutterSpeedValue = 37377, kTIFF_ApertureValue = 37378, kTIFF_BrightnessValue = 37379, kTIFF_ExposureBiasValue = 37380, kTIFF_MaxApertureValue = 37381, kTIFF_SubjectDistance = 37382, kTIFF_MeteringMode = 37383, kTIFF_LightSource = 37384, kTIFF_Flash = 37385, kTIFF_FocalLength = 37386, kTIFF_SubjectArea = 37396, kTIFF_UserComment = 37510, kTIFF_SubSecTime = 37520, kTIFF_SubSecTimeOriginal = 37521, kTIFF_SubSecTimeDigitized = 37522, kTIFF_FlashpixVersion = 40960, kTIFF_ColorSpace = 40961, kTIFF_PixelXDimension = 40962, kTIFF_PixelYDimension = 40963, kTIFF_RelatedSoundFile = 40964, kTIFF_InteroperabilityIFDPointer = 40965, kTIFF_FlashEnergy = 41483, kTIFF_SpatialFrequencyResponse = 41484, kTIFF_FocalPlaneXResolution = 41486, kTIFF_FocalPlaneYResolution = 41487, kTIFF_FocalPlaneResolutionUnit = 41488, kTIFF_SubjectLocation = 41492, kTIFF_ExposureIndex = 41493, kTIFF_SensingMethod = 41495, kTIFF_FileSource = 41728, kTIFF_SceneType = 41729, kTIFF_CFAPattern = 41730, kTIFF_CustomRendered = 41985, kTIFF_ExposureMode = 41986, kTIFF_WhiteBalance = 41987, kTIFF_DigitalZoomRatio = 41988, kTIFF_FocalLengthIn35mmFilm = 41989, kTIFF_SceneCaptureType = 41990, kTIFF_GainControl = 41991, kTIFF_Contrast = 41992, kTIFF_Saturation = 41993, kTIFF_Sharpness = 41994, kTIFF_DeviceSettingDescription = 41995, kTIFF_SubjectDistanceRange = 41996, kTIFF_ImageUniqueID = 42016, kTIFF_MakerNote = 37500, // Gets deleted when rewriting memory-based TIFF. // GPS IFD tags. kTIFF_GPSVersionID = 0, kTIFF_GPSLatitudeRef = 1, kTIFF_GPSLatitude = 2, kTIFF_GPSLongitudeRef = 3, kTIFF_GPSLongitude = 4, kTIFF_GPSAltitudeRef = 5, kTIFF_GPSAltitude = 6, kTIFF_GPSTimeStamp = 7, kTIFF_GPSSatellites = 8, kTIFF_GPSStatus = 9, kTIFF_GPSMeasureMode = 10, kTIFF_GPSDOP = 11, kTIFF_GPSSpeedRef = 12, kTIFF_GPSSpeed = 13, kTIFF_GPSTrackRef = 14, kTIFF_GPSTrack = 15, kTIFF_GPSImgDirectionRef = 16, kTIFF_GPSImgDirection = 17, kTIFF_GPSMapDatum = 18, kTIFF_GPSDestLatitudeRef = 19, kTIFF_GPSDestLatitude = 20, kTIFF_GPSDestLongitudeRef = 21, kTIFF_GPSDestLongitude = 22, kTIFF_GPSDestBearingRef = 23, kTIFF_GPSDestBearing = 24, kTIFF_GPSDestDistanceRef = 25, kTIFF_GPSDestDistance = 26, kTIFF_GPSProcessingMethod = 27, kTIFF_GPSAreaInformation = 28, kTIFF_GPSDateStamp = 29, kTIFF_GPSDifferential = 30 };// ------------------------------------------------------------------// Sorted arrays of the tags that are recognized in the various IFDs.static const XMP_Uns16 sKnownPrimaryIFDTags[] ={ kTIFF_ImageWidth, // 256 kTIFF_ImageLength, // 257 kTIFF_BitsPerSample, // 258 kTIFF_Compression, // 259 kTIFF_PhotometricInterpretation, // 262 kTIFF_ImageDescription, // 270 kTIFF_Make, // 271 kTIFF_Model, // 272 kTIFF_Orientation, // 274 kTIFF_SamplesPerPixel, // 277 kTIFF_XResolution, // 282 kTIFF_YResolution, // 283 kTIFF_PlanarConfiguration, // 284 kTIFF_ResolutionUnit, // 296 kTIFF_TransferFunction, // 301 kTIFF_Software, // 305 kTIFF_DateTime, // 306 kTIFF_Artist, // 315 kTIFF_WhitePoint, // 318 kTIFF_PrimaryChromaticities, // 319 kTIFF_YCbCrCoefficients, // 529 kTIFF_YCbCrSubSampling, // 530 kTIFF_YCbCrPositioning, // 531 kTIFF_ReferenceBlackWhite, // 532 kTIFF_XMP, // 700 kTIFF_Copyright, // 33432 kTIFF_IPTC, // 33723 kTIFF_PSIR, // 34377 kTIFF_ExifIFDPointer, // 34665 kTIFF_GPSInfoIFDPointer, // 34853 0xFFFF // Must be last as a sentinel.};static const XMP_Uns16 sKnownThumbnailIFDTags[] ={ kTIFF_ImageWidth, // 256
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -