libopenraw  0.3.7
Public Types | Public Member Functions | Protected Member Functions | List of all members
OpenRaw::Internals::IfdFileContainer Class Reference

IFD container (TIFF). More...

#include <ifdfilecontainer.hpp>

Inheritance diagram for OpenRaw::Internals::IfdFileContainer:
OpenRaw::Internals::RawContainer OpenRaw::Internals::MRWContainer OpenRaw::Internals::OrfContainer OpenRaw::Internals::Rw2Container

Public Types

enum  { IFD_NONE = -1 , IFD_EXIF = -2 , IFD_GPS = -3 , IFD_INTEROP = -4 }
 
- Public Types inherited from OpenRaw::Internals::RawContainer
enum  EndianType { ENDIAN_NULL = 0 , ENDIAN_BIG , ENDIAN_LITTLE }
 Define the endian of the container. More...
 

Public Member Functions

 IfdFileContainer (const IO::Stream::Ptr &file, off_t offset)
 Constructor. More...
 
virtual ~IfdFileContainer ()
 Destructor.
 
 IfdFileContainer (IfdFileContainer &&)=default
 
virtual EndianType isMagicHeader (const char *p, int len)
 Check the IFD magic header. More...
 
IfdDir::Ref setDirectory (int dir)
 Set the current directory. More...
 
int countDirectories (void)
 Count the number of image file directories, not including EXIF, GPS and INTEROP. More...
 
std::vector< IfdDir::Ref > & directories ()
 Get the directories, loading them if necessary. More...
 
int currentDirectory ()
 Get the number of the current directory. More...
 
size_t getDirectoryDataSize ()
 get the extra data size chunk associated to the current image directory More...
 
int lastError () const
 Return the last error. More...
 
virtual int exifOffsetCorrection () const override
 Return the Exif offset from the container begining. More...
 
void setExifOffsetCorrection (int corr)
 Set the exif offset if needed.
 
::or_error locateImageData (const IfdDir::Ref &dir, uint32_t &x, uint32_t &y, ::or_data_type &t)
 Locate image data in the ifd (excepted RAW) More...
 
- Public Member Functions inherited from OpenRaw::Internals::RawContainer
 RawContainer (const IO::Stream::Ptr &_file, off_t offset)
 
virtual ~RawContainer ()
 
const IO::Stream::Ptrfile () const
 
EndianType endian () const
 
off_t offset () const
 
bool skip (off_t offset)
 
Option< int8_t > readInt8 (const IO::Stream::Ptr &f) const
 
Option< uint8_t > readUInt8 (const IO::Stream::Ptr &f) const
 
Option< int16_t > readInt16 (const IO::Stream::Ptr &f, EndianType endian) const
 Read an int16 following the m_endian set.
 
Option< int32_t > readInt32 (const IO::Stream::Ptr &f, EndianType endian) const
 Read an int32 following the m_endian set.
 
Option< uint16_t > readUInt16 (const IO::Stream::Ptr &f, EndianType endian) const
 Read an uint16 following the m_endian set.
 
size_t readUInt16Array (const IO::Stream::Ptr &f, std::vector< uint16_t > &v, size_t count) const
 Read an array of uint16 following the m_endian set. More...
 
Option< uint32_t > readUInt32 (const IO::Stream::Ptr &f, EndianType endian) const
 Read an uint32 following the m_endian set.
 
size_t fetchData (void *buf, off_t offset, size_t buf_size) const
 Fetch the data chunk from the file. More...
 
off_t size () const
 Return the effective size of the container.
 

Protected Member Functions

virtual bool locateDirsPreHook ()
 hook to be called at the start of _locateDirs()
 
- Protected Member Functions inherited from OpenRaw::Internals::RawContainer
 RawContainer (const RawContainer &)=delete
 
 RawContainer (RawContainer &&)=default
 
RawContaineroperator= (const RawContainer &)=delete
 
void setEndian (EndianType _endian)
 

Additional Inherited Members

- Protected Attributes inherited from OpenRaw::Internals::RawContainer
IO::Stream::Ptr m_file
 The file handle.
 
off_t m_offset
 The offset from the beginning of the file.
 
EndianType m_endian
 

Detailed Description

IFD container (TIFF).

Defines the class for reading TIFF-like file, including but not limited to TIFF, Exif, CR2, NEF, etc. It is designed to also address issues like sone RAW file that do create veriation of TIFF just to confuse readers (like Olympus ORW).

