//create new BITMAPINFOHEADER details
BITMAPINFOHEADER bi_new;
bi_new.biHeight = bi.biHeight * factor;
bi_new.biWidth = bi.biWidth * factor;
// determine padding for infile scanlines
int padding = (4 - (bi.biWidth * sizeof(RGBTRIPLE)) % 4) % 4;
// determine padding for outfile scanlines
int new_padding = (4 - (bi_new.biWidth * sizeof(RGBTRIPLE)) % 4) % 4;
bi_new.biSizeImage = (bi_new.biHeight * bi_new.biWidth * 9) + (new_padding * bi_new.biHeight);
//create new BITMAPFILEHEADER details
BITMAPFILEHEADER bf_new;
bf_new.bfSize = bi_new.biSizeImage + sizeof(BITMAPINFOHEADER) + sizeof(BITMAPFILEHEADER);
// write outfile's BITMAPFILEHEADER
fwrite(&bf_new, sizeof(BITMAPFILEHEADER), 1, outptr);
// write outfile's BITMAPINFOHEADER
fwrite(&bi_new, sizeof(BITMAPINFOHEADER), 1, outptr);
I have written code for new header files of bit map. Please check this if it is correct, I guess something is going wrong. I didnt write code to resize the pixels yet. But, I have run my code, found that new bmp file is generated and I couldnt open the file. It says unsupported file format. I am not sure if this is expected behaviour, Please let me know if something's wrong in my code. Thank you!