0

I was looking through copy.c, and if the bf.Size part of BITMAPFILEHEADER includes padding, then how come the amount of padding needed isn't even defined in copy.c until after BITMAPFILEHEADER is declared? How does that work?

// write outfile's BITMAPFILEHEADER
fwrite(&bf, sizeof(BITMAPFILEHEADER), 1, outptr);

// write outfile's BITMAPINFOHEADER
fwrite(&bi, sizeof(BITMAPINFOHEADER), 1, outptr);

// determine padding for scanlines
int padding = (4 - (bi.biWidth * sizeof(RGBTRIPLE)) % 4) % 4;
1

Remember that this is copy.c. It's purpose is to merely copy the file, not alter it. The headers are copied, not altered, so it isn't a problem. The value of padding isn't needed to merely copy the headers.

However, a lot of this part of the pset's purpose is a setup for the next part, resize.c. When you complete that part, you'll see how going through the motions in copy.c is actually teaching how to use the techniques to complete resize.c.

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 .