Decompression of deflated TIFF data

I have this code:

ifstream istream;
std::string line;
TIFHEAD header;
istream.open("pic.tif",ios::binary|ios::in);
istream.read((char*)&header, sizeof(TIFHEAD));
cout<<hex<<header.Identifier<<" "<<header.Version<<" "<<header.IFDOffset<<endl<<endl;
istream.seekg(header.IFDOffset);

WORD numEntries1;
istream.read((char *)&numEntries1, sizeof(WORD));
cout<<numEntries1<<endl;

DWORD tagOffset;
DWORD stripByte;

for(int i=0; i<numEntries1; i++) {
    TIFTAG tag;
    istream.read((char *)&tag, sizeof(TIFTAG));
    cout<<istream.tellg()<<":"<<tag.TagId<<" "<<tag.DataType<<" "<<tag.DataCount<<" "<<tag.DataOffset<<endl;
}

      

I also did a hexdump on pic.tif and got about 450 lines of hex values, many of which were reflected by the tag data and the header that I print out.

But I found this TIFF has 32946 compression, which is COMPRESSION_DEFLATE.

How can I unpack other hex values ​​from hexdump to get the actual float values ​​from this TIFF? I know Zlib can decompress, but can it decompress compression compression, and if so, how?

I know the float values ​​should be using LibTIFF, but can't use this.It 512x512 32 bit tiff which is float values.

Also, I can post more information on TIFF or values ​​from hexdump in case anyone wants to see it.

+3


source to share


1 answer


Each segment is a standard zlib stream, that is, photographed data with a zlib header and a trailer. You can use zlib functions uncompress()

or inflateInit()

/ inflate()

/ inflateEnd()

.



+1


source







All Articles