I need help filling out a BMP file based on the width and height of an image.
What I am working with:
struct BMP_Header {
char signature[2];
int size;
short reserved1;
short reserved2;
int offset;
};
struct DIB_Header {
int size;
int width;
int height;
short planes;
short bit_count;
int compression;
int size_image;
int x_ppm;
int y_ppm;
int clr_used;
int clr_important;
};
* @param header: Pointer to the destination DIB header
* @param width: Width of the image
* @param height: Height of the image
void makeBMPHeader(struct BMP_Header* header, int width, int height){
//header->size = ???;
//header->offset = ???;
}
* @param header: Pointer to the destination DIB header
* @param width: Width of the image
* @param height: Height of the image
void makeDIBHeader(struct DIB_Header* header, int width, int height) {
//header->size = ???;
//header-> width = ???;
//header->height = ???;
//header-> bits_per_pixel = ???;
//header-> size_image = ???;
}
I used default values for most components I just need assistance calculating the values for the components above.
Here is an example to create a .bmp file in Windows. BITMAPINFOHEADER and BITMAPFILEHEADER structures are defined in wingdi.h (accessed from windows.h). This example creates a 24 bit RGB bitmap.