I have a strange flaw in my program. Initially everything looks fine, it can resize any image correctly and the headers of the staff solutions and mine all match via "peek", so it seems that it makes an identical file. However, when I perform xxd on the copy I made, I notice my file is quite a bit longer!
For instance, when I resize small.bmp by 2, it looks fine on the image viewer and has a bfSize of (0xae) and biSizeImage of (0x78), which they should be.
However, xxd reveals this:
0000036: 00ff00 00ff00 00ff00 00ff00 00ff00 00ff00 0000 ....................
000004a: 00ff00 00ff00 00ff00 00ff00 00ff00 00ff00 0000 ....................
000005e: 00ff00 00ff00 ffffff ffffff 00ff00 00ff00 0000 ....................
0000072: 00ff00 00ff00 ffffff ffffff 00ff00 00ff00 0000 ....................
0000086: 00ff00 00ff00 00ff00 00ff00 00ff00 00ff00 0000 ....................
000009a: 00ff00 00ff00 00ff00 00ff00 00ff00 00ff00 0000 ....................
00000ae: 00ff00 00ff00 00ff00 00ff00 00ff00 00ff00 0000 ....................
00000c2: 00ff00 00ff00 00ff00 00ff00 000000 000000 0000 ....................
00000d6: 000000 000000 000000 000000 000000 000000 0000 ....................
00000ea: 00ff00 00ff00 000000 000000 000000 000000 0000 ....................
00000fe: 000000 000000 000000 000000 000000 000000 0000 ....................
0000112: 00ff00 00ff00 000000 000000 000000 000000 0000 ....................
As you can see, it's written beyond the size of the file!! How is that even possible. It should have stopped at (0xae), but just keeps going.
When I try to see what is causing this in gdb, I can't figure out whats wrong! The program actually does stop writing there, but again when I open it up via xxd it looks like this. Please help me out, I don't know why it keeps writing these extra pixels and it is very frustrating!
for
loop responsible for iterating over scanlines.