0

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

2 Answers 2

0

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.

2
0

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.

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

You must log in to answer this question.