I have 8 bit raw data representing a grayscale image (int value 0-255) in a file looking like this:
0000 0000 0000 0000 0000 0000 0000 0000
0000 0000 0000 0000 001c 354d 6576 8797
9fa4 a7a4 864b 252e 5973 7673 7b86 7e6d
6164 6c7a 8b98 a2ac b8bd ae96 857f 6d40
1d14 160b 0000 0000 0000 0000 0000 0000
and i need to read them and print their int value (0-255). I try this, but all result looks like this: 0020 0a00 2000 2000 2000 2000 2000 2000 I dont know what is wrong, fopen as binary file is OK?
FILE * pFile;
pFile = fopen(inFileName.c_str(), "rb");
if (pFile==NULL){
cerr << "erro" << endl;
}
uint8_t bufferImmagine[height*width];
fread(bufferImmagine,1,height*width,pFile);
fclose (pFile);
for (int i = 0; i < height*width; ++i)
{
cout << bufferImmagine[i] << " ";
}