0

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);

1 Answer 1

1

When the file has an invalid or unsupported file format, the peek tool doesn't work. When that happens, you can always fall back and use the xxd tool to look at the raw data.

By the way, which header is first in the file and which is second? ;-)

If this answers your question, please click on the check mark to accept. Let's keep up on forum maintenance. ;-)

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .