tags:

views:

92

answers:

3

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
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
+1  A: 
Charlie Martin
Thank you :)That looks like it should do the trick.
Elephantinc
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