2

Look at the following code: fwrite(inptr, 512, 1, img); Why are you writing something back to the input file? Even if it was supposed to go to the output file, why would the same block be written out twice? Once by this line, and then again by the next fwrite statement? If this answers your question, please click on the check mark to accept. Let's ...


1

You've declared a new header struct, but you never gave it any values // write outfile's BITMAPFILEHEADER BITMAPFILEHEADER outfile_bf; fwrite(&outfile_bf, sizeof(outfile_bf), 1, outptr); Earlier you read the header from the file into a variable called bf. Perhaps you meant to set out_file bf = bf? Otherwise, you are writing garbage.


1

Hmmm..... After the code creates the output file headers, do you think it would be useful to load/copy the values from the input file headers into the output file headers? // write outfile's BITMAPFILEHEADER BITMAPFILEHEADER outfile_bf; fwrite(&outfile_bf, sizeof(outfile_bf), 1, outptr); // write outfile's BITMAPINFOHEADER BITMAPINFOHEADER ...


1

Looks like a typo in the fwrite statements. You want to write the block that was just read into buffer (not memCard).


1

Perhaps you should very carefully review the header fields that you are changing. Many have quite similar names, even the same name in both bi and bf headers. You should also use the peek tool to examine headers in both the input and output file. If you can't open the output file with peek, then you should use the xxd tool to look at the raw data. Also, ...


1

There are a number of errors in the code. It creates struct vars for the input file headers and reads the headers from the input file (correct), but then creates two more headers and reads again from the input file to populate them. The headers have already been read, so the file pointer is at the beginning of the image data. That image data is put into the ...


Only top voted, non community-wiki answers of a minimum length are eligible