0

Can someone explain to me, why will there be a case where the first jpeg has already been found but subsequent jpeg doesn’t match the header?

I thought all jpegs should match the header?

If (header condition) { xxx write() }

Else { If(img != null) { fwrite() <<< // why do we write it anyway if header is not found, but first jpeg has already been found? }

Your help is much appreciated. Thanks.

1

I'm not sure what you're describing, but I think I know what you're really asking, so let's try.

When scanning the data in the card.raw file, the code needs to search for the first block of 512 bytes that has a header signature. Everything before that is garbage data to throw away. From this point forward, all the data is good data.

Now, here's what I think you're trying to figure out. Once you've found a 512 byte block that has a signature, it's the start of the first image file. BUT, it's not the WHOLE file. Blocks of data that follow will not have the header signature, but they're more of the data in that file! Remember, most image files are a lot larger than 512 bytes!

This means that all data blocks that follow the one with a signature are part of the same image file. Once the code finds the next header signature, that means that the data block with the signature is the beginning of the next file. Time to close the current file and open the next file.

Does that explain what's going on?

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

  • Thanks for answering my question in detail! You have clarified all my doubts! Cheers! :-) – Duckyhelp Jun 27 '19 at 0:18
  • please click on the check mark to accept. Otherwise, it'll stay in the unasnwered question pool forever. – Cliff B Jun 27 '19 at 0:50

You must log in to answer this question.

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