My code seems to work but check50 fails with
~/workspace/git/CS50/pset04/resize/ (master) $ check50 2016.resize.more bmp.h resize.c
:) resize.c and bmp.h exist
:) resize.c compiles
:) doesn't resize 1x1-pixel BMP when f is 1.0
:) resizes 1x1-pixel BMP to 2x2 correctly when f is 2.0
:) resizes 1x1-pixel BMP to 3x3 correctly when f is 3.0
:) resizes 1x1-pixel BMP to 4x4 correctly when f is 4.0
:) resizes 1x1-pixel BMP to 5x5 correctly when f is 5.0
:) resizes 2x2-pixel BMP to 4x4 correctly when f is 2.0
:( resizes 2x2-pixel BMP to 1x1 correctly when f is 0.5
:( resizes 4x4-pixel BMP to 2x2 correctly when f is 0.5
:( resizes 6x6-pixel BMP to 3x3 correctly when f is 0.5
Since small.bmp is a 3x3-pixel image I produced a 1x1-pixel image with the staff solution:
~/workspace/git/CS50/pset04/resize/ (master) $ ~cs50/hacker4/resize .333333333 small.bmp 1x1.bmp
and my solution ~/workspace/git/CS50/pset04/resize/ (master) $ ./resize .333333333 small.bmp student.bmp
and compared it to my solution with ~/workspace/git/CS50/pset04/resize/ (master) $ ~cs50/hacker4/peek student.bmp 1x1.bmp
:
offset type name argv[1] argv[2]
0 WORD bfType 4d42 4d42
2 DWORD bfSize 0000003a 0000003a
6 WORD bfReserved1 0000 0000
8 WORD bfReserved2 0000 0000
10 DWORD bfOffBits 00000036 00000036
14 DWORD biSize 00000028 00000028
18 LONG biWidth 00000001 00000001
22 LONG biHeight ffffffff ffffffff
26 WORD biPlanes 0001 0001
28 WORD biBitCount 0018 0018
30 DWORD biCompression 00000000 00000000
34 DWORD biSizeImage 00000004 00000004
38 LONG biXPelsPerMeter 00000b12 00000b12
42 LONG biYPelsPerMeter 00000b12 00000b12
46 DWORD biClrUsed 00000000 00000000
50 DWORD biClrImportant 00000000 00000000
~/workspace/git/CS50/pset04/resize/ (master) $ xxd -c 12 -g 3 -s 54 student.bmp
0000036: 00ff00 00
~/workspace/git/CS50/pset04/resize/ (master) $ xxd -c 12 -g 3 -s 54 1x1.bmp
0000036: 00ff00 00
I really don't know, what the problem is. Here are the interesting bits of my code:
The part that is different from copy.c:
// It works now, so I removed the code to not spoil anything.
// I forgot to skip lines and pixels when downscaling.