A few more things,
1. Your program is not portable, you should be #including <cmath> and <cstdlib>.
2. You have a dozen unused variables. Is it possibly a mistake that one or more of them aren't being used?
3. Your program expects .ppm file as input, but you have provided .png files. You're making us do unnecessary work in converting the test image to help you.
Bonus:
4. After converting your png to a ppm and running your program, the program crashes on me.
But this is only because of the manual destructor calls I mentioned earlier. However, after I removed those calls, the crash no longer happens, but the output.ppm is still severely misaligned, with incorrect dimensions.
standard output of your program:
input.ppm is a PPM file (raw version)!
done
done
done
450 823 |
Those dimensions seem backwards to me?
Your jpg* functions expect {height, width} as input, but you are inputting {width, height}. Your readppm function is also mixing up width and height.
Maybe that helps. Perhaps you're consistently switching the two, canceling out errors. But the image that I produced by running your code definitely has wrong dimensions.