I'm trying to resize bmp files in Pset 5 using the re-copy method. However, it seems as though I'm calculating the headers wrongly and I'm also not implementing the for loop where I repeat the horizontal resizing correctly. I would really appreciate any advice on how to overcome these problems!
Here is my code for resize: https://gist.github.com/ehahehah/f9b4073f41b2a56482ce
UPDATE: I added an if statement (line 127) to check if inptr should be repositioned to the beginning of the scanline. https://gist.github.com/ehahehah/0acc422c6dbbd5ffe63f
This is what I got from check50. Previously without adding the if statement only the 1st 2 checks passed check50.
:) resize.c and bmp.h exist
:) resize.c compiles
:) doesn't resize 1x1-pixel BMP when n is 1
:( resizes 1x1-pixel BMP to 2x2 correctly when n is 2
:( resizes 1x1-pixel BMP to 3x3 correctly when n is 3
:( resizes 1x1-pixel BMP to 4x4 correctly when n is 4
:( resizes 1x1-pixel BMP to 5x5 correctly when n is 5
:( resizes 2x2-pixel BMP to 4x4 correctly when n is 2
UPDATE: I haven't seemed to have found what went wrong and I executed:
./resize 4 small.bmp student.bmp
~cs50/pset5/resize 4 small.bmp staff.bmp
~cs50/pset5/peek student.bmp staff.bmp
This is what I got:
From this can I conclude that the problem lies (only) in my header calculations?
Any help would be greatly appreciated!
UPDATE: Having realized that I was using the old headers for my new resized bmp files (with the help of jessicab4!) I made the necessary changes but check50 gave me this (the 3rd check is now a sad face):
:) resize.c and bmp.h exist
:) resize.c compiles
:( doesn't resize 1x1-pixel BMP when n is 1
:( resizes 1x1-pixel BMP to 2x2 correctly when n is 2
:( resizes 1x1-pixel BMP to 3x3 correctly when n is 3
:( resizes 1x1-pixel BMP to 4x4 correctly when n is 4
:( resizes 1x1-pixel BMP to 5x5 correctly when n is 5
:( resizes 2x2-pixel BMP to 4x4 correctly when n is 2