Basically you need to modify the headers so they are the right size but not all the information contained in the headers needs to change.
Than you need to iterate over the printing of the pictures so that it prints twice for the height and wight and it accounts for the new padding.
When a struct is stored in memory, the data for each struct element is stored in sequence. That means that when a struct's data is read, the data is simply read into each element in the same order that it was stored. Individual elements can be selected out by reading them from their position in the struct. It's all about the location of each element in the ...
Because 1/f when f = 3 is not exactly 1/3 but 0.33333.. with a lot of digits. So the loop iterate for some times, the offset accumulate making the variable newHeightIndex behave not as we want. For example, may be after 9 times, newHeightIndex = 2.9999.. < 3 so another iteration is bound to happen.
There are a few issues I see in your code.
You define your file headers, but you don't read them or set pointers to them, which means you can't track them.
You need padding n times for each pixel. You also don't skip over resize padding in either direction when you add the padding.
The equations you use to determine the new size of the image and the ...
You should run the staff's version for a couple of files and different values of resize and then run peek on those files to see which are the headers that actually change.
Also, take a closer look at the code. bi.biSize is one of the headers used to make sure the file is a bmp. Do you think that one should really change?
Other than that, you're not ...
There are a number of errors in the code that need to be resolved and other issues that haven't even been coded for.
There are fields in the headers that haven't been updated. The padding for the input and output files need to be calculated independently. The pixels need to be output n times. Each line of pixels needs to be processed n times as well. There ...
I think maybe the relationship between biSize, biSizeImage, and bfSize is not reflected properly in the code. Here's reference from MSDN:
bfSize: The size, in bytes, of the bitmap file.
~ MSDN BITMAPFILEHEADER structure
biSize: The number of bytes required by the structure.
biSizeImage: The size, in bytes, of the image.
~ MSDN ...
There are a number of problems. First, you haven't calculated the padding for the output file. The padding for the input and output files are not necessarily the same. You have to calculate the padding for the output file. Some of the header values are dependant on this, so this fix will cure some other issues.
Next, your fwrite() doesn't write out ...
Because the width of your image has to be a multiple of 4, in fact the next multiple of 4 of your width. Since the width is 3, the next multiple of 4 is 4. So you have to add one pixel of padding. And the size then is: 4 x 3 x 3 = 36. So biSizeImage is the number of pixels, plus the padding. Keep watching the pset's videos and you will get a better idea.