ome-files  0.5.0
Classes | Public Types | Public Member Functions | Static Public Member Functions | Protected Member Functions | Private Member Functions | Private Attributes | Friends | List of all members
ome::files::tiff::TIFF Class Reference

Tagged Image File Format (TIFF). More...

#include <ome/files/tiff/TIFF.h>

+ Inheritance diagram for ome::files::tiff::TIFF:
+ Collaboration diagram for ome::files::tiff::TIFF:

Classes

class  Impl
 Internal implementation details of TIFF. More...
 

Public Types

typedef IFDIterator< IFDiterator
 IFD iterator.
 
typedef IFDIterator< const IFDconst_iterator
 const IFD iterator.
 

Public Member Functions

 ~TIFF ()
 Destructor.
 
void close ()
 Close the TIFF file. More...
 
 operator bool ()
 Check if the TIFF file is valid. More...
 
directory_index_type directoryCount () const
 Get the total number of IFDs. More...
 
std::shared_ptr< IFDgetDirectoryByIndex (directory_index_type index) const
 Get an IFD by its index. More...
 
std::shared_ptr< IFDgetDirectoryByOffset (offset_type offset) const
 Get an IFD by its offset in the file. More...
 
std::shared_ptr< IFDgetCurrentDirectory () const
 Get the currently active IFD. More...
 
void writeCurrentDirectory ()
 Write the currently active IFD. More...
 
wrapped_type * getWrapped () const
 Get the underlying libtiff ::TIFF instance. More...
 
iterator begin ()
 Get the first image file directory. More...
 
const_iterator begin () const
 Get the first image file directory. More...
 
iterator end ()
 Get the last+1 image file directory. More...
 
const_iterator end () const
 Get the last+1 image file directory. More...
 

Static Public Member Functions

static std::shared_ptr< TIFFopen (const boost::filesystem::path &filename, const std::string &mode)
 Open a TIFF file for reading or writing. More...
 

Protected Member Functions

 TIFF (const boost::filesystem::path &filename, const std::string &mode)
 Constructor (non-public). More...
 

Private Member Functions

void registerImageJTags ()
 Register ImageJ tags with libtiff for this image.
 

Private Attributes

std::shared_ptr< Implimpl
 Private implementation details.
 

Friends

class IFD
 IFD uses internal TIFF state.
 

Detailed Description

Tagged Image File Format (TIFF).

This class is the primary class for reading and writing TIFF files. Use the static open() method to get a working instance. This instance may be used to get IFD instances and then access to image metadata and pixel data.

Constructor & Destructor Documentation

◆ TIFF()

ome::files::tiff::TIFF::TIFF ( const boost::filesystem::path &  filename,
const std::string &  mode 
)
protected

Constructor (non-public).

Parameters
filenamethe file to open.
modethe file open mode (r to read, w to write or a to append).
Exceptions
anException on failure.

References impl, and registerImageJTags().

Member Function Documentation

◆ begin() [1/2]

TIFF::iterator ome::files::tiff::TIFF::begin ( )

Get the first image file directory.

Returns
an iterator referring to the first image file directory

References getDirectoryByIndex().

◆ begin() [2/2]

TIFF::const_iterator ome::files::tiff::TIFF::begin ( ) const

Get the first image file directory.

Returns
an iterator referring to the first image file directory

References getDirectoryByIndex().

◆ close()

void ome::files::tiff::TIFF::close ( )

Close the TIFF file.

Note that this will be done automatically when the destructor runs. Any further method calls using this object or any child IFD will throw an Exception.

References impl.

◆ directoryCount()

directory_index_type ome::files::tiff::TIFF::directoryCount ( ) const

Get the total number of IFDs.

Returns
the IFD count.

References impl.

◆ end() [1/2]

TIFF::iterator ome::files::tiff::TIFF::end ( )

Get the last+1 image file directory.

Returns
an iterator referring to the last+1 image file directory.

◆ end() [2/2]

TIFF::const_iterator ome::files::tiff::TIFF::end ( ) const

Get the last+1 image file directory.

Returns
an iterator referring to the last+1 image file directory.

◆ getCurrentDirectory()

std::shared_ptr< IFD > ome::files::tiff::TIFF::getCurrentDirectory ( ) const

Get the currently active IFD.

Returns
the IFD.
Exceptions
anException if the IFD could not be accessed.

References ome::files::tiff::IFD::current().

Referenced by writeCurrentDirectory().

+ Here is the caller graph for this function:

◆ getDirectoryByIndex()

std::shared_ptr< IFD > ome::files::tiff::TIFF::getDirectoryByIndex ( directory_index_type  index) const

Get an IFD by its index.

Parameters
indexthe directory index.
Returns
the IFD.
Exceptions
anException if the index is invalid or could not be accessed.

References getDirectoryByOffset(), and impl.

Referenced by begin().

+ Here is the caller graph for this function:

◆ getDirectoryByOffset()

std::shared_ptr< IFD > ome::files::tiff::TIFF::getDirectoryByOffset ( offset_type  offset) const

Get an IFD by its offset in the file.

Parameters
offsetthe directory offset.
Returns
the IFD.
Exceptions
anException if the offset is invalid or could not be accessed.

References ome::files::tiff::IFD::openOffset().

Referenced by getDirectoryByIndex().

+ Here is the caller graph for this function:

◆ getWrapped()

TIFF::wrapped_type * ome::files::tiff::TIFF::getWrapped ( ) const

Get the underlying libtiff ::TIFF instance.

If there is any need to use the libtiff C interface to access any functionality not exposed through these C++ wrapper classes, this will provide a pointer to the handle.

Note
Due to not including the libtiff C headers the ::TIFF type isn't available here. After including the main <tiffio.h> header, cast the return value to the correct type:
* ::TIFF *tiff = reinterpret_cast<::TIFF *>(myfile.getWrapped());
* 
Returns
an opaque pointer to the wrapped ::TIFF instance.

References impl.

Referenced by registerImageJTags().

+ Here is the caller graph for this function:

◆ open()

std::shared_ptr< TIFF > ome::files::tiff::TIFF::open ( const boost::filesystem::path &  filename,
const std::string &  mode 
)
static

Open a TIFF file for reading or writing.

Note
There are additional open flags, documented in TIFFOpen(3).
Parameters
filenamethe file to open.
modethe file open mode (r to read, w to write or a to append).
Returns
the the open TIFF.
Exceptions
anException on failure.

Referenced by ome::files::in::OMETIFFReader::getTIFF(), and ome::files::out::OMETIFFWriter::setId().

+ Here is the caller graph for this function:

◆ operator bool()

ome::files::tiff::TIFF::operator bool ( )

Check if the TIFF file is valid.

Returns
true if the file is open and available for reading and writing, or false if closed or invalid.

References impl.

◆ writeCurrentDirectory()

void ome::files::tiff::TIFF::writeCurrentDirectory ( )

Write the currently active IFD.

The pixel data accompanying this IFD must have been written using IFD::writeImage() prior to calling this method, or else the TIFF tags for strip and tile offsets will be incomplete and the file will fail to read.

References ome::files::tiff::Sentry::error(), getCurrentDirectory(), impl, and ome::files::tiff::SOFTWARE.


The documentation for this class was generated from the following files: