2011.04.15 11:50 "[Tiff] File size too large when using custom tiff tags", by
Hey guys,
I'm using Libtiff to store a array of long values (32 bit) in a custom tiff tag. The type of the tag is TIFF_LONG. Everything works pretty well, except that the file size is too large by factor 2.
For example, there is an array of 361000 long values. The file size should be ~ 1.44 MB (size of data ) + 531 KB ( size of the picture) = 1.971 MB.
But the size is 3.4 MB. How could that be? Any Ideas?
That's my cutom tag:
void TagExtender( TIFF *tiff )
{
assert( tiff );
static const TIFFFieldInfo xtiffFieldInfo[] = {
{ TIFFTAG_LAYER0, -3, -3, TIFF_LONG, FIELD_CUSTOM, 1, 1,
"Data" },
};
TIFFMergeFieldInfo( tiff, xtiffFieldInfo,
sizeof(xtiffFieldInfo) / sizeof(xtiffFieldInfo[0]) );
}
This is how the array is stored:
class TiffHandler{
private:
TIFF * m_tiff;
...
void TiffHandler::AddData( int directory, const std::vector<long>& data
)
{
assert( m_tiff );
assert( data.size() );
TIFFSetTagExtender( TagExtender );
TIFFSetErrorHandler( TIFFError );
TIFFSetDirectory( m_tiff, directory );
TIFFSetField( m_tiff, TIFFTAG_LAYER0, data.size(), &data[0] );
TIFFRewriteDirectory( m_tiff );
}