0

Check50 is failing my code and I am out of options to troubleshoot this. Any help from the community is greatly appreciated.

I have compared different resizing factors for small.bmp and smiley.bmp between my code and the staff. There is not a single difference using diff and peek:

-rw-------. 1 jharvard students   3661 Sep  5 22:43 resize.c
-rw-------. 1 jharvard students    174 Sep  5 23:02 small-by2-staff.bmp
-rw-------. 1 jharvard students    174 Sep  5 23:02 small-by2-stud.bmp
-rw-------. 1 jharvard students    306 Sep  5 23:02 small-by3-staff.bmp
-rw-------. 1 jharvard students    306 Sep  5 23:03 small-by3-stud.bmp

-rw-------. 1 jharvard students    822 Sep  5 23:04 smiley-by2-staff.bmp
-rw-------. 1 jharvard students    822 Sep  5 23:03 smiley-by2-stud.bmp
-rw-------. 1 jharvard students   1782 Sep  5 23:04 smiley-by3-staff.bmp
-rw-------. 1 jharvard students   1782 Sep  5 23:05 smiley-by3-stud.bmp

jharvard@appliance (~/Dropbox/pset5/bmp): diff small-by2-staff.bmp small-by2-stud.bmp
jharvard@appliance (~/Dropbox/pset5/bmp): diff small-by3-staff.bmp small-by3-stud.bmp
jharvard@appliance (~/Dropbox/pset5/bmp): diff smiley-by2-staff.bmp smiley-by2-stud.bmp
jharvard@appliance (~/Dropbox/pset5/bmp): diff smiley-by3-staff.bmp smiley-by3-stud.bmp

check50 fails here:

:) 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  <------- Failure
https://sandbox.cs50.net/checks/9be673944671478f97cfcdeb563389e7
4
  • 1
    Try resizing your small-by2-staff.bmp by 2 and comparing. Does that show any diffs? – curiouskiwi Sep 6 '14 at 5:21
  • Thanks for your suggestion. I found something in the diff now and will check what is causing it... Here's the comparison so far: – Walter Roncada Sep 6 '14 at 14:41
  • jharvard@appliance (~/Dropbox/pset5/bmp): diff small-by2-by2-staff.bmp small-by2-by2-stud.bmp boldBinary files small-by2-by2-staff.bmp and small-by2-by2-stud.bmp differbold <br>jharvard@appliance (~/Dropbox/pset5/bmp): ll small-by2-by2-staff.bmp small-by2-by2-stud.bmp <br>-rw-------. 1 jharvard students 486 Sep 6 10:36 small-by2-by2-staff.bmp <br>-rw-------. 1 jharvard students 486 Sep 6 10:35 small-by2-by2-stud.bmp – Walter Roncada Sep 6 '14 at 14:50
  • Thanks for your suggestion. I found something in the diff now and will check what is causing it... Here's part of the comparison so far: <br>offset type name argv[1] argv[2] <br>2 DWORD bfSize 000001e6 <br>14 DWORD biSize 00000028 00000028 <br>18 LONG biWidth 0000000c 0000000c <br>22 LONG biHeight fffffff4 fffffff4 <br>28 WORD biBitCount 0018 0018 <br>34 DWORD biSizeImage 000001b0 000001b0 – Walter Roncada Sep 6 '14 at 14:52
1

I finally fixed resize.c based on curiouskiwi's suggestion.

For those having the same problem here's what I realized was wrong with my previous tries. I had to pay close attention to padding, both from the infile and the outfile. In my case CHECK50 only marked red to the last check :-( because THERE the pads required are not multiples of 3 which is a pitfall if you are reading and writing triplets (BGR) at once.

You must log in to answer this question.

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