Reputation:
So I have this TIFF, with compression 32946, which is COMPRESSION_DEFLATE.
I am reading it by hand:
ifstream istream;
std::string line;
TIFHEAD header;
istream.open("pic.tif",ios::binary|ios::in);
istream.read((char*)&header, sizeof(TIFHEAD));
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));
}
and found all the TIFF hex values.
I now have a value, data3.txt, which contains all hex values from the hexdump. Here it is pasted into docs:
This is my zlib code so far, and for most of the data, it prints correctly (for some reason, partway through, it starts printing 000 and a newline repeatedly, then goes into non-ASCII characters).
int main(int argc, char **argv) {
gzFile inFileZ = gzopen("data3.txt", "rb");
unsigned char unzipBuffer[4];
uint8_t unzippedBytes;
while (true) {
unzippedBytes = gzread(inFileZ, unzipBuffer, 4);
std::cout<<std::hex<<unzipBuffer<<std::endl;
z_stream stream;
stream.next_in = unzipBuffer;
inflate(&stream, 1);
std::cout<<stream.next_in<<std::endl;
}
gzclose(inFileZ);
}
and the second thing that's printed out are partly the values and partly non-ASCII characters. Why is this?
if it's not clear, my end goal is to read a TIFF by hand which has floating points at each pixel. I want to just get all those floats.
EDIT: Also, even when data3.txt only contains 12 characters, there is an infinite loop. Why?
Upvotes: 0
Views: 74
Reputation: 6404
As far as I can tell you're decompressing binary floating point values and treating them as ASCII,which creates something which looks like garbage.
Upvotes: 1