Я пытаюсь восстановить изображения с карты памяти, но большинство изображений, которые я получаю, повреждены. Кто-нибудь может сказать мне, почему это происходит? - PullRequest
0 голосов
/ 01 мая 2020
while( !feof(card))
{
  FILE *f1=fopen(gp[i],"a");                            //Opens a new file to store the bytes in
  fread(buffer1, sizeof(BYTE), 512, card);              //Reads a set of bytes from the card
  if (buffer1[0] == 0xff && buffer1[1] == 0xd8 && buffer1[2] == 0xff && buffer1[3]/0x10==0x0e)  //Checks whether the first 4 bytes match the start of a jpg
  {

      fwrite(buffer1, sizeof(BYTE), 512, f1);               //Writes the bytes on to the opened file
      fread(buffer1, sizeof(BYTE), 512, card);              //Reads the next set of bytes from the card

      while (buffer1[0] != 0xff && buffer1[1] != 0xd8 && buffer1[2] != 0xff && buffer1[3]/0x10!=0x0e)   //Repeats the below process till we find the start of a new jpg
      {
      fwrite(buffer1, sizeof(BYTE), 512, f1);               //Writes the bytes on to the opened file
      fread(buffer1, sizeof(BYTE), 512, card);              //Reads the next set of bytes from the card
      }
      fclose(f1);
      i++;
  }

1 Ответ

0 голосов
/ 04 мая 2020

Ребята, я выяснил проблемы. Самая большая проблема была связана с конечным условием while l oop, а другая проблема была связана с созданием бесконечного l oop. Я все еще не знаю почему, хотя. Спасибо за помощь

...