Reputation: 53
I have written a class to perform certain manipulations on a 3D grayscale image that I have placed in a vector container of doubles and use indexing to iterate through the rows, columns and slices.
I want to output this image as a bitmap file. I know I have to first write the header info but I've no clue how to go about it.
Upvotes: 0
Views: 722
Reputation: 9929
You can use fwrite()
. This function can write struct of data into file.
For example you define the header as a struct:
struct Header {
int len;
...
}
struct Header header;
header.len = any_len;
hander. = ... ; // any other info of header
fwrite(&header, sizeof(header), 1, fp);
This way, you write header info into the file.
Then, if your bmp content is in an array of doubles:
double dots[N]; // this is your bmp point array
fwrite(dots, sizeof(double) * N, 1, fp);
Upvotes: 1