Support for multipage decoding in BaseImageDecoder and implemented in TiffDecoder.
This commit is contained in:
parent
6cb93445e1
commit
ecf359b8c9
@ -70,6 +70,9 @@ public:
|
|||||||
virtual bool readHeader() = 0;
|
virtual bool readHeader() = 0;
|
||||||
virtual bool readData( Mat& img ) = 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 size_t signatureLength() const;
|
||||||
virtual bool checkSignature( const String& signature ) const;
|
virtual bool checkSignature( const String& signature ) const;
|
||||||
virtual ImageDecoder newDecoder() const;
|
virtual ImageDecoder newDecoder() const;
|
||||||
|
@ -118,10 +118,13 @@ bool TiffDecoder::readHeader()
|
|||||||
{
|
{
|
||||||
bool result = false;
|
bool result = false;
|
||||||
|
|
||||||
close();
|
TIFF* tif = static_cast<TIFF*>(m_tif);
|
||||||
// TIFFOpen() mode flags are different to fopen(). A 'b' in mode "rb" has no effect when reading.
|
if (!m_tif)
|
||||||
// http://www.remotesensing.org/libtiff/man/TIFFOpen.3tiff.html
|
{
|
||||||
TIFF* tif = TIFFOpen( m_filename.c_str(), "r" );
|
// 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 )
|
if( tif )
|
||||||
{
|
{
|
||||||
@ -182,6 +185,13 @@ bool TiffDecoder::readHeader()
|
|||||||
return result;
|
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 )
|
bool TiffDecoder::readData( Mat& img )
|
||||||
{
|
{
|
||||||
@ -413,7 +423,6 @@ bool TiffDecoder::readData( Mat& img )
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
close();
|
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -100,6 +100,7 @@ public:
|
|||||||
bool readHeader();
|
bool readHeader();
|
||||||
bool readData( Mat& img );
|
bool readData( Mat& img );
|
||||||
void close();
|
void close();
|
||||||
|
bool nextPage();
|
||||||
|
|
||||||
size_t signatureLength() const;
|
size_t signatureLength() const;
|
||||||
bool checkSignature( const String& signature ) const;
|
bool checkSignature( const String& signature ) const;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user