Skip to main content
Source Link

pset5 resize working (IMO) but check50 says it's not

guys, I'm having a bit of an issue here.. I wrote the resize.c function for pset5 and it is working - I am getting the expected results - I can see my file being resized and it looks alright in image viewers .. and the information seems correct (resizing with a scale of 2 gives me a file that is 2x2 and has the same color). However, when submitting or checking with check50, it says my result is wrong. I have rewritten the program twice, also I found somebody else that wrote it and tried their implementation. The result is always the same - the file looks right and the output is the same, but my work is still not accepted. Here is my original file that I'm trying to resize (pixel.bmp):

xxd -c 4 -g 3 -s 54 infile.bmp
0000036: ffffff 00  ....

And this is the entire file:

xxd -c 2 -g 3 infile.bmp
0000000: 424d  BM
0000002: 3a00  :.
0000004: 0000  ..
0000006: 0000  ..
0000008: 0000  ..
000000a: 3600  6.
000000c: 0000  ..
000000e: 2800  (.
0000010: 0000  ..
0000012: 0100  ..
0000014: 0000  ..
0000016: 0100  ..
0000018: 0000  ..
000001a: 0100  ..
000001c: 1800  ..
000001e: 0000  ..
0000020: 0000  ..
0000022: 0400  ..
0000024: 0000  ..
0000026: 0000  ..
0000028: 0000  ..
000002a: 0000  ..
000002c: 0000  ..
000002e: 0000  ..
0000030: 0000  ..
0000032: 0000  ..
0000034: 0000  ..
0000036: ffff  ..
0000038: ff00  ..

When I run resize with a scale of 2, it works and is opened by image viewers, as expected. This is the outfile:

xxd -c 8 -g 3 -s54 outfile.bmp
0000036: ffffff ffffff 0000  ........
000003e: ffffff ffffff 0000  ........

And this is the entire outfile.bmp:

xxd -c 2 -g 3 outfile.bmp
0000000: 424d  BM
0000002: 4600  F.
0000004: 0000  ..
0000006: 0000  ..
0000008: 0000  ..
000000a: 3600  6.
000000c: 0000  ..
000000e: 2800  (.
0000010: 0000  ..
0000012: 0200  ..
0000014: 0000  ..
0000016: 0200  ..
0000018: 0000  ..
000001a: 0100  ..
000001c: 1800  ..
000001e: 0000  ..
0000020: 0000  ..
0000022: 1000  ..
0000024: 0000  ..
0000026: 0000  ..
0000028: 0000  ..
000002a: 0000  ..
000002c: 0000  ..
000002e: 0000  ..
0000030: 0000  ..
0000032: 0000  ..
0000034: 0000  ..
0000036: ffff  ..
0000038: ffff  ..
000003a: ffff  ..
000003c: 0000  ..
000003e: ffff  ..
0000040: ffff  ..
0000042: ffff  ..
0000044: 0000  ..

Everything looks right (to me) - the size seems to be correct, the BM is being sent and the padding looks right. Yet, check50 says it's not.

Can someone give me a hint of what is wrong here? Thanks in advance!

1 2
3