virtual bool readHeader() = 0;
virtual bool readData( Mat& img ) = 0;
+ /// Called after readData to advance to the next page, if any.
+ virtual bool nextPage() { return false; }
+
virtual size_t signatureLength() const;
virtual bool checkSignature( const String& signature ) const;
virtual ImageDecoder newDecoder() const;
{
bool result = false;
- close();
- // TIFFOpen() mode flags are different to fopen(). A 'b' in mode "rb" has no effect when reading.
- // http://www.remotesensing.org/libtiff/man/TIFFOpen.3tiff.html
- TIFF* tif = TIFFOpen( m_filename.c_str(), "r" );
+ TIFF* tif = static_cast<TIFF*>(m_tif);
+ if (!m_tif)
+ {
+ // TIFFOpen() mode flags are different to fopen(). A 'b' in mode "rb" has no effect when reading.
+ // http://www.remotesensing.org/libtiff/man/TIFFOpen.3tiff.html
+ tif = TIFFOpen(m_filename.c_str(), "r");
+ }
if( tif )
{
return result;
}
+bool TiffDecoder::nextPage()
+{
+ // Prepare the next page, if any.
+ return m_tif &&
+ TIFFReadDirectory(static_cast<TIFF*>(m_tif)) &&
+ readHeader();
+}
bool TiffDecoder::readData( Mat& img )
{
}
}
- close();
return result;
}