Definition at line 52 of file ifdfilecontainer.hpp.

Member Enumeration Documentation

◆ anonymous enum

anonymous enum
Enumerator
IFD_NONE 

invalid IFD. Means an error

IFD_EXIF 

exif IFD: see field 0x6789 in IFD 0

IFD_GPS 

GPS IFD: see field 0x8825 in IFD 0

IFD_INTEROP 

interoperability IFD: see field 0xa005 in exif IFD

Definition at line 70 of file ifdfilecontainer.hpp.

Constructor & Destructor Documentation

◆ IfdFileContainer()

OpenRaw::Internals::IfdFileContainer::IfdFileContainer ( const IO::Stream::Ptr file,
off_t  offset 
)

Constructor.

Parameters
filethe file handle
offsetthe offset from the start of the file

Definition at line 38 of file ifdfilecontainer.cpp.

Member Function Documentation

◆ countDirectories()

int OpenRaw::Internals::IfdFileContainer::countDirectories ( void  )

Count the number of image file directories, not including EXIF, GPS and INTEROP.

Returns
the number of image file directories

Definition at line 68 of file ifdfilecontainer.cpp.

Referenced by directories(), and setDirectory().

◆ currentDirectory()

int OpenRaw::Internals::IfdFileContainer::currentDirectory ( )

Get the number of the current directory.

Returns
the index of the current directory. By default we are in directory 0. -1 indicates an initialized IFD file

◆ directories()

std::vector< IfdDir::Ref > & OpenRaw::Internals::IfdFileContainer::directories ( )

Get the directories, loading them if necessary.

Returns
the directories

Definition at line 80 of file ifdfilecontainer.cpp.

References countDirectories().

◆ exifOffsetCorrection()

virtual int OpenRaw::Internals::IfdFileContainer::exifOffsetCorrection ( ) const
inlineoverridevirtual

Return the Exif offset from the container begining.

By default it is 0, but some format like MRW needs a different one. This is an adjustement for the offset in the Exif IFD tag.

Reimplemented from OpenRaw::Internals::RawContainer.

Definition at line 128 of file ifdfilecontainer.hpp.

◆ getDirectoryDataSize()

size_t OpenRaw::Internals::IfdFileContainer::getDirectoryDataSize ( )

get the extra data size chunk associated to the current image directory

Returns
the size of the data chunk in bytes

Definition at line 111 of file ifdfilecontainer.cpp.

References OpenRaw::Internals::RawContainer::m_file, and OpenRaw::Internals::RawContainer::readInt32().

◆ isMagicHeader()

IfdFileContainer::EndianType OpenRaw::Internals::IfdFileContainer::isMagicHeader ( const char *  p,
int  len 
)
virtual

Check the IFD magic header.

Parameters
pthe pointer to check
lenthe length of the block to check. Likely to be at least 4.
Returns
the endian if it is the magic header

subclasses needs to override it for like Olympus RAW

Reimplemented in OpenRaw::Internals::Rw2Container, OpenRaw::Internals::OrfContainer, and OpenRaw::Internals::MRWContainer.

Definition at line 52 of file ifdfilecontainer.cpp.

References OpenRaw::Internals::RawContainer::ENDIAN_BIG, OpenRaw::Internals::RawContainer::ENDIAN_LITTLE, and OpenRaw::Internals::RawContainer::ENDIAN_NULL.

◆ lastError()

int OpenRaw::Internals::IfdFileContainer::lastError ( ) const
inline

Return the last error.

Returns
the error code

Definition at line 118 of file ifdfilecontainer.hpp.

◆ locateImageData()

::or_error OpenRaw::Internals::IfdFileContainer::locateImageData ( const IfdDir::Ref dir,
uint32_t &  x,
uint32_t &  y,
::or_data_type t 
)

Locate image data in the ifd (excepted RAW)

Parameters
dirthe IFD dir to locate the image data in
tthe type of the image data
Returns
an error code

◆ setDirectory()

IfdDir::Ref OpenRaw::Internals::IfdFileContainer::setDirectory ( int  dir)

Set the current directory.

Parameters
dirthe index of the directory to read, or one of the specific IFD index values that are < -1
Returns
NULL if not found, or return the reference to the current directory

Definition at line 88 of file ifdfilecontainer.cpp.

References countDirectories().

Referenced by OpenRaw::Internals::MRWFile::_locateMainIfd().


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