解压缩缩小的TIFF数据

时间:2017-06-29 16:12:16

标签: c++ zlib tiff compression hexdump

我有这段代码:

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;
}

我还在pic.tif上做了一个hexdump,得到了大约450行的十六进制值,其中很多都是通过标签数据和标题打印出来的。

但是我发现这个TIFF有压缩32946,它是COMPRESSION_DEFLATE。

如何从hexdump中解压缩其他十六进制值以从此TIFF获取实际浮点值?我知道Zlib可以解压缩,但它可以解压缩deflate压缩,如果是这样,怎么样?

我知道浮点值应该通过LibTIFF,但不能使用它。它是一个512x512 32位tiff,它有浮点值。

另外,如果有人想看,我可以发布更多关于TIFF或hexdump值的信息。

1 个答案:

答案 0 :(得分:1)

每个段都是标准的zlib流,即带有zlib头和尾部的deflate压缩数据。您可以使用zlib的uncompress()inflateInit() / inflate() / inflateEnd()函数。

相关问题