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 ...


2

There is a significant flaw in the code. The header vars are changed (probably correctly) but then stored in the original headers for the input file, bi, bf. Then the output file headers are written out to the output files, bih and bfh. This has led to input and output header fields being intermixed in both being written out to files and used in the code. ...


2

Your output file is too large, larger than the header claims. Use input height, not output height for the outermost for loop. Not sure this can explain the problem you describe, especially those numbers make me wonder. A common mistake would be confusing input and output padding, but all related cases I've seen so far produced some viewable output.


2

Effectively your algorithm is correct, but there is a small mess with the pointers, you declare a pointer to the buffer in which it will be written: uint8_t *buffer_ptr = malloc(FAT_BLOCK_SIZE); So, what is buffer_ptr ?, a pointer, the name itself is the pointer, since we have thus declared this variable. And what is & buffer_ptr ?, well it is a ...


1

See anything wrong here? fwrite(openFile, BLOCKSIZE, 1, openFile); If this answers your question, please click on the check mark to accept. Let's keep up on forum mainteance. ;-)


1

Along with using 1 and not n to write headers (no matter how large the file is scaled up, the headers are only written out once each), some of the header fields are wrong. Many of the header fields have very similar names. Look very closely at the fields that you are changing and verify that they are the correct fields to be changed! Then, use the peek and ...


1

At first read PSET4 RECOVER Can't Open JPEGS, I Have Tried Everything Please HELP! about sizeof(buffer) Then, do something with the whole logic of your code. Write it in your language (english or whatever it is) and then try to implement step by step with C. For now, I am sorry, but it is a mess. Just look what you are doing: You read a block from card....


1

There are a number of errors in the code that need to be resolved and other issues that haven't even been coded for. There are fields in the headers that haven't been updated. The padding for the input and output files need to be calculated independently. The pixels need to be output n times. Each line of pixels needs to be processed n times as well. There ...


1

If you had used the xxd tool to look at the output file, you would see that most of the header data is wrong. If you run the program multiple times, that incorrect data also changes from run to run. Interestingly, the fields that are explicitly changed in the program are correct. Did you remember to initialize the headers by copying the original header ...


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