bitmap.width = (int)//whatever number you like!
out << (bitmap.width );
out << (bitmap.width >> 8);
out << (bitmap.width >> 16);
out << (bitmap.width >> 24);
Okay, I put this integer into the file correctly, but I am having a bit of trouble GETTING IT OUT!
Can anyone finish this?:
1 2 3 4 5
char meas[4];
in.get(meas[0]); //All 4 bytes I put in
in.get(meas[1]);
in.get(meas[2]);
in.get(meas[3]);
Got anything?
PS-I posted what I thought was an answer on another post but after I looked into it, I found it was HORRIBLY wrong, please disregard my advice!
// write little-endian 4-byte integer
// MAKE SURE stream is opened in BINARY mode!
void write_int_le4( ostream& outs, int value )
{
for (int n = 0; n < 4; n++, value >>= 8)
outs.put( (unsignedchar)value );
}
// read little-endian 4-byte integer
// MAKE SURE stream is opened in BINARY mode!
int read_int_le4( istream& ins )
{
int result = 0;
unsignedchar c;
for (int n = 0; n < 4; n++)
{
ins.get( c );
result = (result << 8) + c;
}
return result;
}