22
22
@file tiffvisitor.hpp
23
@brief Operations on a TIFF composite tree, implemented as visitor classes.
25
25
@author Andreas Huggel (ahu)
26
26
<a href="mailto:ahuggel@gmx.net">ahuggel@gmx.net</a>
27
27
@date 11-Apr-06, ahu: created
106
100
@brief Operation to perform for a TIFF directory, after all components
107
101
and before the next entry is processed.
109
virtual void visitDirectoryNext(TiffDirectory* object) {}
103
virtual void visitDirectoryNext(TiffDirectory* /*object*/) {}
111
105
@brief Operation to perform for a TIFF directory, at the end of the
114
virtual void visitDirectoryEnd(TiffDirectory* object) {}
108
virtual void visitDirectoryEnd(TiffDirectory* /*object*/) {}
115
109
//! Operation to perform for a TIFF sub-IFD
116
110
virtual void visitSubIfd(TiffSubIfd* object) =0;
117
111
//! Operation to perform for the makernote component
119
113
//! Operation to perform for an IFD makernote
120
114
virtual void visitIfdMakernote(TiffIfdMakernote* object) =0;
121
115
//! Operation to perform after processing an IFD makernote
122
virtual void visitIfdMakernoteEnd(TiffIfdMakernote* object) {}
116
virtual void visitIfdMakernoteEnd(TiffIfdMakernote* /*object*/) {}
123
117
//! Operation to perform for an array entry (as found in Canon makernotes)
124
118
virtual void visitArrayEntry(TiffArrayEntry* object) =0;
125
119
//! Operation to perform for an array element
196
190
TiffComponent* tiffComponent_;
197
191
}; // class TiffFinder
199
//! Function pointer type for a function to decode a TIFF component.
200
typedef void (TiffMetadataDecoder::*DecoderFct)(const TiffEntryBase*);
202
//! TIFF decoder table
203
struct TiffDecoderInfo {
206
@brief Compare a TiffDecoderInfo with a TiffDecoderInfo::Key.
207
The two are equal if TiffDecoderInfo::make_ equals a substring
208
of the key of the same size. E.g., decoder info = "OLYMPUS",
209
key = "OLYMPUS OPTICAL CO.,LTD" (found in the image) match,
210
the extendedTag is Tag::all or equal to the extended tag of the
211
key, and the group is equal to that of the key.
213
bool operator==(const Key& key) const;
214
//! Return the tag corresponding to the extended tag
215
uint16_t tag() const { return static_cast<uint16_t>(extendedTag_ & 0xffff); }
218
const char* make_; //!< Camera make for which this decoder function applies
219
uint32_t extendedTag_; //!< Tag (32 bit so that it can contain special tags)
220
uint16_t group_; //!< Group that contains the tag
221
DecoderFct decoderFct_; //!< Decoder function for matching tags
223
}; // struct TiffDecoderInfo
225
//! Search key for TIFF decoder structures.
226
struct TiffDecoderInfo::Key {
228
Key(const std::string& m, uint32_t e, uint16_t g) : m_(m), e_(e), g_(g) {}
229
std::string m_; //!< Camera make
230
uint32_t e_; //!< Extended tag
231
uint16_t g_; //!< %Group
235
194
@brief TIFF composite visitor to decode metadata from the TIFF tree and
236
195
add it to an Image, which is supplied in the constructor (Visitor
251
210
TiffMetadataDecoder(Image* pImage,
252
211
TiffComponent* const pRoot,
212
FindDecoderFct findDecoderFct =0,
253
213
uint32_t threshold =0);
254
214
//! Virtual destructor
255
215
virtual ~TiffMetadataDecoder() {}
276
236
//! Decode an array element
277
237
virtual void visitArrayElement(TiffArrayElement* object);
239
//! Entry function, determines how to decode each tag
240
void decodeTiffEntry(const TiffEntryBase* object);
279
241
//! Decode a standard TIFF entry
280
void decodeTiffEntry(const TiffEntryBase* object);
242
void decodeStdTiffEntry(const TiffEntryBase* object);
281
243
//! Decode Olympus Thumbnail from the TIFF makernote into IFD1
282
244
void decodeOlympThumb(const TiffEntryBase* object);
283
245
//! Decode SubIFD contents to Image group if it contains primary image data
294
256
Image* pImage_; //!< Pointer to the image to which the metadata is added
295
257
TiffComponent* const pRoot_; //!< Root element of the composite
258
const FindDecoderFct findDecoderFct_; //!< Ptr to the function to find special decoding functions
296
259
const uint32_t threshold_; //!< Threshold, see constructor documentation.
297
260
std::string make_; //!< Camera make, determined from the tags to decode
300
263
typedef std::map<uint16_t, uint32_t> GroupType;
301
264
GroupType groupType_; //!< NewSubfileType for each group
303
static const TiffDecoderInfo tiffDecoderInfo_[]; //<! TIFF decoder table
305
266
}; // class TiffMetadataDecoder
428
389
//! Return the base offset. See class TiffRwState for details
429
390
uint32_t baseOffset() const;
430
391
//! Create a TIFF component for \em extendedTag and group
431
TiffComponent::AutoPtr create(uint32_t extendedTag, uint16_t group) const;
392
std::auto_ptr<TiffComponent> create(uint32_t extendedTag,
393
uint16_t group) const;
397
//! @name Manipulators
399
//! Helper function to set the thumbnail data area
400
void setDataArea(TiffEntryBase* pOffsetEntry, const Value* pSize);