I used the following code to read a raw file:
Code:
const int size = 1080*1080;
int r;
unsigned char* A;
A = (unsigned char*)malloc(size*sizeof(char));
fin.open("test.raw",ios::binary); // read data file of four integers
for(r=0; r<size; r++) // into array
fin >> A[r];
fin.close();
ofstream fout;
fout.open("result.raw",ios::binary);
// write data file
for(r=0; r<size; r++){
fout << A[r];
}
fout.close();
So, this is just a roundtrip that import the raw file into the array A, and then export data into the file result.raw. However, the image output is incomplete. What's the problem with my coding?