I have been trying to read a .tif file using ifstream and I get incorrect data back when I run the code in Unreal Engine but when I read the same file using a standalone c++ program it reads the file correctly.
The data I read in UE:
Endian: i ᆭ
Arbitrary Number: 4
IFD Address: 32763
The data I read standalone:
Endian: II
Arbitrary Number: 42
IFD Address: 192
I have confirmed the data read by the standalone c++ program is correct using notepad++ to view the files hex values. I don’t understand why I would get different results reading a file with the same code in Unreal vs standalone.
The code used to read the file:
short magicno;
char buffer[3];
int ifdaddress;
ifstream imfile;
imfile.open("ProjectPath/Content/file.tif", ios::binary);
imfile.seekg(0,ios::beg);
imfile.read(buffer,2);
imfile.read((char*)&magicno, 2);
imfile.read((char*)&ifdaddress, 4);
imfile.seekg(ifdaddress, ios::beg);
imfile.close();
cout<<"Endian: "<<buffer<<endl;
cout<<"Magic: "<<magicno<<endl;
cout<<"IFD Address: "<<ifdaddress<<endl;