|
|
|
@ -50,7 +50,10 @@ namespace Exiv2 {
|
|
|
|
|
// class declarations
|
|
|
|
|
|
|
|
|
|
struct TiffStructure;
|
|
|
|
|
class TiffVisitor;
|
|
|
|
|
class TiffDirectory;
|
|
|
|
|
class TiffEntryBase;
|
|
|
|
|
class TiffEntry;
|
|
|
|
|
class TiffSubIfd;
|
|
|
|
|
|
|
|
|
|
// *****************************************************************************
|
|
|
|
|
// type definitions
|
|
|
|
@ -87,12 +90,187 @@ namespace Exiv2 {
|
|
|
|
|
const uint32_t next = 0x30000; //!< Special tag: next IFD
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/*!
|
|
|
|
|
@brief This class models a TIFF header structure.
|
|
|
|
|
*/
|
|
|
|
|
class TiffHeade2 {
|
|
|
|
|
public:
|
|
|
|
|
//! @name Creators
|
|
|
|
|
//@{
|
|
|
|
|
//! Default constructor
|
|
|
|
|
TiffHeade2()
|
|
|
|
|
: byteOrder_ (littleEndian),
|
|
|
|
|
offset_ (0x00000008)
|
|
|
|
|
{}
|
|
|
|
|
//@}
|
|
|
|
|
|
|
|
|
|
//! @name Manipulators
|
|
|
|
|
//@{
|
|
|
|
|
/*!
|
|
|
|
|
@brief Read the TIFF header from a data buffer. Return false if the
|
|
|
|
|
data buffer does not contain a TIFF header, else true.
|
|
|
|
|
|
|
|
|
|
@param pData Pointer to the data buffer.
|
|
|
|
|
@param size Number of bytes in the data buffer.
|
|
|
|
|
*/
|
|
|
|
|
bool read(const byte* pData, uint32_t size);
|
|
|
|
|
//@}
|
|
|
|
|
|
|
|
|
|
//! @name Accessors
|
|
|
|
|
//@{
|
|
|
|
|
/*!
|
|
|
|
|
@brief Write the TIFF header to the binary image \em blob.
|
|
|
|
|
This method appends to the blob.
|
|
|
|
|
|
|
|
|
|
@param blob Binary image to add to.
|
|
|
|
|
|
|
|
|
|
@throw Error If the header cannot be written.
|
|
|
|
|
*/
|
|
|
|
|
void write(Blob& blob) const;
|
|
|
|
|
/*!
|
|
|
|
|
@brief Print debug info for the TIFF header to \em os.
|
|
|
|
|
|
|
|
|
|
@param os Output stream to write to.
|
|
|
|
|
@param prefix Prefix to be written before each line of output.
|
|
|
|
|
*/
|
|
|
|
|
void print(std::ostream& os, const std::string& prefix ="") const;
|
|
|
|
|
//! Return the byte order (little or big endian).
|
|
|
|
|
ByteOrder byteOrder() const { return byteOrder_; }
|
|
|
|
|
//! Return the offset to the start of the root directory
|
|
|
|
|
uint32_t offset() const { return offset_; }
|
|
|
|
|
//@}
|
|
|
|
|
|
|
|
|
|
private:
|
|
|
|
|
// DATA
|
|
|
|
|
ByteOrder byteOrder_; //!< Applicable byte order
|
|
|
|
|
uint32_t offset_; //!< Offset to the start of the root dir
|
|
|
|
|
|
|
|
|
|
static const uint16_t tag_; //!< 42, identifies the buffer as TIFF data
|
|
|
|
|
|
|
|
|
|
}; // class TiffHeade2
|
|
|
|
|
|
|
|
|
|
/*!
|
|
|
|
|
@brief Abstract base class for TIFF composite vistors (Visitor pattern)
|
|
|
|
|
|
|
|
|
|
A concrete visitor class is used as shown in the example below. Accept()
|
|
|
|
|
will invoke the member function corresponding to the concrete type of each
|
|
|
|
|
component in the composite.
|
|
|
|
|
|
|
|
|
|
@code
|
|
|
|
|
void visitorExample(Exiv2::TiffComponent* tiffComponent, Exiv2::TiffVisitor& visitor)
|
|
|
|
|
{
|
|
|
|
|
tiffComponent->accept(visitor);
|
|
|
|
|
}
|
|
|
|
|
@endcode
|
|
|
|
|
*/
|
|
|
|
|
class TiffVisitor {
|
|
|
|
|
public:
|
|
|
|
|
//! @name Creators
|
|
|
|
|
//@{
|
|
|
|
|
virtual ~TiffVisitor() {}
|
|
|
|
|
//@}
|
|
|
|
|
|
|
|
|
|
//! @name Manipulators
|
|
|
|
|
//@{
|
|
|
|
|
//! Operation to perform for a TIFF entry
|
|
|
|
|
virtual void visitEntry(TiffEntry* object) =0;
|
|
|
|
|
//! Operation to perform for a TIFF directory
|
|
|
|
|
virtual void visitDirectory(TiffDirectory* object) =0;
|
|
|
|
|
//! Operation to perform for a TIFF sub-IFD
|
|
|
|
|
virtual void visitSubIfd(TiffSubIfd* object) =0;
|
|
|
|
|
//@}
|
|
|
|
|
|
|
|
|
|
}; // class TiffVisitor
|
|
|
|
|
|
|
|
|
|
/*!
|
|
|
|
|
@brief TIFF composite visitor to decode metadata from the TIFF tree and
|
|
|
|
|
add it to an Image, which is supplied in the constructor (Visitor
|
|
|
|
|
pattern). Used by TiffParser to decode the metadata from a
|
|
|
|
|
TIFF composite.
|
|
|
|
|
*/
|
|
|
|
|
class TiffMetadataDecoder : public TiffVisitor {
|
|
|
|
|
public:
|
|
|
|
|
//! @name Creators
|
|
|
|
|
//@{
|
|
|
|
|
//! Constructor, taking the image to add the metadata to
|
|
|
|
|
TiffMetadataDecoder(Image* pImage) : pImage_(pImage) {}
|
|
|
|
|
//! Virtual destructor
|
|
|
|
|
virtual ~TiffMetadataDecoder() {}
|
|
|
|
|
//@}
|
|
|
|
|
|
|
|
|
|
//! @name Manipulators
|
|
|
|
|
//@{
|
|
|
|
|
//! Decode a TIFF entry
|
|
|
|
|
virtual void visitEntry(TiffEntry* object);
|
|
|
|
|
//! Decode a TIFF directory
|
|
|
|
|
virtual void visitDirectory(TiffDirectory* object);
|
|
|
|
|
//! Decode a TIFF sub-IFD
|
|
|
|
|
virtual void visitSubIfd(TiffSubIfd* object);
|
|
|
|
|
//! Decode a standard TIFF entry
|
|
|
|
|
void decodeTiffEntry(const TiffEntryBase* object);
|
|
|
|
|
//@}
|
|
|
|
|
|
|
|
|
|
private:
|
|
|
|
|
// DATA
|
|
|
|
|
Image* pImage_; //!< Pointer to the image to which the metadata is added
|
|
|
|
|
|
|
|
|
|
}; // class TiffMetadataDecoder
|
|
|
|
|
|
|
|
|
|
/*!
|
|
|
|
|
@brief TIFF composite visitor to read the TIFF structure from a block of
|
|
|
|
|
memory and build the composite from it (Visitor pattern). Used by
|
|
|
|
|
TiffParser to read the TIFF data from a block of memory.
|
|
|
|
|
*/
|
|
|
|
|
class TiffReader : public TiffVisitor {
|
|
|
|
|
public:
|
|
|
|
|
//! @name Creators
|
|
|
|
|
//@{
|
|
|
|
|
/*!
|
|
|
|
|
@brief Constructor. The data buffer and table describing the TIFF
|
|
|
|
|
structure of the data are set in the constructor.
|
|
|
|
|
@param pData Pointer to the data buffer, starting with a TIFF header.
|
|
|
|
|
@param size Number of bytes in the data buffer.
|
|
|
|
|
@param byteOrder Applicable byte order (little or big endian).
|
|
|
|
|
@param pTiffStructure Pointer to a table describing the TIFF structure
|
|
|
|
|
used to decode the data.
|
|
|
|
|
*/
|
|
|
|
|
TiffReader(const byte* pData,
|
|
|
|
|
uint32_t size,
|
|
|
|
|
ByteOrder byteOrder,
|
|
|
|
|
const TiffStructure* pTiffStructure);
|
|
|
|
|
|
|
|
|
|
//! Virtual destructor
|
|
|
|
|
virtual ~TiffReader() {}
|
|
|
|
|
//@}
|
|
|
|
|
|
|
|
|
|
//! @name Manipulators
|
|
|
|
|
//@{
|
|
|
|
|
//! Read a TIFF entry from the data buffer
|
|
|
|
|
virtual void visitEntry(TiffEntry* object);
|
|
|
|
|
//! Read a TIFF directory from the data buffer
|
|
|
|
|
virtual void visitDirectory(TiffDirectory* object);
|
|
|
|
|
//! Read a TIFF sub-IFD from the data buffer
|
|
|
|
|
virtual void visitSubIfd(TiffSubIfd* object);
|
|
|
|
|
//! Read a standard TIFF entry from the data buffer
|
|
|
|
|
void readTiffEntry(TiffEntryBase* object);
|
|
|
|
|
//@}
|
|
|
|
|
|
|
|
|
|
private:
|
|
|
|
|
// DATA
|
|
|
|
|
const byte* pData_; //!< Pointer to the memory buffer
|
|
|
|
|
const uint32_t size_; //!< Size of the buffer
|
|
|
|
|
const byte* pLast_; //!< Pointer to the last byte
|
|
|
|
|
const ByteOrder byteOrder_; //!< Byteorder for the image
|
|
|
|
|
const TiffStructure* pTiffStructure_; //!< Pointer to the TIFF structure
|
|
|
|
|
|
|
|
|
|
}; // class TiffReader
|
|
|
|
|
|
|
|
|
|
/*!
|
|
|
|
|
@brief Interface class for components of a TIFF directory hierarchy
|
|
|
|
|
(Composite pattern). Both TIFF directories as well as entries
|
|
|
|
|
implement this interface. A component can be un iquely identified
|
|
|
|
|
bya tag, group tupel. This class is implemented as a NVI
|
|
|
|
|
(Non-Virtual Interface). It has an interface for visitors (Visitor
|
|
|
|
|
by a tag, group tupel. This class is implemented as a NVI
|
|
|
|
|
(Non-Virtual Interface) and it has an interface for visitors (Visitor
|
|
|
|
|
pattern).
|
|
|
|
|
*/
|
|
|
|
|
class TiffComponent {
|
|
|
|
@ -105,10 +283,8 @@ namespace Exiv2 {
|
|
|
|
|
//! @name Creators
|
|
|
|
|
//@{
|
|
|
|
|
//! Constructor
|
|
|
|
|
TiffComponent(uint16_t tag,
|
|
|
|
|
uint16_t group,
|
|
|
|
|
const TiffStructure* pTiffStructure)
|
|
|
|
|
: tag_(tag), group_(group), pTiffStructure_(pTiffStructure) {}
|
|
|
|
|
TiffComponent(uint16_t tag, uint16_t group)
|
|
|
|
|
: tag_(tag), group_(group), pData_(0) {}
|
|
|
|
|
|
|
|
|
|
//! Virtual destructor.
|
|
|
|
|
virtual ~TiffComponent() {}
|
|
|
|
@ -116,20 +292,22 @@ namespace Exiv2 {
|
|
|
|
|
|
|
|
|
|
//! @name Manipulators
|
|
|
|
|
//@{
|
|
|
|
|
//! Add a child to the component. Default is to do nothing.
|
|
|
|
|
void addChild(AutoPtr tiffComponent);
|
|
|
|
|
//! Add a "next" component to the component. Default is to do nothing.
|
|
|
|
|
void addNext(AutoPtr tiffComponent);
|
|
|
|
|
/*!
|
|
|
|
|
@brief Read a component from a data buffer
|
|
|
|
|
|
|
|
|
|
@param pData Pointer to the data buffer, starting with a TIFF header.
|
|
|
|
|
@param size Number of bytes in the data buffer.
|
|
|
|
|
@param start Component starts at \em pData + \em start.
|
|
|
|
|
@param byteOrder Applicable byte order (little or big endian).
|
|
|
|
|
@brief Interface to accept visitors (Visitor pattern).
|
|
|
|
|
|
|
|
|
|
@throw Error If the component cannot be parsed.
|
|
|
|
|
@param visitor The visitor.
|
|
|
|
|
*/
|
|
|
|
|
void read(const byte* pData,
|
|
|
|
|
uint32_t size,
|
|
|
|
|
uint32_t start,
|
|
|
|
|
ByteOrder byteOrder);
|
|
|
|
|
void accept(TiffVisitor& visitor);
|
|
|
|
|
/*!
|
|
|
|
|
@brief Set a pointer to the start of the binary representation of the
|
|
|
|
|
component in a memory buffer. The buffer must be allocated and
|
|
|
|
|
freed outside of this class.
|
|
|
|
|
*/
|
|
|
|
|
void setStart(const byte* pData) { pData_ = const_cast<byte*>(pData); }
|
|
|
|
|
//@}
|
|
|
|
|
|
|
|
|
|
//! @name Accessors
|
|
|
|
@ -138,8 +316,8 @@ namespace Exiv2 {
|
|
|
|
|
uint16_t tag() const { return tag_; }
|
|
|
|
|
//! Return the group id of this component
|
|
|
|
|
uint16_t group() const { return group_; }
|
|
|
|
|
//! Return the TIFF structure
|
|
|
|
|
const TiffStructure* pTiffStructure() const { return pTiffStructure_; }
|
|
|
|
|
//! Return a pointer to the start of the binary representation of the component
|
|
|
|
|
const byte* start() const { return pData_; }
|
|
|
|
|
/*!
|
|
|
|
|
@brief Print debug info about a component to \em os.
|
|
|
|
|
|
|
|
|
@ -150,22 +328,19 @@ namespace Exiv2 {
|
|
|
|
|
void print(std::ostream& os,
|
|
|
|
|
ByteOrder byteOrder,
|
|
|
|
|
const std::string& prefix ="") const;
|
|
|
|
|
/*!
|
|
|
|
|
@brief Interface to accept visitors (Visitor pattern).
|
|
|
|
|
|
|
|
|
|
@param visitor The visitor.
|
|
|
|
|
*/
|
|
|
|
|
void accept(TiffVisitor& visitor) const;
|
|
|
|
|
//@}
|
|
|
|
|
|
|
|
|
|
protected:
|
|
|
|
|
//! @name Manipulators
|
|
|
|
|
//@{
|
|
|
|
|
//! Implements read().
|
|
|
|
|
virtual void doRead(const byte* pData,
|
|
|
|
|
uint32_t size,
|
|
|
|
|
uint32_t start,
|
|
|
|
|
ByteOrder byteOrder) =0;
|
|
|
|
|
//! Implements addChild().
|
|
|
|
|
virtual void doAddChild(AutoPtr tiffComponent) {}
|
|
|
|
|
|
|
|
|
|
//! Implements addNext().
|
|
|
|
|
virtual void doAddNext(AutoPtr tiffComponent) {}
|
|
|
|
|
|
|
|
|
|
//! Implements accept()
|
|
|
|
|
virtual void doAccept(TiffVisitor& visitor) =0;
|
|
|
|
|
//@}
|
|
|
|
|
|
|
|
|
|
//! @name Accessors
|
|
|
|
@ -174,31 +349,34 @@ namespace Exiv2 {
|
|
|
|
|
virtual void doPrint(std::ostream& os,
|
|
|
|
|
ByteOrder byteOrder,
|
|
|
|
|
const std::string& prefix) const =0;
|
|
|
|
|
|
|
|
|
|
//! Implements accept()
|
|
|
|
|
virtual void doAccept(TiffVisitor& visitor) const =0;
|
|
|
|
|
//@}
|
|
|
|
|
|
|
|
|
|
private:
|
|
|
|
|
// DATA
|
|
|
|
|
uint16_t tag_; //!< Tag that identifies the component
|
|
|
|
|
uint16_t group_; //!< Group id for this component
|
|
|
|
|
const TiffStructure* pTiffStructure_; //!< TIFF structure for this component
|
|
|
|
|
/*!
|
|
|
|
|
Pointer to the start of the binary representation of the component in
|
|
|
|
|
a memory buffer. The buffer is allocated and freed outside of this class.
|
|
|
|
|
*/
|
|
|
|
|
byte* pData_;
|
|
|
|
|
|
|
|
|
|
}; // class TiffComponent
|
|
|
|
|
|
|
|
|
|
/*!
|
|
|
|
|
@brief This baseclass provides the common functionality of an IFD
|
|
|
|
|
directory entry and defines the interface for derived concrete
|
|
|
|
|
entries.
|
|
|
|
|
@brief This abstract base class provides the common functionality of an
|
|
|
|
|
IFD directory entry and defines an extended interface for derived
|
|
|
|
|
concrete entries, which allows access to the attributes of the
|
|
|
|
|
entry.
|
|
|
|
|
*/
|
|
|
|
|
class TiffEntryBase : public TiffComponent {
|
|
|
|
|
friend void TiffReader::readTiffEntry(TiffEntryBase* object);
|
|
|
|
|
public:
|
|
|
|
|
//! @name Creators
|
|
|
|
|
//@{
|
|
|
|
|
//! Default constructor
|
|
|
|
|
TiffEntryBase(uint16_t tag, uint16_t group)
|
|
|
|
|
: TiffComponent(tag, group, 0),
|
|
|
|
|
: TiffComponent(tag, group),
|
|
|
|
|
type_(0), count_(0), offset_(0),
|
|
|
|
|
size_(0), pData_(0), isAllocated_(false), pValue_(0) {}
|
|
|
|
|
//! Virtual destructor.
|
|
|
|
@ -226,15 +404,6 @@ namespace Exiv2 {
|
|
|
|
|
const std::string& prefix) const;
|
|
|
|
|
//@}
|
|
|
|
|
|
|
|
|
|
//! @name Manipulators
|
|
|
|
|
//@{
|
|
|
|
|
//! Read base entry
|
|
|
|
|
void readEntry(const byte* pData,
|
|
|
|
|
uint32_t size,
|
|
|
|
|
uint32_t start,
|
|
|
|
|
ByteOrder byteOrder);
|
|
|
|
|
//@}
|
|
|
|
|
|
|
|
|
|
private:
|
|
|
|
|
// DATA
|
|
|
|
|
uint16_t type_; //!< Field Type
|
|
|
|
@ -252,7 +421,7 @@ namespace Exiv2 {
|
|
|
|
|
}; // class TiffEntryBase
|
|
|
|
|
|
|
|
|
|
/*!
|
|
|
|
|
@brief A standard TIFF IFD entry. The value is kept in a data buffer.
|
|
|
|
|
@brief A standard TIFF IFD entry.
|
|
|
|
|
*/
|
|
|
|
|
class TiffEntry : public TiffEntryBase {
|
|
|
|
|
public:
|
|
|
|
@ -267,11 +436,7 @@ namespace Exiv2 {
|
|
|
|
|
private:
|
|
|
|
|
//! @name Manipulators
|
|
|
|
|
//@{
|
|
|
|
|
//! Implements read().
|
|
|
|
|
virtual void doRead(const byte* pData,
|
|
|
|
|
uint32_t size,
|
|
|
|
|
uint32_t start,
|
|
|
|
|
ByteOrder byteOrder);
|
|
|
|
|
virtual void doAccept(TiffVisitor& visitor);
|
|
|
|
|
//@}
|
|
|
|
|
|
|
|
|
|
//! @name Accessors
|
|
|
|
@ -279,19 +444,21 @@ namespace Exiv2 {
|
|
|
|
|
virtual void doPrint(std::ostream& os,
|
|
|
|
|
ByteOrder byteOrder,
|
|
|
|
|
const std::string& prefix) const;
|
|
|
|
|
virtual void doAccept(TiffVisitor& visitor) const;
|
|
|
|
|
//@}
|
|
|
|
|
|
|
|
|
|
}; // class TiffEntry
|
|
|
|
|
|
|
|
|
|
//! This class models a TIFF directory (%Ifd).
|
|
|
|
|
/*!
|
|
|
|
|
@brief This class models a TIFF directory (%Ifd). It is a composite
|
|
|
|
|
component of the TIFF tree.
|
|
|
|
|
*/
|
|
|
|
|
class TiffDirectory : public TiffComponent {
|
|
|
|
|
public:
|
|
|
|
|
//! @name Creators
|
|
|
|
|
//@{
|
|
|
|
|
//! Default constructor
|
|
|
|
|
TiffDirectory(uint16_t tag, uint16_t group, const TiffStructure* pTiffStructure)
|
|
|
|
|
: TiffComponent(tag, group, pTiffStructure), pNext_(0) {}
|
|
|
|
|
TiffDirectory(uint16_t tag, uint16_t group)
|
|
|
|
|
: TiffComponent(tag, group), pNext_(0) {}
|
|
|
|
|
//! Virtual destructor
|
|
|
|
|
virtual ~TiffDirectory();
|
|
|
|
|
//@}
|
|
|
|
@ -299,10 +466,11 @@ namespace Exiv2 {
|
|
|
|
|
private:
|
|
|
|
|
//! @name Manipulators
|
|
|
|
|
//@{
|
|
|
|
|
virtual void doRead(const byte* pData,
|
|
|
|
|
uint32_t size,
|
|
|
|
|
uint32_t start,
|
|
|
|
|
ByteOrder byteOrder);
|
|
|
|
|
virtual void doAddChild(TiffComponent::AutoPtr tiffComponent);
|
|
|
|
|
|
|
|
|
|
virtual void doAddNext(TiffComponent::AutoPtr tiffComponent);
|
|
|
|
|
|
|
|
|
|
virtual void doAccept(TiffVisitor& visitor);
|
|
|
|
|
//@}
|
|
|
|
|
|
|
|
|
|
//! @name Accessors
|
|
|
|
@ -310,8 +478,6 @@ namespace Exiv2 {
|
|
|
|
|
virtual void doPrint(std::ostream& os,
|
|
|
|
|
ByteOrder byteOrder,
|
|
|
|
|
const std::string& prefix) const;
|
|
|
|
|
|
|
|
|
|
virtual void doAccept(TiffVisitor& visitor) const;
|
|
|
|
|
//@}
|
|
|
|
|
|
|
|
|
|
private:
|
|
|
|
@ -321,17 +487,21 @@ namespace Exiv2 {
|
|
|
|
|
|
|
|
|
|
}; // class TiffDirectory
|
|
|
|
|
|
|
|
|
|
//! This class models a TIFF sub-directory (%SubIfd).
|
|
|
|
|
/*!
|
|
|
|
|
@brief This class models a TIFF sub-directory (sub-IFD). A sub-IFD
|
|
|
|
|
is an entry with a value that is a pointer to an IFD
|
|
|
|
|
structure and contains this IFD. The TIFF standard defines
|
|
|
|
|
some important tags to be sub-IFDs, including the %Exif and
|
|
|
|
|
GPS tags.
|
|
|
|
|
*/
|
|
|
|
|
class TiffSubIfd : public TiffEntryBase {
|
|
|
|
|
friend void TiffReader::visitSubIfd(TiffSubIfd* object);
|
|
|
|
|
public:
|
|
|
|
|
//! @name Creators
|
|
|
|
|
//@{
|
|
|
|
|
//! Default constructor
|
|
|
|
|
TiffSubIfd(uint16_t tag,
|
|
|
|
|
uint16_t group,
|
|
|
|
|
uint16_t newGroup,
|
|
|
|
|
const TiffStructure* pTiffStructure)
|
|
|
|
|
: TiffEntryBase(tag, group), ifd_(tag, newGroup, pTiffStructure) {}
|
|
|
|
|
TiffSubIfd(uint16_t tag, uint16_t group, uint16_t newGroup)
|
|
|
|
|
: TiffEntryBase(tag, group), ifd_(tag, newGroup) {}
|
|
|
|
|
//! Virtual destructor
|
|
|
|
|
virtual ~TiffSubIfd() {}
|
|
|
|
|
//@}
|
|
|
|
@ -339,10 +509,11 @@ namespace Exiv2 {
|
|
|
|
|
private:
|
|
|
|
|
//! @name Manipulators
|
|
|
|
|
//@{
|
|
|
|
|
virtual void doRead(const byte* pData,
|
|
|
|
|
uint32_t size,
|
|
|
|
|
uint32_t start,
|
|
|
|
|
ByteOrder byteOrder);
|
|
|
|
|
virtual void doAddChild(TiffComponent::AutoPtr tiffComponent);
|
|
|
|
|
|
|
|
|
|
virtual void doAddNext(TiffComponent::AutoPtr tiffComponent);
|
|
|
|
|
|
|
|
|
|
virtual void doAccept(TiffVisitor& visitor);
|
|
|
|
|
//@}
|
|
|
|
|
|
|
|
|
|
//! @name Accessors
|
|
|
|
@ -350,86 +521,26 @@ namespace Exiv2 {
|
|
|
|
|
virtual void doPrint(std::ostream& os,
|
|
|
|
|
ByteOrder byteOrder,
|
|
|
|
|
const std::string& prefix) const;
|
|
|
|
|
|
|
|
|
|
virtual void doAccept(TiffVisitor& visitor) const;
|
|
|
|
|
//@}
|
|
|
|
|
|
|
|
|
|
private:
|
|
|
|
|
// DATA
|
|
|
|
|
TiffDirectory ifd_; //!< The subdirectory
|
|
|
|
|
|
|
|
|
|
}; // class TiffDirectory
|
|
|
|
|
|
|
|
|
|
/*!
|
|
|
|
|
@brief This class models a TIFF header structure.
|
|
|
|
|
*/
|
|
|
|
|
class TiffHeade2 {
|
|
|
|
|
public:
|
|
|
|
|
//! @name Creators
|
|
|
|
|
//@{
|
|
|
|
|
//! Default constructor
|
|
|
|
|
TiffHeade2()
|
|
|
|
|
: byteOrder_ (littleEndian),
|
|
|
|
|
offset_ (0x00000008)
|
|
|
|
|
{}
|
|
|
|
|
//@}
|
|
|
|
|
|
|
|
|
|
//! @name Manipulators
|
|
|
|
|
//@{
|
|
|
|
|
/*!
|
|
|
|
|
@brief Read the TIFF header from a data buffer. Return false if the
|
|
|
|
|
data buffer does not contain a TIFF header, else true.
|
|
|
|
|
|
|
|
|
|
@param pData Pointer to the data buffer.
|
|
|
|
|
@param size Number of bytes in the data buffer.
|
|
|
|
|
*/
|
|
|
|
|
bool read(const byte* pData, uint32_t size);
|
|
|
|
|
//@}
|
|
|
|
|
|
|
|
|
|
//! @name Accessors
|
|
|
|
|
//@{
|
|
|
|
|
/*!
|
|
|
|
|
@brief Write the TIFF header to the binary image \em blob.
|
|
|
|
|
This method appends to the blob.
|
|
|
|
|
|
|
|
|
|
@param blob Binary image to add to.
|
|
|
|
|
|
|
|
|
|
@throw Error If the header cannot be written.
|
|
|
|
|
*/
|
|
|
|
|
void write(Blob& blob) const;
|
|
|
|
|
/*!
|
|
|
|
|
@brief Print debug info for the TIFF header to \em os.
|
|
|
|
|
|
|
|
|
|
@param os Output stream to write to.
|
|
|
|
|
@param prefix Prefix to be written before each line of output.
|
|
|
|
|
*/
|
|
|
|
|
void print(std::ostream& os, const std::string& prefix ="") const;
|
|
|
|
|
//! Return the byte order (little or big endian).
|
|
|
|
|
ByteOrder byteOrder() const { return byteOrder_; }
|
|
|
|
|
//! Return the offset to the start of the root directory
|
|
|
|
|
uint32_t offset() const { return offset_; }
|
|
|
|
|
//@}
|
|
|
|
|
|
|
|
|
|
private:
|
|
|
|
|
// DATA
|
|
|
|
|
ByteOrder byteOrder_; //!< Applicable byte order
|
|
|
|
|
uint32_t offset_; //!< Offset to the start of the root dir
|
|
|
|
|
|
|
|
|
|
static const uint16_t tag_; //!< 42, identifies the buffer as TIFF data
|
|
|
|
|
|
|
|
|
|
}; // class TiffHeade2
|
|
|
|
|
}; // class TiffSubIfd
|
|
|
|
|
|
|
|
|
|
/*!
|
|
|
|
|
Type for a function pointer for functions to create TIFF components.
|
|
|
|
|
Todo: This may eventually need to also have access to the image or parse tree
|
|
|
|
|
in order to make decisions based on the value of other tags.
|
|
|
|
|
*/
|
|
|
|
|
typedef TiffComponent::AutoPtr (*NewTiffCompFct)(const TiffStructure* ts, int i);
|
|
|
|
|
typedef TiffComponent::AutoPtr (*NewTiffCompFct)(const TiffStructure* ts);
|
|
|
|
|
|
|
|
|
|
/*!
|
|
|
|
|
This structure is meant to be used as an entry (row) of a table describing
|
|
|
|
|
the TIFF structure of an image format for reading and writing. Different
|
|
|
|
|
tables can be used to support different TIFF based image formats.
|
|
|
|
|
@brief Data structure used as a row (element) of a table (array)
|
|
|
|
|
describing the TIFF structure of an image format for reading and
|
|
|
|
|
writing. Different tables can be used to support different TIFF
|
|
|
|
|
based image formats.
|
|
|
|
|
*/
|
|
|
|
|
struct TiffStructure {
|
|
|
|
|
//! Return the tag corresponding to the extended tag
|
|
|
|
@ -441,57 +552,9 @@ namespace Exiv2 {
|
|
|
|
|
uint16_t newGroup_; //!< Group of the newly created component
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
//! Abstract base class for TIFF composite vistors (Visitor pattern)
|
|
|
|
|
class TiffVisitor {
|
|
|
|
|
public:
|
|
|
|
|
//! @name Creators
|
|
|
|
|
//@{
|
|
|
|
|
virtual ~TiffVisitor() {}
|
|
|
|
|
//@}
|
|
|
|
|
|
|
|
|
|
//! @name Manipulators
|
|
|
|
|
//@{
|
|
|
|
|
//! Decode a TIFF entry
|
|
|
|
|
virtual void visitEntry(const TiffEntry* object) =0;
|
|
|
|
|
//! Decode a TIFF directory
|
|
|
|
|
virtual void visitDirectory(const TiffDirectory* object) =0;
|
|
|
|
|
//! Decode a TIFF sub-IFD
|
|
|
|
|
virtual void visitSubIfd(const TiffSubIfd* object) =0;
|
|
|
|
|
//@}
|
|
|
|
|
|
|
|
|
|
}; // class TiffVisitor
|
|
|
|
|
|
|
|
|
|
/*!
|
|
|
|
|
TIFF composite visitor to decode metadata from the composite and add it
|
|
|
|
|
to an Image, which is supplied in the constructor.
|
|
|
|
|
*/
|
|
|
|
|
class TiffMetadataDecoder : public TiffVisitor {
|
|
|
|
|
public:
|
|
|
|
|
//! @name Creators
|
|
|
|
|
//@{
|
|
|
|
|
//! Constructor
|
|
|
|
|
TiffMetadataDecoder(Image* pImage) : pImage_(pImage) {}
|
|
|
|
|
//! Virtual destructor
|
|
|
|
|
virtual ~TiffMetadataDecoder() {}
|
|
|
|
|
//@}
|
|
|
|
|
|
|
|
|
|
//! @name Manipulators
|
|
|
|
|
//@{
|
|
|
|
|
virtual void visitEntry(const TiffEntry* object);
|
|
|
|
|
virtual void visitDirectory(const TiffDirectory* object);
|
|
|
|
|
virtual void visitSubIfd(const TiffSubIfd* object);
|
|
|
|
|
//! Decode a standard TIFF entry
|
|
|
|
|
void decodeTiffEntry(const TiffEntryBase* object);
|
|
|
|
|
//@}
|
|
|
|
|
|
|
|
|
|
private:
|
|
|
|
|
// DATA
|
|
|
|
|
Image* pImage_; //!< Pointer to the image to which the metadata is added
|
|
|
|
|
|
|
|
|
|
}; // class TiffMetadataDecoder
|
|
|
|
|
|
|
|
|
|
/*!
|
|
|
|
|
Stateless parser class for data in TIFF format.
|
|
|
|
|
@brief Stateless parser class for data in TIFF format. Images use this
|
|
|
|
|
class to decode and encode TIFF-based data.
|
|
|
|
|
*/
|
|
|
|
|
class TiffParser {
|
|
|
|
|
public:
|
|
|
|
@ -500,7 +563,8 @@ namespace Exiv2 {
|
|
|
|
|
\em size into \em image.
|
|
|
|
|
|
|
|
|
|
This is the entry point to access image data in TIFF format. The
|
|
|
|
|
parser uses classes TiffHeade2, TiffEntry, TiffDirectory.
|
|
|
|
|
parser uses classes TiffHeade2 and the TiffComponent and TiffVisitor
|
|
|
|
|
hierarchies.
|
|
|
|
|
|
|
|
|
|
@param pData Pointer to the data buffer. Must point to data
|
|
|
|
|
in TIFF format; no checks are performed.
|
|
|
|
@ -517,12 +581,12 @@ namespace Exiv2 {
|
|
|
|
|
const TiffStructure* pTiffStructure,
|
|
|
|
|
TiffVisitor& decoder);
|
|
|
|
|
/*!
|
|
|
|
|
@brief Create the appropriate TiffComponent to handle the \em tag in
|
|
|
|
|
\em group.
|
|
|
|
|
@brief Create the TiffComponent for TIFF entry \em tag in \em group
|
|
|
|
|
based on the lookup list \em pTiffStructure.
|
|
|
|
|
|
|
|
|
|
Uses table \em pTiffStructure to derive the correct component. If a
|
|
|
|
|
tag, group tupel is not found in the table, a TiffEntry is created. If
|
|
|
|
|
the pointer that is returned is 0, then the TIFF entry should be ignored.
|
|
|
|
|
If a tag, group tupel is not found in the table, a TiffEntry is
|
|
|
|
|
created. If the pointer that is returned is 0, then the TIFF entry
|
|
|
|
|
should be ignored.
|
|
|
|
|
*/
|
|
|
|
|
static TiffComponent::AutoPtr create( uint32_t extendedTag,
|
|
|
|
|
uint16_t group,
|
|
|
|
@ -533,10 +597,10 @@ namespace Exiv2 {
|
|
|
|
|
// template, inline and free functions
|
|
|
|
|
|
|
|
|
|
//! Function to create and initialize a new TIFF directory
|
|
|
|
|
TiffComponent::AutoPtr newTiffDirectory(const TiffStructure* ts, int i);
|
|
|
|
|
TiffComponent::AutoPtr newTiffDirectory(const TiffStructure* ts);
|
|
|
|
|
|
|
|
|
|
//! Function to create and initialize a new TIFF sub-directory
|
|
|
|
|
TiffComponent::AutoPtr newTiffSubIfd(const TiffStructure* ts, int i);
|
|
|
|
|
TiffComponent::AutoPtr newTiffSubIfd(const TiffStructure* ts);
|
|
|
|
|
|
|
|
|
|
} // namespace Exiv2
|
|
|
|
|
|
|
|
|
|