0


While submitting resize.c to check50 in pset5, I get the following results: check50 2014/x/pset5/resize bmp.h resize.c


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

As you can see all is well in resizing but the last one has a :-( The course does not provide a 2x2 bmp so I created and uploaded one and run the following:
jharvard@appliance (~/Dropbox/pset5/bmp): ./resize 2 twobytwo2.bmp student.bmp
jharvard@appliance (~/Dropbox/pset5/bmp): ~cs50/pset5/resize 2 twobytwo2.bmp staff.bmp
jharvard@appliance (~/Dropbox/pset5/bmp): ~cs50/pset5/peek student.bmp staff.bmp

The results are identical: offset type name argv[1] argv[2]
0 WORD bfType 4d42 4d42
2 DWORD bfSize 00000066 00000066
6 WORD bfReserved1 0000 0000
8 WORD bfReserved2 0000 0000
10 DWORD bfOffBits 00000036 00000036
14 DWORD biSize 00000028 00000028
18 LONG biWidth 00000004 00000004
22 LONG biHeight 00000004 00000004
26 WORD biPlanes 0001 0001
28 WORD biBitCount 0018 0018
30 DWORD biCompression 00000000 00000000
34 DWORD biSizeImage 00000030 00000030
38 LONG biXPelsPerMeter 00000b13 00000b13
42 LONG biYPelsPerMeter 00000b13 00000b13
46 DWORD biClrUsed 00000000 00000000
50 DWORD biClrImportant 00000000 00000000

SO I AM AT A LOSS ON WHAT COULD BE WRONG. iS THERE ANYBODY THAT COULD HELP WITH THIS?
Thanks a Lot.

2
  • So your headers are okay, but did you check the pixels, using xxd? Also, what happens if you resize small.bmp by 2? – curiouskiwi Sep 4 '14 at 5:08
  • Yep, I have more padding than the staff solution and smaller than 0x66. This must be the problem, yet it is misleading that check50 returns "resizes 2x2-pixel BMP to 4x4 correctly when n is 2" I will fix the padding and post here if all is fine. Thanks. – Walter Roncada Sep 4 '14 at 13:46
0

The problem was a wrong number of padding. Correcting these will yield exactly the same outputs produced by the staff code.

3
  • Talked too soon... the problem persists and I have no clue on how to troubleshoot it. – Walter Roncada Sep 6 '14 at 2:52
  • Will open a new the thread with the same issue. – Walter Roncada Sep 6 '14 at 2:53
  • 1
    Then delete this answer, and add it as a comment to your original question, please. – ChiCubed Dec 31 '14 at 5:30

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