I don't know why I am getting the error "Invalid or Unsupported Image Format" for my code. From reading the questions that other people have posted, this issue seems to be coming from the header structure. I'm not sure where my problem is. Can someone please help me?
// determine new padding for outfile
int padding_o = (4 - ((bi.biWidth*n) * sizeof(RGBTRIPLE)) % 4) % 4;
// write outfile's BITMAPINFOHEADER
BITMAPINFOHEADER bi_new;
bi_new = bi;
bi_new.biWidth = bi.biWidth*n;
bi_new.biHeight = abs(bi.biHeight) * n;
bi_new.biSizeImage = (bi_new.biWidth*sizeof(RGBTRIPLE) + padding_o) * bi_new.biHeight;
fwrite(&bi_new, sizeof(BITMAPINFOHEADER), 1, outptr);
// write outfile's BITMAPFILEHEADER
BITMAPFILEHEADER bf_new;
bf_new = bf;
bf_new.bfSize = sizeof(BITMAPINFOHEADER) + sizeof(BITMAPFILEHEADER) + bi_new.biSizeImage;
fwrite(&bf_new, sizeof(BITMAPFILEHEADER), 1, outptr);