【问题标题】:Decompressing deflated TIFF data解压缩压缩的 TIFF 数据
【发布时间】:2017-06-29 16:12:16
【问题描述】:

我有这个代码:

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 的值的更多信息。

【问题讨论】:

    标签: c++ zlib tiff compression hexdump


    【解决方案1】:

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

    【讨论】:

    • 您愿意举个例子吗?我已经搜索过了,但随着数据的返回,我只是得到了空格......
    • 没有比使用uncompress() 更简单的了。只需填写参数即可。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2016-03-17
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多