I'm currently trying to write a .bmp file in C++ and for the most part it works, there is however, just one issue. When I start trying to save images with different widths and heights everything goes askew and I'm struggling to solve it, so is there any way to force something to write to a specific byte (adding padding in between it and the last thing written)?
+1
A:
Count how many bytes have been written. Write zeroes until the count hits 18. Then resume writing your real data.
Borealid
2010-08-08 16:05:58
A:
If you are on Windows, everything comes to writing predefined structures: "Bitmap storage".
Also there is an example that shows how they should be filled: "Storing an Image".
If you are writing not-just-for-windows code then you can mimic these structs and fallow the guide.
adf88
2010-08-08 16:24:31
Thank you :)That looks like it should do the trick.
Elephantinc
2010-08-08 17:00:17
I'm opening the file like this: ofstream out("test.bmp",ios::out|ios::binary);so what do I put ad the file pointer?
Elephantinc
2010-08-08 18:05:52