Hi!
Following on my previous post:
I have a read function like this:
I have implemented a write function like this
Everything works fine execpt that if I call the write function straight after the read the out file file is smaller than the input file: 1048582 vs 1376262 resp.I check lenx, leny and lenz are the same (128,128,64) resp
Any ideas why?
Thanks!
Following on my previous post:
I have a read function like this:
Code:
/* open file */
fstream file (filename, ios::in | ios::binary);
if (!file)
{
PRINT_ERROR("Cannot open file (%s)\n",filename);
}
file.seekg (0, ios::beg);
/* read dimensions */
file.read(&hi,1);
file.read(&lo,1);
lenx = hi*256+lo;
file.read(&hi,1);
file.read(&lo,1);
leny = hi*256+lo;
file.read(&hi,1);
file.read(&lo,1);
lenz = hi*256+lo;
pixels = new GLubyte [lenx * leny * lenz];
if (pixels==NULL)
{
PRINT_ERROR("Read_data() : Out of memory (%s)\n",filename);
}
/*read data*/
file.read(pixels,lenx * leny * lenz);
I have implemented a write function like this
Code:
GLint hi = 0;
/* open file */
fstream file (filename, ios::out | ios::binary);
/* write dimensions */
file.write(reinterpret_cast <char*> (&hi),1);
file.write(reinterpret_cast <char*> (&lenx),1);
file.write(reinterpret_cast <char*> (&hi),1);
file.write(reinterpret_cast <char*> (&leny),1);
file.write(reinterpret_cast <char*> (&hi),1);
file.write(reinterpret_cast <char*> (&lenz),1);
/*write data*/
file.write(reinterpret_cast <char*> (&pixels),lenx * leny * lenz);
Everything works fine execpt that if I call the write function straight after the read the out file file is smaller than the input file: 1048582 vs 1376262 resp.I check lenx, leny and lenz are the same (128,128,64) resp
Any ideas why?
Thanks!