I'm currently working on resize, and I attempted to solve the part about updating the outfile's header info, but I think I messed up somehow. The bi2.biWidth and bi2.biHeight (see my code) get set to 0 from the beginning for some reason. Can someone explain why? https://gist.github.com/AProgrammerZ/5eadef75760c127201596178c6d481d1


Don't read the header from your output file (not sure how this should work if you don't fclose the output first, or use "w+" mode), but copy the header (or modify the original and use that one). You can simply do bi2 = bi to copy all the fields over.


The code reads the headers from the input file and immediately writes them to the output file without recalculating anything. Does that make any sense?

Then certain fields are recalculated for the output file. While they may be used in processing the image, they're not making it into the headers in the output file.

This is the headers issue. There are others that, would warrant a new question, if needed.

If this answers your question, please click on the check mark to accept. Let's keep up on forum maintenance. ;-)

Note: this is based on code that may have changed since @Blauelf 's answer.

  • So you're saying I would have to fwrite the updated header info into the output file? Mar 27 '19 at 0:10
  • @AProgrammerZ Correct, read the input header, modify it or create a copy you modify, then write that to output file.
    – Blauelf
    Mar 27 '19 at 8:10
  • @AProgrammerZ Looks fine to me (assuming this is the first fwrite in the file)
    – Blauelf
    Mar 27 '19 at 16:44

You must log in to answer this question.

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